diff options
author | Rigby <rigby@onarandombox.com> | 2011-09-21 16:32:37 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-09-21 16:55:27 +0100 |
commit | 1da2d1f5b619706ae64f317fe9a822e4ab9efeaf (patch) | |
tree | 01762edffc14b8a803753f002d3747bebecae787 /src | |
parent | 59908c43c99ffc85d60e44dfab56212126a6bcd3 (diff) | |
download | craftbukkit-1da2d1f5b619706ae64f317fe9a822e4ab9efeaf.tar craftbukkit-1da2d1f5b619706ae64f317fe9a822e4ab9efeaf.tar.gz craftbukkit-1da2d1f5b619706ae64f317fe9a822e4ab9efeaf.tar.lz craftbukkit-1da2d1f5b619706ae64f317fe9a822e4ab9efeaf.tar.xz craftbukkit-1da2d1f5b619706ae64f317fe9a822e4ab9efeaf.zip |
Implements the ability to customise and remove Player death messages.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityPlayer.java | 7 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 799aae64..3c944a9b 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -12,6 +12,7 @@ import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.PlayerDeathEvent; // CraftBukkit end public class EntityPlayer extends EntityHuman implements ICrafting { @@ -139,7 +140,6 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public void die(DamageSource damagesource) { - this.b.serverConfigurationManager.sendAll(new Packet3Chat(damagesource.a(this))); // CraftBukkit start java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); @@ -155,7 +155,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - CraftEventFactory.callPlayerDeathEvent(this, loot); + PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, damagesource.a(this)); + if (!"".equals(event.getDeathMessage())) { + this.b.serverConfigurationManager.sendAll(new Packet3Chat(event.getDeathMessage())); + } // CraftBukkit - we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. for (int i = 0; i < this.inventory.items.length; ++i) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 0082526c..f86dded7 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -293,9 +293,9 @@ public class CraftEventFactory { return event; } - public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops) { + public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) { CraftPlayer entity = (CraftPlayer)victim.getBukkitEntity(); - PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0); + PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage); org.bukkit.World world = entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); |