mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
Adjusted CraftBukkit to work with the entity event convenience patch in Bukkit. Addresses BUKKIT-809
By: TomyLobo <tomylobo@nurfuerspam.de>
This commit is contained in:
parent
0914806835
commit
ade8e8932f
2 changed files with 39 additions and 5 deletions
|
@ -19,7 +19,7 @@ public class CraftCreeper extends CraftMonster implements Creeper {
|
|||
|
||||
public void setPowered(boolean powered) {
|
||||
CraftServer server = this.server;
|
||||
org.bukkit.entity.Entity entity = this.getHandle().getBukkitEntity();
|
||||
Creeper entity = (Creeper) this.getHandle().getBukkitEntity();
|
||||
|
||||
if (powered) {
|
||||
CreeperPowerEvent event = new CreeperPowerEvent(entity, CreeperPowerEvent.PowerCause.SET_ON);
|
||||
|
|
|
@ -35,7 +35,11 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
|
@ -215,7 +219,7 @@ public class CraftEventFactory {
|
|||
org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? (AnimalTamer) tamer.getBukkitEntity() : null);
|
||||
CraftServer craftServer = (CraftServer) bukkitEntity.getServer();
|
||||
|
||||
EntityTameEvent event = new EntityTameEvent(bukkitEntity, bukkitTamer);
|
||||
EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer);
|
||||
craftServer.getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
@ -224,7 +228,7 @@ public class CraftEventFactory {
|
|||
* ItemSpawnEvent
|
||||
*/
|
||||
public static ItemSpawnEvent callItemSpawnEvent(EntityItem entityitem) {
|
||||
org.bukkit.entity.Entity entity = entityitem.getBukkitEntity();
|
||||
org.bukkit.entity.Item entity = (org.bukkit.entity.Item) entityitem.getBukkitEntity();
|
||||
CraftServer craftServer = (CraftServer) entity.getServer();
|
||||
|
||||
ItemSpawnEvent event = new ItemSpawnEvent(entity, entity.getLocation());
|
||||
|
@ -237,7 +241,7 @@ public class CraftEventFactory {
|
|||
* ItemDespawnEvent
|
||||
*/
|
||||
public static ItemDespawnEvent callItemDespawnEvent(EntityItem entityitem) {
|
||||
org.bukkit.entity.Entity entity = entityitem.getBukkitEntity();
|
||||
org.bukkit.entity.Item entity = (org.bukkit.entity.Item) entityitem.getBukkitEntity();
|
||||
|
||||
ItemDespawnEvent event = new ItemDespawnEvent(entity, entity.getLocation());
|
||||
|
||||
|
@ -350,7 +354,7 @@ public class CraftEventFactory {
|
|||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
return target.damageEntity(damagesource, damage);
|
||||
return target.damageEntity(damagesource, event.getDamage());
|
||||
}
|
||||
} else {
|
||||
// Other entities have their events (if any) handled in damageEntity
|
||||
|
@ -373,4 +377,34 @@ public class CraftEventFactory {
|
|||
state.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static FoodLevelChangeEvent callFoodLevelChangeEvent(EntityHuman entity, int level) {
|
||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent((Player) entity.getBukkitEntity(), level);
|
||||
entity.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material) {
|
||||
EntityChangeBlockEvent event = new EntityChangeBlockEvent((LivingEntity) entity, block, material);
|
||||
entity.getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static PigZapEvent callPigZapEvent(Entity pig, Entity lightning, Entity pigzombie) {
|
||||
PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity());
|
||||
pig.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, Block block, Material material) {
|
||||
EntityChangeBlockEvent event = new EntityChangeBlockEvent((LivingEntity) entity.getBukkitEntity(), block, material);
|
||||
entity.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static CreeperPowerEvent callCreeperPowerEvent(Entity creeper, Entity lightning, CreeperPowerEvent.PowerCause cause) {
|
||||
CreeperPowerEvent event = new CreeperPowerEvent((Creeper) creeper.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), cause);
|
||||
creeper.getBukkitEntity().getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue