Fix for null entities.

https://github.com/tastybento/bskyblock/issues/206
This commit is contained in:
tastybento 2018-07-17 07:54:22 -07:00
parent 5572875257
commit ee440b4f0d
2 changed files with 20 additions and 13 deletions

View File

@ -30,7 +30,7 @@ public class MobSpawnListener extends AbstractFlagListener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public boolean onNaturalMobSpawn(CreatureSpawnEvent e) {
// If not in the right world, return
if (!getIWM().inWorld(e.getEntity().getLocation())) {
if (e.getEntity() == null || !getIWM().inWorld(e.getEntity().getLocation())) {
return false;
}
// Deal with natural spawning

View File

@ -126,6 +126,13 @@ public class MobSpawnListenerTest {
}
@Test
public void testNullEntity() {
CreatureSpawnEvent e = new CreatureSpawnEvent(null, SpawnReason.NATURAL);
MobSpawnListener l = new MobSpawnListener();
assertFalse(l.onNaturalMobSpawn(e));
assertFalse(e.isCancelled());
}
@Test
public void testNotInWorld() {