fixes to combust event so that it is raised only once on combustion.

minor fixes to imports
This commit is contained in:
Andrew Ardill 2011-01-18 16:30:01 +11:00
parent ddc30dd6e3
commit d7d7a68f91
8 changed files with 44 additions and 26 deletions

View file

@ -1,14 +1,12 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start
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.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
// CraftBukkit end // CraftBukkit end
import java.util.List; import java.util.List;
@ -221,9 +219,12 @@ public abstract class Entity {
if (Z % 20 == 0) { if (Z % 20 == 0) {
// CraftBukkit start // CraftBukkit start
if(this instanceof EntityLiving) { 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); server.getPluginManager().callEvent(ede);
if (!ede.isCancelled()){ if (!ede.isCancelled()){
@ -254,19 +255,30 @@ public abstract class Entity {
if (!ae) { if (!ae) {
// CraftBukkit start // CraftBukkit start
if(this instanceof EntityLiving) { 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.LAVA;
int damageDone = 4;
EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(null, this.getBukkitEntity(), EntityDamageEvent.DamageCause.LAVA, 4); EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone);
server.getPluginManager().callEvent(ede); server.getPluginManager().callEvent(ede);
if (!ede.isCancelled()){ if (!ede.isCancelled()){
a(((Entity) (null)), ede.getDamage()); a(((Entity) (null)), ede.getDamage());
} }
EntityCombustEvent ece = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity()); if(Z <= 0){
// not on fire yet
Type eventType = Type.ENTITY_COMBUST;
EntityCombustEvent ece = new EntityCombustEvent(eventType, damagee);
server.getPluginManager().callEvent(ece); server.getPluginManager().callEvent(ece);
if (!ece.isCancelled()){ if (!ece.isCancelled()){
Z = 600; Z = 600;
} }
} else {
// reset fire level back to max
Z = 600;
}
} else { } else {
a(((Entity) (null)), 4); a(((Entity) (null)), 4);
Z = 600; Z = 600;
@ -473,9 +485,24 @@ public abstract class Entity {
b(1); b(1);
if (!flag2) { if (!flag2) {
Z++; 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; Z = 300;
} }
} else {
// reset fire level back to max
Z = 300;
}
//CraftBukkit end
} }
} else if (Z <= 0) { } else if (Z <= 0) {
Z = -Y; Z = -Y;
@ -505,9 +532,12 @@ public abstract class Entity {
if (!ae) { if (!ae) {
// CraftBukkit start // CraftBukkit start
if(this instanceof EntityLiving) { 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); server.getPluginManager().callEvent(ede);
if (!ede.isCancelled()){ if (!ede.isCancelled()){

View file

@ -1,12 +1,9 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random;
//CraftBukkit start //CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftArrow; 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.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;

View file

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

View file

@ -3,11 +3,7 @@ package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random; 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.CraftFireball;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;

View file

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals;
import org.bukkit.craftbukkit.entity.CraftGhast; import org.bukkit.craftbukkit.entity.CraftGhast;
public class EntityGhast extends EntityFlying implements IMobs { public class EntityGhast extends EntityFlying implements IMobs {

View file

@ -3,7 +3,6 @@ package net.minecraft.server;
import java.util.Random; import java.util.Random;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals;
import org.bukkit.craftbukkit.entity.CraftItem; import org.bukkit.craftbukkit.entity.CraftItem;
public class EntityItem extends Entity { public class EntityItem extends Entity {

View file

@ -4,7 +4,6 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals;
import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.entity.CraftLivingEntity;
public abstract class EntityLiving extends Entity { public abstract class EntityLiving extends Entity {

View file

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