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