Implementation of reworked EntityCombustEvents
Also includes some extra comments, and a refactoring of the PaintingBreakByEntity event that is raised when lighting strikes a painting.
Dieser Commit ist enthalten in:
Ursprung
0c88f05c0d
Commit
3da00ee41a
@ -8,7 +8,11 @@ import java.util.UUID;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Painting;
|
||||||
import org.bukkit.entity.Vehicle;
|
import org.bukkit.entity.Vehicle;
|
||||||
|
import org.bukkit.event.entity.EntityCombustByBlockEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
|
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
@ -16,6 +20,7 @@ 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.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public abstract class Entity {
|
public abstract class Entity {
|
||||||
@ -300,7 +305,7 @@ public abstract class Entity {
|
|||||||
|
|
||||||
protected void av() {
|
protected void av() {
|
||||||
if (!this.fireProof) {
|
if (!this.fireProof) {
|
||||||
// CraftBukkit start - TODO: this event spams!
|
// CraftBukkit start - fallen in lava TODO: this event spams!
|
||||||
if (this instanceof EntityLiving) {
|
if (this instanceof EntityLiving) {
|
||||||
org.bukkit.Server server = this.world.getServer();
|
org.bukkit.Server server = this.world.getServer();
|
||||||
|
|
||||||
@ -317,18 +322,19 @@ public abstract class Entity {
|
|||||||
|
|
||||||
if (this.fireTicks <= 0) {
|
if (this.fireTicks <= 0) {
|
||||||
// not on fire yet
|
// not on fire yet
|
||||||
EntityCombustEvent combustEvent = new EntityCombustEvent(damagee);
|
EntityCombustEvent combustEvent = new EntityCombustByBlockEvent(damager, damagee, 15);
|
||||||
server.getPluginManager().callEvent(combustEvent);
|
server.getPluginManager().callEvent(combustEvent);
|
||||||
|
|
||||||
if (!combustEvent.isCancelled()) {
|
if (!combustEvent.isCancelled()) {
|
||||||
this.j(15);
|
this.j(combustEvent.getDuration());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// This will be called every single tick the entity is in lava, so don't throw an event.
|
||||||
this.j(15);
|
this.j(15);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
|
||||||
|
|
||||||
this.damageEntity(DamageSource.LAVA, 4);
|
this.damageEntity(DamageSource.LAVA, 4);
|
||||||
this.j(15);
|
this.j(15);
|
||||||
@ -620,12 +626,12 @@ public abstract class Entity {
|
|||||||
if (!flag2) {
|
if (!flag2) {
|
||||||
++this.fireTicks;
|
++this.fireTicks;
|
||||||
// CraftBukkit start - not on fire yet
|
// CraftBukkit start - not on fire yet
|
||||||
if (this.fireTicks <= 0) {
|
if (this.fireTicks <= 0) { // only throw events on the first combust, otherwise it spams
|
||||||
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity());
|
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
this.j(8);
|
this.j(event.getDuration());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -1299,8 +1305,21 @@ public abstract class Entity {
|
|||||||
|
|
||||||
public void a(EntityWeatherStorm entityweatherstorm) {
|
public void a(EntityWeatherStorm entityweatherstorm) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(entityweatherstorm.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.LIGHTNING, 5);
|
final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
final org.bukkit.entity.Entity stormBukkitEntity = entityweatherstorm.getBukkitEntity();
|
||||||
|
final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
|
if (thisBukkitEntity instanceof Painting) {
|
||||||
|
PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity);
|
||||||
|
pluginManager.callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(stormBukkitEntity, thisBukkitEntity, EntityDamageEvent.DamageCause.LIGHTNING, 5);
|
||||||
|
pluginManager.callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
@ -1311,7 +1330,13 @@ public abstract class Entity {
|
|||||||
|
|
||||||
++this.fireTicks;
|
++this.fireTicks;
|
||||||
if (this.fireTicks == 0) {
|
if (this.fireTicks == 0) {
|
||||||
this.j(8);
|
// CraftBukkit start - raise a combust event when lightning strikes
|
||||||
|
EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
|
||||||
|
pluginManager.callEvent(entityCombustEvent);
|
||||||
|
if (!entityCombustEvent.isCancelled()) {
|
||||||
|
this.j(entityCombustEvent.getDuration());
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.entity.CraftItem;
|
|||||||
import org.bukkit.craftbukkit.TrigMath;
|
import org.bukkit.craftbukkit.TrigMath;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
@ -838,7 +839,12 @@ public abstract class EntityHuman extends EntityLiving {
|
|||||||
int l = EnchantmentManager.c(this.inventory, (EntityLiving) entity);
|
int l = EnchantmentManager.c(this.inventory, (EntityLiving) entity);
|
||||||
|
|
||||||
if (l > 0) {
|
if (l > 0) {
|
||||||
entity.j(l * 4);
|
// CraftBukkit start - raise a combust event when somebody hits with a fire enchanted item
|
||||||
|
EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), l*4);
|
||||||
|
if (!combustEvent.isCancelled()) {
|
||||||
|
entity.j(combustEvent.getDuration());
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,25 +245,6 @@ public class EntityPainting extends Entity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit start - copy of a method in Entity except for the CraftBukkit-specific code
|
|
||||||
// TODO: Better way?
|
|
||||||
public void a(EntityWeatherStorm entityweatherstorm) {
|
|
||||||
// CraftBukkit start
|
|
||||||
PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), entityweatherstorm.getBukkitEntity());
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
++this.fireTicks;
|
|
||||||
if (this.fireTicks == 0) {
|
|
||||||
this.j(8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
nbttagcompound.a("Dir", (byte) this.a);
|
nbttagcompound.a("Dir", (byte) this.a);
|
||||||
nbttagcompound.setString("Motive", this.e.A);
|
nbttagcompound.setString("Motive", this.e.A);
|
||||||
|
@ -53,11 +53,11 @@ public class EntitySkeleton extends EntityMonster {
|
|||||||
|
|
||||||
if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
|
if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity());
|
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
this.j(8);
|
this.j(event.getDuration());
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@ public class EntityZombie extends EntityMonster {
|
|||||||
|
|
||||||
if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
|
if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity());
|
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
this.j(8);
|
this.j(event.getDuration());
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren