3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00

[Bleeding] Deprecate Enderman events in favor of EntityChangeBlock

Dieser Commit ist enthalten in:
Aidan Matzko 2012-02-04 12:40:52 -05:00 committet von EvilSeph
Ursprung 10ab7b96ed
Commit 6dda89d873

Datei anzeigen

@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.entity.EndermanPickupEvent; import org.bukkit.event.entity.EndermanPickupEvent;
import org.bukkit.event.entity.EndermanPlaceEvent; import org.bukkit.event.entity.EndermanPlaceEvent;
import org.bukkit.event.entity.EntityTeleportEvent; import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
// CraftBukkit end // CraftBukkit end
public class EntityEnderman extends EntityMonster { public class EntityEnderman extends EntityMonster {
@ -108,9 +109,14 @@ public class EntityEnderman extends EntityMonster {
l = this.world.getTypeId(i, j, k); l = this.world.getTypeId(i, j, k);
if (b[l]) { if (b[l]) {
// CraftBukkit start - pickup event // CraftBukkit start - pickup event
// TODO: We still call the old event
EndermanPickupEvent pickup = new EndermanPickupEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j, k)); EndermanPickupEvent pickup = new EndermanPickupEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j, k));
this.world.getServer().getPluginManager().callEvent(pickup); this.world.getServer().getPluginManager().callEvent(pickup);
if (!pickup.isCancelled()) {
EntityChangeBlockEvent event = new EntityChangeBlockEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR);
this.world.getServer().getPluginManager().callEvent(event);
if (!pickup.isCancelled() && !event.isCancelled()) {
this.setCarriedId(this.world.getTypeId(i, j, k)); this.setCarriedId(this.world.getTypeId(i, j, k));
this.setCarriedData(this.world.getData(i, j, k)); this.setCarriedData(this.world.getData(i, j, k));
this.world.setTypeId(i, j, k, 0); this.world.setTypeId(i, j, k, 0);
@ -127,9 +133,14 @@ public class EntityEnderman extends EntityMonster {
if (l == 0 && i1 > 0 && Block.byId[i1].b()) { if (l == 0 && i1 > 0 && Block.byId[i1].b()) {
// CraftBukkit start - place event // CraftBukkit start - place event
// TODO: We still call the old event
EndermanPlaceEvent place = new EndermanPlaceEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), i, j, k)); EndermanPlaceEvent place = new EndermanPlaceEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), i, j, k));
this.world.getServer().getPluginManager().callEvent(place); this.world.getServer().getPluginManager().callEvent(place);
if (!place.isCancelled()) {
EntityChangeBlockEvent event = new EntityChangeBlockEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR);
this.world.getServer().getPluginManager().callEvent(event);
if (!place.isCancelled() && !event.isCancelled()) {
this.world.setTypeIdAndData(i, j, k, this.getCarriedId(), this.getCarriedData()); this.world.setTypeIdAndData(i, j, k, this.getCarriedId(), this.getCarriedData());
this.setCarriedId(0); this.setCarriedId(0);
} }