Archiviert
13
0

Handle null targets in target event. Fixes BUKKIT-5635

Dieser Commit ist enthalten in:
Travis Watkins 2014-05-26 19:28:11 -05:00
Ursprung 3fbf4d3b5f
Commit 38fbe60d46
2 geänderte Dateien mit 10 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -64,8 +64,12 @@ public class EntityIronGolem extends EntityGolem {
// CraftBukkit start // CraftBukkit start
org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(this, (EntityLiving) entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.COLLISION); org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(this, (EntityLiving) entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.COLLISION);
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.setGoalTarget(null);
} else {
this.setGoalTarget(((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle()); this.setGoalTarget(((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle());
} }
}
// CraftBukkit end // CraftBukkit end
} }

Datei anzeigen

@ -191,9 +191,12 @@ public class EntityZombie extends EntityMonster {
this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
// CraftBukkit start - call EntityTargetEvent // CraftBukkit start - call EntityTargetEvent
org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entityzombie, entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET); org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entityzombie, entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET);
entityliving = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle();
if (!event.isCancelled()) { if (!event.isCancelled()) {
entityzombie.setGoalTarget(entityliving); if (event.getTarget() == null) {
entityzombie.setGoalTarget(null);
} else {
entityzombie.setGoalTarget(((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle());
}
} }
// CraftBukkit end // CraftBukkit end
entityzombie.a((GroupDataEntity) null); entityzombie.a((GroupDataEntity) null);