mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 19:55:17 +01:00
Fix for null entities.
https://github.com/tastybento/bskyblock/issues/206
This commit is contained in:
parent
5572875257
commit
ee440b4f0d
@ -30,7 +30,7 @@ public class MobSpawnListener extends AbstractFlagListener {
|
|||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public boolean onNaturalMobSpawn(CreatureSpawnEvent e) {
|
public boolean onNaturalMobSpawn(CreatureSpawnEvent e) {
|
||||||
// If not in the right world, return
|
// If not in the right world, return
|
||||||
if (!getIWM().inWorld(e.getEntity().getLocation())) {
|
if (e.getEntity() == null || !getIWM().inWorld(e.getEntity().getLocation())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Deal with natural spawning
|
// Deal with natural spawning
|
||||||
|
@ -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
|
@Test
|
||||||
public void testNotInWorld() {
|
public void testNotInWorld() {
|
||||||
|
Loading…
Reference in New Issue
Block a user