Archiviert
13
0

Updates to all Entities to use getBukkitEntity() any time an event is

raised.
Similar update to CraftVehicle and CraftLivingEntity
Dieser Commit ist enthalten in:
Andrew Ardill 2011-01-17 08:53:42 +08:00 committet von Dinner Bone
Ursprung 3400eafaf1
Commit 5f2c8108b7
14 geänderte Dateien mit 34 neuen und 70 gelöschten Zeilen

Datei anzeigen

@ -222,9 +222,8 @@ public abstract class Entity {
// CraftBukkit start
if(this instanceof EntityLiving) {
CraftServer server = ((WorldServer)l).getServer();
CraftEntity damagee = new CraftLivingEntity(server, (EntityLiving)this);
EntityDamageEvent ede = new EntityDamageEvent(damagee, EntityDamageEvent.DamageCause.DROWNING, 1);
EntityDamageEvent ede = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.DROWNING, 1);
server.getPluginManager().callEvent(ede);
if (!ede.isCancelled()){
@ -256,15 +255,14 @@ public abstract class Entity {
// CraftBukkit start
if(this instanceof EntityLiving) {
CraftServer server = ((WorldServer)l).getServer();
CraftEntity defender = new CraftLivingEntity(server, (EntityLiving) this);
EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(null, defender, EntityDamageEvent.DamageCause.LAVA, 4);
EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(null, this.getBukkitEntity(), EntityDamageEvent.DamageCause.LAVA, 4);
server.getPluginManager().callEvent(ede);
if (!ede.isCancelled()){
a(((Entity) (null)), ede.getDamage());
}
EntityCombustEvent ece = new EntityCombustEvent(Type.ENTITY_COMBUST, defender);
EntityCombustEvent ece = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity());
server.getPluginManager().callEvent(ece);
if (!ece.isCancelled()){
Z = 600;
@ -507,16 +505,9 @@ public abstract class Entity {
if (!ae) {
// CraftBukkit start
if(this instanceof EntityLiving) {
CraftEntity defender = null;
CraftServer server = ((WorldServer)l).getServer();
if (this instanceof EntityPlayerMP) {
defender = new CraftPlayer(server, (EntityPlayerMP)this);
} else {
defender = new CraftLivingEntity(server, (EntityLiving)this);
}
EntityDamageEvent ede = new EntityDamageEvent(defender, EntityDamageEvent.DamageCause.FIRE, i1);
EntityDamageEvent ede = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.FIRE, i1);
server.getPluginManager().callEvent(ede);
if (!ede.isCancelled()){

Datei anzeigen

@ -176,14 +176,10 @@ public class EntityArrow extends Entity {
boolean bounce;
if (entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer();
CraftEntity damagee = new CraftLivingEntity(server, (EntityLiving) entity);
CraftEntity damager = new CraftLivingEntity(server, b);
CraftEntity projectile = new CraftArrow(server, (EntityArrow) this);
//TODO decide if we should create DamageCause.ARROW, DamageCause.PROJECTILE
// or leave as DamageCause.ENTITY_ATTACK
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(
damager, damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 4);
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(b.getBukkitEntity(), entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 4);
server.getPluginManager().callEvent(edbpe);
if(!edbpe.isCancelled()) {

Datei anzeigen

@ -10,6 +10,7 @@ import org.bukkit.craftbukkit.entity.CraftBoat;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.CraftMappable;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.Event.Type;
import org.bukkit.event.vehicle.VehicleCreateEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
@ -31,8 +32,9 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
private double am;
// CraftBukkit start
/**@deprecated*/
private CraftBoat boat;
/**@deprecated*/
public CraftEntity getCraftEntity() {
return boat;
}
@ -85,8 +87,7 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
// CraftBukkit start
private void handleCreation(World world) {
CraftServer server = ((WorldServer) world).getServer();
boat = new CraftBoat(server, this);
VehicleCreateEvent event = new VehicleCreateEvent( Type.VEHICLE_CREATE, boat);
VehicleCreateEvent event = new VehicleCreateEvent( Type.VEHICLE_CREATE, (Vehicle) this.getBukkitEntity());
server.getPluginManager().callEvent(event);
}
// CraftBukkit end
@ -97,7 +98,7 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
public boolean a(Entity entity, int i) {
// CraftBukkit start
VehicleDamageEvent event = new VehicleDamageEvent( Type.VEHICLE_DAMAGE, boat, ((WorldServer)l).getWorld().toCraftEntity(entity), i);
VehicleDamageEvent event = new VehicleDamageEvent( Type.VEHICLE_DAMAGE, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity(), i);
((WorldServer) l).getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
@ -290,12 +291,7 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
// CraftBukkit start
CraftServer server = ((WorldServer)l).getServer();
VehicleMoveEvent event = new VehicleMoveEvent(
Type.VEHICLE_MOVE,
boat,
new Location(((WorldServer)l).getWorld(), prevX, prevY, prevZ, prevYaw, prevPitch),
new Location(((WorldServer)l).getWorld(), p, q, r, v, w)
);
VehicleMoveEvent event = new VehicleMoveEvent(Type.VEHICLE_MOVE, (Vehicle) this.getBukkitEntity(), new Location(((WorldServer)l).getWorld(), prevX, prevY, prevZ, prevYaw, prevPitch), new Location(((WorldServer)l).getWorld(), p, q, r, v, w));
server.getPluginManager().callEvent(event);
// CraftBukkit end
@ -330,7 +326,7 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
// CraftBukkit start
public void c(Entity entity) {
CraftServer server = ((WorldServer)l).getServer();
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent( Type.VEHICLE_COLLISION_ENTITY, boat, ((WorldServer)l).getWorld().toCraftEntity(entity));
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent( Type.VEHICLE_COLLISION_ENTITY, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
server.getPluginManager().callEvent(collsionEvent);
if (collsionEvent.isCancelled()) {
@ -352,7 +348,7 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
if (!l.z) {
// CraftBukkit start
CraftServer server = ((WorldServer)l).getServer();
VehicleEnterEvent event = new VehicleEnterEvent( Type.VEHICLE_ENTER, boat, ((WorldServer)l).getWorld().toCraftEntity(entityplayer));
VehicleEnterEvent event = new VehicleEnterEvent( Type.VEHICLE_ENTER, (Vehicle) this.getBukkitEntity(), entityplayer.getBukkitEntity());
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {

Datei anzeigen

@ -5,6 +5,7 @@ import java.util.Random;
// CraftBukkit start
import org.bukkit.entity.MobType;
import org.bukkit.entity.Player;
import org.bukkit.craftbukkit.entity.CraftArrow;
import org.bukkit.craftbukkit.entity.CraftEgg;
import org.bukkit.craftbukkit.entity.CraftEntity;
@ -182,12 +183,9 @@ public class EntityEgg extends Entity {
boolean bounce;
if (movingobjectposition.g instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer();
CraftEntity damagee = new CraftLivingEntity(server, (EntityLiving) movingobjectposition.g);
CraftEntity damager = new CraftLivingEntity(server, ak);
CraftEntity projectile = new CraftEgg(server, (EntityEgg) this);
//TODO @see EntityArrow#162
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent( damager, damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent( ak.getBukkitEntity(), movingobjectposition.g.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
server.getPluginManager().callEvent(edbpe);
if(!edbpe.isCancelled()) {
@ -216,8 +214,7 @@ public class EntityEgg extends Entity {
if (ak instanceof EntityPlayerMP) {
CraftServer server = ((WorldServer) l).getServer();
CraftPlayer player = new CraftPlayer(server, (EntityPlayerMP) ak);
PlayerEggThrowEvent event = new PlayerEggThrowEvent(Type.PLAYER_EGG_THROW, player, hatching, numHatching, type);
PlayerEggThrowEvent event = new PlayerEggThrowEvent(Type.PLAYER_EGG_THROW, (Player) ak.getBukkitEntity(), hatching, numHatching, type);
server.getPluginManager().callEvent(event);
hatching = event.isHatching();
numHatching = event.getNumHatches();

Datei anzeigen

@ -140,12 +140,9 @@ public class EntityFireball extends Entity {
boolean bounce;
if (movingobjectposition.g instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer();
CraftEntity damagee = new CraftLivingEntity(server, (EntityLiving) movingobjectposition.g);
CraftEntity damager = new CraftLivingEntity(server, an);
CraftEntity projectile = new CraftFireball(server, (EntityFireball) this);
//TODO @see EntityArrow#162
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent( damager, damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent( an.getBukkitEntity(), movingobjectposition.g.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
server.getPluginManager().callEvent(edbpe);
if(!edbpe.isCancelled()) {

Datei anzeigen

@ -211,12 +211,9 @@ public class EntityFish extends Entity {
boolean bounce;
if (movingobjectposition.g instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer();
CraftEntity damagee = new CraftLivingEntity(server, (EntityLiving) movingobjectposition.g);
CraftEntity damager = new CraftLivingEntity(server, b);
CraftEntity projectile = new CraftFish(server, (EntityFish) this);
//TODO @see EntityArrow#162
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent( damager, damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(b.getBukkitEntity(), movingobjectposition.g.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
server.getPluginManager().callEvent(edbpe);
if(!edbpe.isCancelled()) {

Datei anzeigen

@ -12,6 +12,7 @@ import org.bukkit.craftbukkit.entity.CraftStorageMinecart;
import org.bukkit.craftbukkit.CraftMappable;
import org.bukkit.craftbukkit.entity.CraftMinecart;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.Event.Type;
import org.bukkit.event.vehicle.*;
// CraftBukkit end
@ -100,6 +101,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
// CraftBukkit start
protected org.bukkit.entity.Entity bukkitPoweredMinecart; //CraftBukkit
protected org.bukkit.entity.Entity bukkitStorageMinecart; //CraftBukkit
/**@deprecated*/
private CraftMinecart minecart;
private boolean slowWhenEmpty = true;
@ -109,6 +111,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
private double flyingX = 0.94999998807907104;
private double flyingY = 0.94999998807907104;
private double flyingZ = 0.94999998807907104;
/**@deprecated*/
public CraftEntity getCraftEntity() {
return minecart;
}
@ -170,8 +173,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
// CraftBukkit start
private void handleCreation(World world) {
CraftServer server = ((WorldServer) world).getServer();
minecart = CraftMinecart.getCraftMinecart(server, this);
VehicleCreateEvent event = new VehicleCreateEvent( Type.VEHICLE_CREATE, minecart);
VehicleCreateEvent event = new VehicleCreateEvent(Type.VEHICLE_CREATE, (Vehicle) this.getBukkitEntity());
server.getPluginManager().callEvent(event);
}
// CraftBukkit end
@ -182,7 +184,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
public boolean a(Entity entity, int i) {
// CraftBukkit start
VehicleDamageEvent event = new VehicleDamageEvent( Type.VEHICLE_DAMAGE, minecart, ((WorldServer)l).getWorld().toCraftEntity(entity), i);
VehicleDamageEvent event = new VehicleDamageEvent(Type.VEHICLE_DAMAGE, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity(), i);
((WorldServer)l).getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
@ -505,12 +507,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
// CraftBukkit start
CraftServer server = ((WorldServer)this.l).getServer();
VehicleMoveEvent event = new VehicleMoveEvent(
Type.VEHICLE_MOVE,
minecart,
new Location(((WorldServer)this.l).getWorld(), prevX, prevY, prevZ, prevYaw, prevPitch),
new Location(((WorldServer)this.l).getWorld(), p, q, r, v, w)
);
VehicleMoveEvent event = new VehicleMoveEvent(Type.VEHICLE_MOVE, (Vehicle) this.getBukkitEntity(), new Location(((WorldServer)this.l).getWorld(), prevX, prevY, prevZ, prevYaw, prevPitch), new Location(((WorldServer)this.l).getWorld(), p, q, r, v, w));
server.getPluginManager().callEvent(event);
// CraftBukkit end
@ -646,7 +643,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
// CraftBukkit start
CraftServer server = ((WorldServer)l).getServer();
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent( Type.VEHICLE_COLLISION_ENTITY, minecart, ((WorldServer)l).getWorld().toCraftEntity(entity));
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(Type.VEHICLE_COLLISION_ENTITY, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
server.getPluginManager().callEvent(collsionEvent);
if (collsionEvent.isCancelled()) {
@ -655,7 +652,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
if ((entity instanceof EntityLiving) && !(entity instanceof EntityPlayer) && d == 0 && s * s + u * u > 0.01D && j == null && entity.k == null) {
if (!collsionEvent.isPickupCancelled()) {
VehicleEnterEvent enterEvent = new VehicleEnterEvent( Type.VEHICLE_ENTER, minecart, ((WorldServer)l).getWorld().toCraftEntity(entity));
VehicleEnterEvent enterEvent = new VehicleEnterEvent(Type.VEHICLE_ENTER, (Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
server.getPluginManager().callEvent(enterEvent);
if (!enterEvent.isCancelled()) {
@ -772,7 +769,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
if (!l.z) {
// CraftBukkit start
CraftServer server = ((WorldServer) l).getServer();
VehicleEnterEvent event = new VehicleEnterEvent( Type.VEHICLE_ENTER, minecart, ((WorldServer)l).getWorld().toCraftEntity(entityplayer));
VehicleEnterEvent event = new VehicleEnterEvent(Type.VEHICLE_ENTER, (Vehicle) this.getBukkitEntity(), entityplayer.getBukkitEntity());
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {

Datei anzeigen

@ -72,10 +72,8 @@ public class EntityMobs extends EntityCreature implements IMobs {
// CraftBukkit start
if(entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) l).getServer();
CraftEntity damagee = new CraftLivingEntity(server, (EntityLiving) entity);
CraftEntity damager = new CraftLivingEntity(server, this);
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, c);
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, c);
server.getPluginManager().callEvent(edbee);
if (!edbee.isCancelled()){

Datei anzeigen

@ -342,10 +342,8 @@ public abstract class EntityPlayer extends EntityLiving {
// CraftBukkit start
if(entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) l).getServer();
CraftEntity damagee = new CraftLivingEntity(server, (EntityLiving) entity);
CraftEntity damager = new CraftLivingEntity(server, this);
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, i);
server.getPluginManager().callEvent(edbee);
if (!edbee.isCancelled()){

Datei anzeigen

@ -41,7 +41,7 @@ public class EntitySkeleton extends EntityMobs {
if (f1 > 0.5F && l.i(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) && W.nextFloat() * 30F < (f1 - 0.4F) * 2.0F) {
// CraftBukkit start
CraftServer server = ((WorldServer) l).getServer();
EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, new CraftLivingEntity(server, (EntityLiving) this));
EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity());
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
Z = 300;

Datei anzeigen

@ -177,12 +177,9 @@ public class EntitySnowball extends Entity {
boolean bounce;
if (movingobjectposition.g instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer();
CraftEntity damagee = new CraftLivingEntity(server, (EntityLiving) movingobjectposition.g);
CraftEntity damager = new CraftLivingEntity(server, ak);
CraftEntity projectile = new CraftSnowball(server, (EntitySnowball) this);
//TODO @see EntityArrow#162
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent( damager, damagee, projectile, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent( ak.getBukkitEntity(), movingobjectposition.g.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, 0);
server.getPluginManager().callEvent(edbpe);
if(!edbpe.isCancelled()) {

Datei anzeigen

@ -29,7 +29,7 @@ public class EntityZombie extends EntityMobs {
if (f1 > 0.5F && l.i(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) && W.nextFloat() * 30F < (f1 - 0.4F) * 2.0F) {
// CraftBukkit start
CraftServer server = ((WorldServer) l).getServer();
EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, new CraftLivingEntity(server, (EntityLiving) this));
EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity());
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
Z = 300;

Datei anzeigen

@ -89,7 +89,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return null;
}
org.bukkit.entity.Entity vehicle = ((CraftWorld)getWorld()).toCraftEntity(entity.k);
org.bukkit.entity.Entity vehicle = (entity.k.getBukkitEntity());
if (vehicle instanceof Vehicle) {
return (Vehicle)vehicle;
}

Datei anzeigen

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