mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-09 17:11:35 +01:00
Null check mania!
This commit is contained in:
parent
080bb69927
commit
03a1212e6b
BIN
MobArena.jar
BIN
MobArena.jar
Binary file not shown.
@ -300,7 +300,7 @@ public class Arena
|
|||||||
playerLeave(p);
|
playerLeave(p);
|
||||||
|
|
||||||
for (Entity e : monsters)
|
for (Entity e : monsters)
|
||||||
e.remove();
|
if (e != null) e.remove();
|
||||||
|
|
||||||
if (bossWave != null)
|
if (bossWave != null)
|
||||||
bossWave.clear();
|
bossWave.clear();
|
||||||
@ -465,6 +465,8 @@ public class Arena
|
|||||||
|
|
||||||
for (LivingEntity e : new LinkedList<LivingEntity>(explodingSheep))
|
for (LivingEntity e : new LinkedList<LivingEntity>(explodingSheep))
|
||||||
{
|
{
|
||||||
|
if (e == null) continue;
|
||||||
|
|
||||||
Creature c = (Creature) e;
|
Creature c = (Creature) e;
|
||||||
if (c.getTarget() != null && e.getLocation().distanceSquared(c.getTarget().getLocation()) < 8)
|
if (c.getTarget() != null && e.getLocation().distanceSquared(c.getTarget().getLocation()) < 8)
|
||||||
{
|
{
|
||||||
@ -777,13 +779,13 @@ public class Arena
|
|||||||
if (bossWave != null)
|
if (bossWave != null)
|
||||||
bossWave.clear();
|
bossWave.clear();
|
||||||
for (LivingEntity e : monsters)
|
for (LivingEntity e : monsters)
|
||||||
e.remove();
|
if (e != null) e.remove();
|
||||||
for (LivingEntity e : explodingSheep)
|
for (LivingEntity e : explodingSheep)
|
||||||
e.remove();
|
if (e != null) e.remove();
|
||||||
for (LivingEntity e : plaguedPigs)
|
for (LivingEntity e : plaguedPigs)
|
||||||
e.remove();
|
if (e != null) e.remove();
|
||||||
for (LivingEntity e : madCows)
|
for (LivingEntity e : madCows)
|
||||||
e.remove();
|
if (e != null) e.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeBlocks()
|
private void removeBlocks()
|
||||||
@ -796,6 +798,8 @@ public class Arena
|
|||||||
{
|
{
|
||||||
for (Wolf w : pets)
|
for (Wolf w : pets)
|
||||||
{
|
{
|
||||||
|
if (w == null) continue;
|
||||||
|
|
||||||
w.setOwner(null);
|
w.setOwner(null);
|
||||||
w.remove();
|
w.remove();
|
||||||
}
|
}
|
||||||
@ -805,7 +809,7 @@ public class Arena
|
|||||||
{
|
{
|
||||||
for (Wolf w : pets)
|
for (Wolf w : pets)
|
||||||
{
|
{
|
||||||
if (!((Player) w.getOwner()).getName().equals(p.getName()))
|
if (w == null || !((Player) w.getOwner()).getName().equals(p.getName()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
w.setOwner(null);
|
w.setOwner(null);
|
||||||
@ -824,7 +828,7 @@ public class Arena
|
|||||||
for (int j = c1.getZ(); j <= c2.getZ(); j++)
|
for (int j = c1.getZ(); j <= c2.getZ(); j++)
|
||||||
for (Entity e : world.getChunkAt(i,j).getEntities())
|
for (Entity e : world.getChunkAt(i,j).getEntities())
|
||||||
if ((e instanceof Item || e instanceof Slime) && inRegion(e.getLocation()))
|
if ((e instanceof Item || e instanceof Slime) && inRegion(e.getLocation()))
|
||||||
e.remove();
|
if (e != null) e.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,6 +87,8 @@ public class MASpawnThread implements Runnable
|
|||||||
List<Entity> tmp = new LinkedList<Entity>(arena.monsters);
|
List<Entity> tmp = new LinkedList<Entity>(arena.monsters);
|
||||||
for (Entity e : tmp)
|
for (Entity e : tmp)
|
||||||
{
|
{
|
||||||
|
if (e == null) continue;
|
||||||
|
|
||||||
if (e.isDead() || !arena.inRegion(e.getLocation()))
|
if (e.isDead() || !arena.inRegion(e.getLocation()))
|
||||||
{
|
{
|
||||||
arena.monsters.remove(e);
|
arena.monsters.remove(e);
|
||||||
@ -230,6 +232,8 @@ public class MASpawnThread implements Runnable
|
|||||||
Location loc;
|
Location loc;
|
||||||
for (Entity e : tmp)
|
for (Entity e : tmp)
|
||||||
{
|
{
|
||||||
|
if (e == null) continue;
|
||||||
|
|
||||||
arena.monsters.remove(e);
|
arena.monsters.remove(e);
|
||||||
loc = e.getLocation().getBlock().getRelative(0,2,0).getLocation();
|
loc = e.getLocation().getBlock().getRelative(0,2,0).getLocation();
|
||||||
arena.world.createExplosion(loc, 2);
|
arena.world.createExplosion(loc, 2);
|
||||||
|
@ -84,8 +84,11 @@ public abstract class AbstractWave implements Wave
|
|||||||
*/
|
*/
|
||||||
public LivingEntity spawnMonster(MACreature creature, Location loc)
|
public LivingEntity spawnMonster(MACreature creature, Location loc)
|
||||||
{
|
{
|
||||||
// Spawn and add to collection
|
// Spawn
|
||||||
LivingEntity e = creature.spawn(getArena(), getWorld(), loc);
|
LivingEntity e = creature.spawn(getArena(), getWorld(), loc);
|
||||||
|
if (e == null) return null;
|
||||||
|
|
||||||
|
// Add to collection
|
||||||
getArena().addMonster(e);
|
getArena().addMonster(e);
|
||||||
|
|
||||||
// Boost health
|
// Boost health
|
||||||
|
@ -135,6 +135,8 @@ public class BossWave extends AbstractWave
|
|||||||
cancelAbilityTask();
|
cancelAbilityTask();
|
||||||
getArena().setBossWave(null);
|
getArena().setBossWave(null);
|
||||||
|
|
||||||
|
if (bossCreature == null) return;
|
||||||
|
|
||||||
CraftEntity ce = (CraftEntity) bossCreature;
|
CraftEntity ce = (CraftEntity) bossCreature;
|
||||||
CraftWorld cw = (CraftWorld) getWorld();
|
CraftWorld cw = (CraftWorld) getWorld();
|
||||||
WorldServer ws = cw.getHandle();
|
WorldServer ws = cw.getHandle();
|
||||||
|
@ -65,6 +65,7 @@ public class SwarmWave extends AbstractWave
|
|||||||
for (int i = 0; i < amount; i++)
|
for (int i = 0; i < amount; i++)
|
||||||
{
|
{
|
||||||
LivingEntity e = spawnMonster(monster, spawnpoints.get(i % spawnpointCount));
|
LivingEntity e = spawnMonster(monster, spawnpoints.get(i % spawnpointCount));
|
||||||
|
if (e == null) continue;
|
||||||
|
|
||||||
// Boost health
|
// Boost health
|
||||||
int health = (int) Math.min(150D, 1 * getHealthMultiplier());
|
int health = (int) Math.min(150D, 1 * getHealthMultiplier());
|
||||||
|
Loading…
Reference in New Issue
Block a user