mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-28 05:25:42 +01:00
Adjusted CraftBukkit to work with the entity event convenience patch in Bukkit. Addresses BUKKIT-809
This commit is contained in:
parent
dcf016822d
commit
92dfb2500b
@ -1,10 +1,6 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
// CraftBukkit start
|
import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
|
||||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
||||||
import org.bukkit.event.entity.CreeperPowerEvent;
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
public class EntityCreeper extends EntityMonster {
|
public class EntityCreeper extends EntityMonster {
|
||||||
|
|
||||||
@ -115,7 +111,7 @@ public class EntityCreeper extends EntityMonster {
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
float radius = this.isPowered() ? 6.0F : 3.0F;
|
float radius = this.isPowered() ? 6.0F : 3.0F;
|
||||||
|
|
||||||
ExplosionPrimeEvent event = new ExplosionPrimeEvent(CraftEntity.getEntity(this.world.getServer(), this), radius, false);
|
ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), radius, false);
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
@ -152,10 +148,7 @@ public class EntityCreeper extends EntityMonster {
|
|||||||
super.a(entityweatherlighting);
|
super.a(entityweatherlighting);
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
CreeperPowerEvent event = new CreeperPowerEvent(this.getBukkitEntity(), entityweatherlighting.getBukkitEntity(), CreeperPowerEvent.PowerCause.LIGHTNING);
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callCreeperPowerEvent(this, entityweatherlighting, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ public class EntityEnderDragon extends EntityComplex {
|
|||||||
byte b0 = 4;
|
byte b0 = 4;
|
||||||
|
|
||||||
// CraftBukkit start - Replace any "this.world" in the following with just "world"!
|
// CraftBukkit start - Replace any "this.world" in the following with just "world"!
|
||||||
EntityCreatePortalEvent event = new EntityCreatePortalEvent(this.getBukkitEntity(), new ArrayList<BlockState>(), PortalType.ENDER);
|
EntityCreatePortalEvent event = new EntityCreatePortalEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), new ArrayList<BlockState>(), PortalType.ENDER);
|
||||||
BlockStateListPopulator world = new BlockStateListPopulator(this.world.getWorld(), event.getBlocks());
|
BlockStateListPopulator world = new BlockStateListPopulator(this.world.getWorld(), event.getBlocks());
|
||||||
|
|
||||||
for (int l = k - 1; l <= k + 32; ++l) {
|
for (int l = k - 1; l <= k + 32; ++l) {
|
||||||
|
@ -6,7 +6,6 @@ import java.util.List;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
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 {
|
||||||
@ -107,10 +106,7 @@ 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
|
||||||
EntityChangeBlockEvent event = new EntityChangeBlockEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR);
|
if (!CraftEventFactory.callEntityChangeBlockEvent(this, this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR).isCancelled()) {
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (!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);
|
||||||
@ -129,10 +125,7 @@ public class EntityEnderman extends EntityMonster {
|
|||||||
// CraftBukkit start - place event
|
// CraftBukkit start - place event
|
||||||
org.bukkit.block.Block bblock = this.world.getWorld().getBlockAt(i, j, k);
|
org.bukkit.block.Block bblock = this.world.getWorld().getBlockAt(i, j, k);
|
||||||
|
|
||||||
EntityChangeBlockEvent event = new EntityChangeBlockEvent(this.getBukkitEntity(), bblock, bblock.getType());
|
if (!CraftEventFactory.callEntityChangeBlockEvent(this, bblock, bblock.getType()).isCancelled()) {
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (!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);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
// CraftBukkit start
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
||||||
import org.bukkit.event.entity.PigZapEvent;
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
public class EntityPig extends EntityAnimal {
|
public class EntityPig extends EntityAnimal {
|
||||||
|
|
||||||
public EntityPig(World world) {
|
public EntityPig(World world) {
|
||||||
@ -76,17 +71,14 @@ public class EntityPig extends EntityAnimal {
|
|||||||
EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
|
EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
PigZapEvent event = new PigZapEvent(this.getBukkitEntity(), entityweatherlighting.getBukkitEntity(), entitypigzombie.getBukkitEntity());
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callPigZapEvent(this, entityweatherlighting, entitypigzombie).isCancelled()) {
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
|
entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
|
||||||
// CraftBukkit - added a reason for spawning this creature
|
// CraftBukkit - added a reason for spawning this creature
|
||||||
this.world.addEntity(entitypigzombie, SpawnReason.LIGHTNING);
|
this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||||
this.die();
|
this.die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import java.util.Random;
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.entity.Sheep;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntitySheep extends EntityAnimal {
|
public class EntitySheep extends EntityAnimal {
|
||||||
@ -79,13 +79,7 @@ public class EntitySheep extends EntityAnimal {
|
|||||||
|
|
||||||
if (this.world.getTypeId(i, j, k) == Block.LONG_GRASS.id) {
|
if (this.world.getTypeId(i, j, k) == Block.LONG_GRASS.id) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
org.bukkit.World bworld = this.world.getWorld();
|
if (!CraftEventFactory.callEntityChangeBlockEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j, k), Material.AIR).isCancelled()) {
|
||||||
org.bukkit.block.Block bblock = bworld.getBlockAt(i, j, k);
|
|
||||||
|
|
||||||
EntityChangeBlockEvent event = new EntityChangeBlockEvent(this.getBukkitEntity(), bblock, Material.AIR);
|
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
this.world.f(2001, i, j, k, Block.LONG_GRASS.id + 256);
|
this.world.f(2001, i, j, k, Block.LONG_GRASS.id + 256);
|
||||||
this.world.setTypeId(i, j, k, 0);
|
this.world.setTypeId(i, j, k, 0);
|
||||||
flag = true;
|
flag = true;
|
||||||
@ -93,13 +87,7 @@ public class EntitySheep extends EntityAnimal {
|
|||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
} else if (this.world.getTypeId(i, j - 1, k) == Block.GRASS.id) {
|
} else if (this.world.getTypeId(i, j - 1, k) == Block.GRASS.id) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
org.bukkit.World bworld = this.world.getWorld();
|
if (!CraftEventFactory.callEntityChangeBlockEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j - 1, k), Material.DIRT).isCancelled()) {
|
||||||
org.bukkit.block.Block bblock = bworld.getBlockAt(i, j - 1, k);
|
|
||||||
|
|
||||||
EntityChangeBlockEvent event = new EntityChangeBlockEvent(this.getBukkitEntity(), bblock, Material.DIRT);
|
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
this.world.f(2001, i, j - 1, k, Block.GRASS.id);
|
this.world.f(2001, i, j - 1, k, Block.GRASS.id);
|
||||||
this.world.setTypeId(i, j - 1, k, Block.DIRT.id);
|
this.world.setTypeId(i, j - 1, k, Block.DIRT.id);
|
||||||
flag = true;
|
flag = true;
|
||||||
@ -110,7 +98,7 @@ public class EntitySheep extends EntityAnimal {
|
|||||||
if (flag) {
|
if (flag) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
if (!this.isBaby()) {
|
if (!this.isBaby()) {
|
||||||
org.bukkit.event.entity.SheepRegrowWoolEvent event = new org.bukkit.event.entity.SheepRegrowWoolEvent(this.getBukkitEntity());
|
org.bukkit.event.entity.SheepRegrowWoolEvent event = new org.bukkit.event.entity.SheepRegrowWoolEvent((Sheep) this.getBukkitEntity());
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
|
||||||
public class EntitySlime extends EntityLiving implements IMonster {
|
public class EntitySlime extends EntityLiving implements IMonster {
|
||||||
|
|
||||||
public float a;
|
public float a;
|
||||||
@ -139,7 +141,7 @@ public class EntitySlime extends EntityLiving implements IMonster {
|
|||||||
int j = 2 + this.random.nextInt(3);
|
int j = 2 + this.random.nextInt(3);
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
org.bukkit.event.entity.SlimeSplitEvent event = new org.bukkit.event.entity.SlimeSplitEvent(this.getBukkitEntity(), j);
|
org.bukkit.event.entity.SlimeSplitEvent event = new org.bukkit.event.entity.SlimeSplitEvent((Slime) this.getBukkitEntity(), j);
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled() && event.getCount() > 0) {
|
if (!event.isCancelled() && event.getCount() > 0) {
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
// CraftBukkit start
|
import org.bukkit.event.entity.EntityDamageEvent; // CraftBukkit
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
public class FoodMetaData {
|
public class FoodMetaData {
|
||||||
|
|
||||||
@ -36,8 +33,7 @@ public class FoodMetaData {
|
|||||||
this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F);
|
this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F);
|
||||||
} else if (i > 0) {
|
} else if (i > 0) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(entityhuman.getBukkitEntity(), Math.max(this.foodLevel - 1, 0));
|
org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, Math.min(this.foodLevel - 1, 0));
|
||||||
entityhuman.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
this.foodLevel = event.getFoodLevel();
|
this.foodLevel = event.getFoodLevel();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
import org.bukkit.entity.Player; // CraftBukkit
|
import org.bukkit.entity.Player; // CraftBukkit
|
||||||
|
import org.bukkit.entity.Sheep;
|
||||||
|
|
||||||
public class ItemDye extends Item {
|
public class ItemDye extends Item {
|
||||||
|
|
||||||
@ -115,7 +116,7 @@ public class ItemDye extends Item {
|
|||||||
if (!entitysheep.isSheared() && entitysheep.getColor() != i) {
|
if (!entitysheep.isSheared() && entitysheep.getColor() != i) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
byte bColor = new Integer(i).byteValue();
|
byte bColor = new Integer(i).byteValue();
|
||||||
org.bukkit.event.entity.SheepDyeWoolEvent event = new org.bukkit.event.entity.SheepDyeWoolEvent(entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByData(bColor));
|
org.bukkit.event.entity.SheepDyeWoolEvent event = new org.bukkit.event.entity.SheepDyeWoolEvent((Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByData(bColor));
|
||||||
entitysheep.world.getServer().getPluginManager().callEvent(event);
|
entitysheep.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent; // CraftBukkit
|
|
||||||
|
|
||||||
public class ItemFood extends Item {
|
public class ItemFood extends Item {
|
||||||
|
|
||||||
public final int a;
|
public final int a;
|
||||||
@ -31,8 +29,7 @@ public class ItemFood extends Item {
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
int oldFoodLevel = entityhuman.getFoodData().foodLevel;
|
int oldFoodLevel = entityhuman.getFoodData().foodLevel;
|
||||||
|
|
||||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(entityhuman.getBukkitEntity(), Math.min(this.getNutrition() + entityhuman.getFoodData().foodLevel, 20));
|
org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, Math.min(this.getNutrition() + oldFoodLevel, 20));
|
||||||
entityhuman.world.getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, this.getSaturationModifier());
|
entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, this.getSaturationModifier());
|
||||||
|
@ -19,7 +19,7 @@ public class CraftCreeper extends CraftMonster implements Creeper {
|
|||||||
|
|
||||||
public void setPowered(boolean powered) {
|
public void setPowered(boolean powered) {
|
||||||
CraftServer server = this.server;
|
CraftServer server = this.server;
|
||||||
org.bukkit.entity.Entity entity = this.getHandle().getBukkitEntity();
|
Creeper entity = (Creeper) this.getHandle().getBukkitEntity();
|
||||||
|
|
||||||
if (powered) {
|
if (powered) {
|
||||||
CreeperPowerEvent event = new CreeperPowerEvent(entity, CreeperPowerEvent.PowerCause.SET_ON);
|
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.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.AnimalTamer;
|
import org.bukkit.entity.AnimalTamer;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.Creeper;
|
||||||
|
import org.bukkit.entity.LightningStrike;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Pig;
|
||||||
|
import org.bukkit.entity.PigZombie;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.ThrownPotion;
|
import org.bukkit.entity.ThrownPotion;
|
||||||
@ -215,7 +219,7 @@ public class CraftEventFactory {
|
|||||||
org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? (AnimalTamer) tamer.getBukkitEntity() : null);
|
org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? (AnimalTamer) tamer.getBukkitEntity() : null);
|
||||||
CraftServer craftServer = (CraftServer) bukkitEntity.getServer();
|
CraftServer craftServer = (CraftServer) bukkitEntity.getServer();
|
||||||
|
|
||||||
EntityTameEvent event = new EntityTameEvent(bukkitEntity, bukkitTamer);
|
EntityTameEvent event = new EntityTameEvent((LivingEntity) bukkitEntity, bukkitTamer);
|
||||||
craftServer.getPluginManager().callEvent(event);
|
craftServer.getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
@ -224,7 +228,7 @@ public class CraftEventFactory {
|
|||||||
* ItemSpawnEvent
|
* ItemSpawnEvent
|
||||||
*/
|
*/
|
||||||
public static ItemSpawnEvent callItemSpawnEvent(EntityItem entityitem) {
|
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();
|
CraftServer craftServer = (CraftServer) entity.getServer();
|
||||||
|
|
||||||
ItemSpawnEvent event = new ItemSpawnEvent(entity, entity.getLocation());
|
ItemSpawnEvent event = new ItemSpawnEvent(entity, entity.getLocation());
|
||||||
@ -237,7 +241,7 @@ public class CraftEventFactory {
|
|||||||
* ItemDespawnEvent
|
* ItemDespawnEvent
|
||||||
*/
|
*/
|
||||||
public static ItemDespawnEvent callItemDespawnEvent(EntityItem entityitem) {
|
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());
|
ItemDespawnEvent event = new ItemDespawnEvent(entity, entity.getLocation());
|
||||||
|
|
||||||
@ -350,7 +354,7 @@ public class CraftEventFactory {
|
|||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
return target.damageEntity(damagesource, damage);
|
return target.damageEntity(damagesource, event.getDamage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Other entities have their events (if any) handled in damageEntity
|
// Other entities have their events (if any) handled in damageEntity
|
||||||
@ -373,4 +377,34 @@ public class CraftEventFactory {
|
|||||||
state.update(true);
|
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 New Issue
Block a user