Fix up NPE's in EntityMinecart/CraftVehicle and removed a little un-needed code in EntityArrow

This commit is contained in:
speakeasy 2011-01-20 05:41:02 +08:00 committed by tahg
parent eabdc7ffa9
commit e93061be48
3 changed files with 7 additions and 5 deletions

View File

@ -178,9 +178,7 @@ public class EntityArrow extends Entity {
// or leave as DamageCause.ENTITY_ATTACK // or leave as DamageCause.ENTITY_ATTACK
org.bukkit.entity.Entity shooter = null; org.bukkit.entity.Entity shooter = null;
if ((EntityLiving)b != null) { if ((EntityLiving)b != null) {
shooter = new org.bukkit.craftbukkit.entity.CraftLivingEntity(server, b); shooter = b.getBukkitEntity();
} else if ((Entity)b != null) {
shooter = (org.bukkit.entity.Entity) b.getBukkitEntity();
} }
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 4); EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 4);

View File

@ -183,7 +183,11 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
public boolean a(Entity entity, int i) { public boolean a(Entity entity, int i) {
// CraftBukkit start // CraftBukkit start
VehicleDamageEvent event = new VehicleDamageEvent(Type.VEHICLE_DAMAGE, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity(), i); org.bukkit.entity.Entity passenger = null;
if ((EntityLiving)entity != null) {
passenger = entity.getBukkitEntity();
}
VehicleDamageEvent event = new VehicleDamageEvent(Type.VEHICLE_DAMAGE, (Vehicle) this.getBukkitEntity(), passenger, i);
((WorldServer)l).getServer().getPluginManager().callEvent(event); ((WorldServer)l).getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {

View File

@ -16,7 +16,7 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
} }
public Entity getPassenger() { public Entity getPassenger() {
return (getHandle().j.getBukkitEntity()); return isEmpty()?null:(getHandle().j.getBukkitEntity());
} }
public boolean setPassenger(Entity passenger) { public boolean setPassenger(Entity passenger) {