summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2011-09-21 15:41:24 +0100
committerDinnerbone <dinnerbone@dinnerbone.com>2011-09-21 15:41:24 +0100
commit20ddc944bb38b96ac5deb742126c53b9989b5c31 (patch)
treecf8cef5a55f609417a756d34a7b09034d48b69e9 /src/main/java/org
parent751ab82be07aec65151d7a0a76b90d8fc12974f6 (diff)
downloadcraftbukkit-20ddc944bb38b96ac5deb742126c53b9989b5c31.tar
craftbukkit-20ddc944bb38b96ac5deb742126c53b9989b5c31.tar.gz
craftbukkit-20ddc944bb38b96ac5deb742126c53b9989b5c31.tar.lz
craftbukkit-20ddc944bb38b96ac5deb742126c53b9989b5c31.tar.xz
craftbukkit-20ddc944bb38b96ac5deb742126c53b9989b5c31.zip
Refactored a bunch of death code into the event factory
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 81d063cc..0082526c 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.event;
+import java.util.List;
import net.minecraft.server.ChunkCoordinates;
import net.minecraft.server.EntityCaveSpider;
import net.minecraft.server.EntityChicken;
@@ -14,6 +15,7 @@ import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityMonster;
import net.minecraft.server.EntityPig;
import net.minecraft.server.EntityPigZombie;
+import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntitySheep;
import net.minecraft.server.EntitySilverfish;
import net.minecraft.server.EntitySkeleton;
@@ -35,6 +37,8 @@ import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.CreatureType;
@@ -273,4 +277,35 @@ public class CraftEventFactory {
Bukkit.getPluginManager().callEvent(event);
return event;
}
+
+ public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) {
+ CraftLivingEntity entity = (CraftLivingEntity)victim.getBukkitEntity();
+ EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());
+ org.bukkit.World world = entity.getWorld();
+ Bukkit.getServer().getPluginManager().callEvent(event);
+
+ victim.expToDrop = event.getDroppedExp();
+
+ for (org.bukkit.inventory.ItemStack stack: event.getDrops()) {
+ world.dropItemNaturally(entity.getLocation(), stack);
+ }
+
+ return event;
+ }
+
+ public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops) {
+ CraftPlayer entity = (CraftPlayer)victim.getBukkitEntity();
+ PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0);
+ org.bukkit.World world = entity.getWorld();
+ Bukkit.getServer().getPluginManager().callEvent(event);
+
+ victim.expToDrop = event.getDroppedExp();
+ victim.newExp = event.getNewExp();
+
+ for (org.bukkit.inventory.ItemStack stack: event.getDrops()) {
+ world.dropItemNaturally(entity.getLocation(), stack);
+ }
+
+ return event;
+ }
}