diff options
Diffstat (limited to 'src')
11 files changed, 59 insertions, 63 deletions
diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java index 69e3ae9c..9ecbaca4 100644 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -1,10 +1,6 @@ package net.minecraft.server; -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.CreeperPowerEvent; -// CraftBukkit end +import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit public class EntityCreeper extends EntityMonster { @@ -115,7 +111,7 @@ public class EntityCreeper extends EntityMonster { // CraftBukkit start 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); if (!event.isCancelled()) { @@ -152,10 +148,7 @@ public class EntityCreeper extends EntityMonster { super.a(entityweatherlighting); // CraftBukkit start - CreeperPowerEvent event = new CreeperPowerEvent(this.getBukkitEntity(), entityweatherlighting.getBukkitEntity(), CreeperPowerEvent.PowerCause.LIGHTNING); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callCreeperPowerEvent(this, entityweatherlighting, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { return; } diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java index 36e73f30..37c70d9d 100644 --- a/src/main/java/net/minecraft/server/EntityEnderDragon.java +++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java @@ -598,7 +598,7 @@ public class EntityEnderDragon extends EntityComplex { byte b0 = 4; // 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()); for (int l = k - 1; l <= k + 32; ++l) { diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java index 7317466e..7e430803 100644 --- a/src/main/java/net/minecraft/server/EntityEnderman.java +++ b/src/main/java/net/minecraft/server/EntityEnderman.java @@ -6,7 +6,6 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.event.entity.EntityTeleportEvent; -import org.bukkit.event.entity.EntityChangeBlockEvent; // CraftBukkit end public class EntityEnderman extends EntityMonster { @@ -107,10 +106,7 @@ public class EntityEnderman extends EntityMonster { l = this.world.getTypeId(i, j, k); if (b[l]) { // CraftBukkit start - pickup event - EntityChangeBlockEvent event = new EntityChangeBlockEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { + if (!CraftEventFactory.callEntityChangeBlockEvent(this, this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR).isCancelled()) { this.setCarriedId(this.world.getTypeId(i, j, k)); this.setCarriedData(this.world.getData(i, j, k)); this.world.setTypeId(i, j, k, 0); @@ -129,10 +125,7 @@ public class EntityEnderman extends EntityMonster { // CraftBukkit start - place event org.bukkit.block.Block bblock = this.world.getWorld().getBlockAt(i, j, k); - EntityChangeBlockEvent event = new EntityChangeBlockEvent(this.getBukkitEntity(), bblock, bblock.getType()); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { + if (!CraftEventFactory.callEntityChangeBlockEvent(this, bblock, bblock.getType()).isCancelled()) { this.world.setTypeIdAndData(i, j, k, this.getCarriedId(), this.getCarriedData()); this.setCarriedId(0); } diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java index 75d94a4b..bf1f9669 100644 --- a/src/main/java/net/minecraft/server/EntityPig.java +++ b/src/main/java/net/minecraft/server/EntityPig.java @@ -1,10 +1,5 @@ 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 EntityPig(World world) { @@ -76,17 +71,14 @@ public class EntityPig extends EntityAnimal { EntityPigZombie entitypigzombie = new EntityPigZombie(this.world); // CraftBukkit start - PigZapEvent event = new PigZapEvent(this.getBukkitEntity(), entityweatherlighting.getBukkitEntity(), entitypigzombie.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callPigZapEvent(this, entityweatherlighting, entitypigzombie).isCancelled()) { return; } // CraftBukkit end entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); // 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(); } } diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java index 28ac8070..77e9092a 100644 --- a/src/main/java/net/minecraft/server/EntitySheep.java +++ b/src/main/java/net/minecraft/server/EntitySheep.java @@ -5,7 +5,7 @@ import java.util.Random; // CraftBukkit start import org.bukkit.Material; import org.bukkit.craftbukkit.event.CraftEventFactory; -import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.entity.Sheep; // CraftBukkit end 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) { // CraftBukkit start - org.bukkit.World bworld = this.world.getWorld(); - 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()) { + if (!CraftEventFactory.callEntityChangeBlockEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j, k), Material.AIR).isCancelled()) { this.world.f(2001, i, j, k, Block.LONG_GRASS.id + 256); this.world.setTypeId(i, j, k, 0); flag = true; @@ -93,13 +87,7 @@ public class EntitySheep extends EntityAnimal { // CraftBukkit end } else if (this.world.getTypeId(i, j - 1, k) == Block.GRASS.id) { // CraftBukkit start - org.bukkit.World bworld = this.world.getWorld(); - 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()) { + if (!CraftEventFactory.callEntityChangeBlockEvent(this.getBukkitEntity(), this.world.getWorld().getBlockAt(i, j - 1, k), Material.DIRT).isCancelled()) { this.world.f(2001, i, j - 1, k, Block.GRASS.id); this.world.setTypeId(i, j - 1, k, Block.DIRT.id); flag = true; @@ -110,7 +98,7 @@ public class EntitySheep extends EntityAnimal { if (flag) { // CraftBukkit start 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); if (!event.isCancelled()) { diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java index bd14719c..3f2ea7f5 100644 --- a/src/main/java/net/minecraft/server/EntitySlime.java +++ b/src/main/java/net/minecraft/server/EntitySlime.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import org.bukkit.entity.Slime; + public class EntitySlime extends EntityLiving implements IMonster { public float a; @@ -139,7 +141,7 @@ public class EntitySlime extends EntityLiving implements IMonster { int j = 2 + this.random.nextInt(3); // 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); if (!event.isCancelled() && event.getCount() > 0) { diff --git a/src/main/java/net/minecraft/server/FoodMetaData.java b/src/main/java/net/minecraft/server/FoodMetaData.java index e6f5c2f0..66bb10b3 100644 --- a/src/main/java/net/minecraft/server/FoodMetaData.java +++ b/src/main/java/net/minecraft/server/FoodMetaData.java @@ -1,9 +1,6 @@ package net.minecraft.server; -// CraftBukkit start -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.FoodLevelChangeEvent; -// CraftBukkit end +import org.bukkit.event.entity.EntityDamageEvent; // CraftBukkit public class FoodMetaData { @@ -36,8 +33,7 @@ public class FoodMetaData { this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); } else if (i > 0) { // CraftBukkit start - FoodLevelChangeEvent event = new FoodLevelChangeEvent(entityhuman.getBukkitEntity(), Math.max(this.foodLevel - 1, 0)); - entityhuman.world.getServer().getPluginManager().callEvent(event); + org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, Math.min(this.foodLevel - 1, 0)); if (!event.isCancelled()) { this.foodLevel = event.getFoodLevel(); diff --git a/src/main/java/net/minecraft/server/ItemDye.java b/src/main/java/net/minecraft/server/ItemDye.java index 1bb284b6..53cb505e 100644 --- a/src/main/java/net/minecraft/server/ItemDye.java +++ b/src/main/java/net/minecraft/server/ItemDye.java @@ -1,6 +1,7 @@ package net.minecraft.server; import org.bukkit.entity.Player; // CraftBukkit +import org.bukkit.entity.Sheep; public class ItemDye extends Item { @@ -115,7 +116,7 @@ public class ItemDye extends Item { if (!entitysheep.isSheared() && entitysheep.getColor() != i) { // CraftBukkit start 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); if (event.isCancelled()) { diff --git a/src/main/java/net/minecraft/server/ItemFood.java b/src/main/java/net/minecraft/server/ItemFood.java index f870e814..43990a9a 100644 --- a/src/main/java/net/minecraft/server/ItemFood.java +++ b/src/main/java/net/minecraft/server/ItemFood.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import org.bukkit.event.entity.FoodLevelChangeEvent; // CraftBukkit - public class ItemFood extends Item { public final int a; @@ -31,8 +29,7 @@ public class ItemFood extends Item { // CraftBukkit start int oldFoodLevel = entityhuman.getFoodData().foodLevel; - FoodLevelChangeEvent event = new FoodLevelChangeEvent(entityhuman.getBukkitEntity(), Math.min(this.getNutrition() + entityhuman.getFoodData().foodLevel, 20)); - entityhuman.world.getServer().getPluginManager().callEvent(event); + org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, Math.min(this.getNutrition() + oldFoodLevel, 20)); if (!event.isCancelled()) { entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, this.getSaturationModifier()); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java index 354e1380..ed771a5b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java @@ -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); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 767499c6..80f4e3db 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -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; + } } |