Merge branch 'EntityDamageEvent_bugFixes' into HEAD

This commit is contained in:
Andrew Ardill 2011-01-18 19:43:50 +11:00
commit e99980983d
33 changed files with 100 additions and 48 deletions

View File

@ -9,6 +9,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
// CraftBukkit end
import java.util.Random;
@ -100,16 +101,21 @@ public class BlockCactus extends Block {
if(entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) world).getServer();
CraftEntity toPassIn = new CraftLivingEntity(server, (EntityLiving) entity);
EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(((WorldServer) world).getWorld().getBlockAt(i, j, k), toPassIn, EntityDamageEvent.DamageCause.CONTACT, 1);
org.bukkit.block.Block damager = ((WorldServer) world).getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = entity.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.CONTACT;
int damageDone = 1;
EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone);
server.getPluginManager().callEvent(edbbe);
if (!edbbe.isCancelled()){
entity.a(((Entity) (null)), edbbe.getDamage());
}
return;
} else {
entity.a(((Entity) (null)), 1);
}
// CraftBukkit end
entity.a(((Entity) (null)), 1);
// CraftBukkit end
}
}

View File

@ -1,15 +1,13 @@
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.entity.CraftPlayer;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
// CraftBukkit end
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
//CraftBukkit end
import java.util.List;
import java.util.Random;
@ -221,9 +219,12 @@ public abstract class Entity {
if (Z % 20 == 0) {
// CraftBukkit start
if(this instanceof EntityLiving) {
CraftServer server = ((WorldServer)l).getServer();
CraftServer server = ((WorldServer) l).getServer();
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.DROWNING;
int damageDone = 1;
EntityDamageEvent ede = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.DROWNING, 1);
EntityDamageEvent ede = new EntityDamageEvent(damagee, damageType, damageDone);
server.getPluginManager().callEvent(ede);
if (!ede.isCancelled()){
@ -254,19 +255,31 @@ public abstract class Entity {
if (!ae) {
// CraftBukkit start
if(this instanceof EntityLiving) {
CraftServer server = ((WorldServer)l).getServer();
CraftServer server = ((WorldServer) l).getServer();
org.bukkit.block.Block damager = null;//((WorldServer) l).getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.LAVA;
int damageDone = 4;
EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(null, this.getBukkitEntity(), EntityDamageEvent.DamageCause.LAVA, 4);
EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone);
server.getPluginManager().callEvent(ede);
if (!ede.isCancelled()){
a(((Entity) (null)), ede.getDamage());
}
EntityCombustEvent ece = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity());
server.getPluginManager().callEvent(ece);
if (!ece.isCancelled()){
if(Z <= 0){
// not on fire yet
Type eventType = Type.ENTITY_COMBUST;
EntityCombustEvent ece = new EntityCombustEvent(eventType, damagee);
server.getPluginManager().callEvent(ece);
if (!ece.isCancelled()){
Z = 600;
}
} else {
// reset fire level back to max
Z = 600;
}
} else {
a(((Entity) (null)), 4);
Z = 600;
@ -473,9 +486,24 @@ public abstract class Entity {
b(1);
if (!flag2) {
Z++;
if (Z == 0) {
//CraftBukkit start
if(Z <= 0){
// not on fire yet
CraftServer server = ((WorldServer) l).getServer();
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
Type eventType = Type.ENTITY_COMBUST;
EntityCombustEvent ece = new EntityCombustEvent(eventType, damagee);
server.getPluginManager().callEvent(ece);
if (!ece.isCancelled()){
Z = 300;
}
} else {
// reset fire level back to max
Z = 300;
}
//CraftBukkit end
}
} else if (Z <= 0) {
Z = -Y;
@ -505,9 +533,12 @@ public abstract class Entity {
if (!ae) {
// CraftBukkit start
if(this instanceof EntityLiving) {
CraftServer server = ((WorldServer)l).getServer();
CraftServer server = ((WorldServer) l).getServer();
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.FIRE;
int damageDone = i1;
EntityDamageEvent ede = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.FIRE, i1);
EntityDamageEvent ede = new EntityDamageEvent(damagee, damageType, damageDone);
server.getPluginManager().callEvent(ede);
if (!ede.isCancelled()){

View File

@ -1,7 +1,9 @@
package net.minecraft.server;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals;
//CraftBukkit end
public abstract class EntityAnimals extends EntityCreature implements IAnimals {

View File

@ -1,12 +1,9 @@
package net.minecraft.server;
import java.util.List;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftArrow;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;

View File

@ -5,7 +5,6 @@ import java.util.Random;
// CraftBukkit start
import org.bukkit.Location;
import org.bukkit.craftbukkit.entity.CraftArrow;
import org.bukkit.craftbukkit.entity.CraftBoat;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.CraftMappable;

View File

@ -2,9 +2,10 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals;
import org.bukkit.craftbukkit.entity.CraftChicken;
//CraftBukkit end
public class EntityChicken extends EntityAnimals {

View File

@ -1,7 +1,9 @@
package net.minecraft.server;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftCow;
//CraftBukkit end
public class EntityCow extends EntityAnimals {

View File

@ -2,8 +2,10 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftCreature;
//CraftBukkit end
public class EntityCreature extends EntityLiving {

View File

@ -2,8 +2,10 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftCreeper;
//CraftBukkit end
public class EntityCreeper extends EntityMobs {

View File

@ -6,11 +6,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;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;

View File

@ -1,7 +1,9 @@
package net.minecraft.server;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftFallingSand;
//CraftBukkit end
public class EntityFallingSand extends Entity {

View File

@ -4,10 +4,7 @@ import java.util.List;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftEgg;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftFireball;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;

View File

@ -4,11 +4,7 @@ import java.util.List;
import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftEgg;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftFireball;
import org.bukkit.craftbukkit.entity.CraftFish;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;

View File

@ -1,7 +1,9 @@
package net.minecraft.server;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftFlying;
//CraftBukkit end
public class EntityFlying extends EntityLiving {

View File

@ -3,9 +3,10 @@ package net.minecraft.server;
import java.util.List;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals;
import org.bukkit.craftbukkit.entity.CraftGhast;
//CraftBukkit end
public class EntityGhast extends EntityFlying implements IMobs {

View File

@ -2,9 +2,10 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals;
import org.bukkit.craftbukkit.entity.CraftItem;
//CraftBukkit end
public class EntityItem extends Entity {

View File

@ -3,9 +3,10 @@ package net.minecraft.server;
import java.util.List;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
//CraftBukkit end
public abstract class EntityLiving extends Entity {

View File

@ -5,7 +5,6 @@ import java.util.Random;
// CraftBukkit start
import org.bukkit.Location;
import org.bukkit.craftbukkit.entity.CraftEgg;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftPoweredMinecart;
import org.bukkit.craftbukkit.entity.CraftStorageMinecart;

View File

@ -3,13 +3,9 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.entity.CraftMinecart;
import org.bukkit.craftbukkit.entity.CraftMonster;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;

View File

@ -2,8 +2,10 @@ package net.minecraft.server;
import java.util.*;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftPainting;
//CraftBukkit end
public class EntityPainting extends Entity {

View File

@ -1,7 +1,9 @@
package net.minecraft.server;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftPig;
//CraftBukkit end
public class EntityPig extends EntityAnimals {

View File

@ -3,8 +3,10 @@ package net.minecraft.server;
import java.util.List;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftPigZombie;
//CraftBukkit end
public class EntityPigZombie extends EntityZombie {

View File

@ -3,12 +3,13 @@ package net.minecraft.server;
import java.util.List;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
// CraftBukkit end
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
//CraftBukkit end
public abstract class EntityPlayer extends EntityLiving {

View File

@ -2,8 +2,10 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSheep;
//CraftBukkit end
public class EntitySheep extends EntityAnimals {

View File

@ -2,6 +2,7 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftSkeleton;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type;

View File

@ -2,9 +2,10 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSkeleton;
import org.bukkit.craftbukkit.entity.CraftSlime;
//CraftBukkit stop
public class EntitySlime extends EntityLiving implements IMobs {

View File

@ -4,8 +4,6 @@ import java.util.List;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSnowball;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;

View File

@ -2,8 +2,10 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSpider;
//CraftBukkit stop
public class EntitySpider extends EntityMobs {

View File

@ -2,8 +2,10 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSquid;
//CraftBukkit stop
public class EntitySquid extends EntityWaterMob {

View File

@ -1,8 +1,9 @@
package net.minecraft.server;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSkeleton;
import org.bukkit.craftbukkit.entity.CraftTNTPrimed;
//CraftBukkit stop
public class EntityTNTPrimed extends Entity {

View File

@ -1,7 +1,9 @@
package net.minecraft.server;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftWaterMob;
//CraftBukkit stop
public class EntityWaterMob extends EntityCreature implements IAnimals {

View File

@ -1,5 +1,6 @@
package net.minecraft.server;
//CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftZombie;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type;

View File

@ -1,7 +1,9 @@
package net.minecraft.server;
//CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftGiant;
//CraftBukkit stop
public class EntityZombieSimple extends EntityMobs {