diff options
author | EvilSeph <evilseph@unaligned.org> | 2011-06-11 02:00:05 -0400 |
---|---|---|
committer | EvilSeph <evilseph@unaligned.org> | 2011-06-11 02:00:05 -0400 |
commit | 73e34c2fe33fe4eeafe8acdf74b7cf2410d5c1ee (patch) | |
tree | 2d878958df9f3cb6b34cd2e6a5fbdf700b0cf730 /src/main | |
parent | 5b93f5565a1807f6aae771aae935a021409dba29 (diff) | |
download | craftbukkit-73e34c2fe33fe4eeafe8acdf74b7cf2410d5c1ee.tar craftbukkit-73e34c2fe33fe4eeafe8acdf74b7cf2410d5c1ee.tar.gz craftbukkit-73e34c2fe33fe4eeafe8acdf74b7cf2410d5c1ee.tar.lz craftbukkit-73e34c2fe33fe4eeafe8acdf74b7cf2410d5c1ee.tar.xz craftbukkit-73e34c2fe33fe4eeafe8acdf74b7cf2410d5c1ee.zip |
Added ItemSpawnEvent. Thanks myers!
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/net/minecraft/server/World.java | 6 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index c2b79fb9..19fd0a1a 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -18,6 +18,7 @@ import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.SnowFormEvent; import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.ThunderChangeEvent; // CraftBukkit end @@ -817,6 +818,11 @@ public class World implements IBlockAccess { // CraftBukkit start if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) { CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity); + if (event.isCancelled()) { + return false; + } + } else if (entity instanceof EntityItem) { + ItemSpawnEvent event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity); if (event.isCancelled()) { return false; } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index ee2d4dbb..94d13b3c 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -7,6 +7,7 @@ import net.minecraft.server.EntityCreeper; import net.minecraft.server.EntityGhast; import net.minecraft.server.EntityGiantZombie; import net.minecraft.server.EntityHuman; +import net.minecraft.server.EntityItem; import net.minecraft.server.EntityLiving; import net.minecraft.server.EntityMonster; import net.minecraft.server.EntityPig; @@ -40,6 +41,7 @@ import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityTameEvent; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerEvent; @@ -243,4 +245,17 @@ public class CraftEventFactory { craftServer.getPluginManager().callEvent(event); return event; } + + /** + * ItemSpawnEvent + */ + public static ItemSpawnEvent callItemSpawnEvent(EntityItem entityitem) { + org.bukkit.entity.Entity entity = entityitem.getBukkitEntity(); + CraftServer craftServer = (CraftServer) entity.getServer(); + + ItemSpawnEvent event = new ItemSpawnEvent(entity, entity.getLocation()); + + craftServer.getPluginManager().callEvent(event); + return event; + } } |