diff options
author | feildmaster <admin@feildmaster.com> | 2012-04-14 00:24:51 -0500 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2012-04-14 00:30:39 -0500 |
commit | 1dcb39074d42e73ebb50127ee7b97705340b0dc7 (patch) | |
tree | e8270bbc62ce2d7dd1435fb15456a61165d19e69 /src | |
parent | e8b6eb717a4807f7ff82de7fd492bc0da2d67a80 (diff) | |
download | craftbukkit-1dcb39074d42e73ebb50127ee7b97705340b0dc7.tar craftbukkit-1dcb39074d42e73ebb50127ee7b97705340b0dc7.tar.gz craftbukkit-1dcb39074d42e73ebb50127ee7b97705340b0dc7.tar.lz craftbukkit-1dcb39074d42e73ebb50127ee7b97705340b0dc7.tar.xz craftbukkit-1dcb39074d42e73ebb50127ee7b97705340b0dc7.zip |
Persist PlayerDeathEvent values. Fixes BUKKIT-1521
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 15 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 4 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index c6410726..1a605880 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -687,6 +687,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { firstPlayed = data.getLong("firstPlayed"); lastPlayed = data.getLong("lastPlayed"); } + + if (data.hasKey("newExp")) { + EntityPlayer handle = getHandle(); + handle.newExp = data.getInt("newExp"); + handle.newTotalExp = data.getInt("newTotalExp"); + handle.newLevel = data.getInt("newLevel"); + handle.expToDrop = data.getInt("expToDrop"); + handle.keepLevel = data.getBoolean("keepLevel"); + } } } @@ -696,6 +705,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } NBTTagCompound data = nbttagcompound.getCompound("bukkit"); + EntityPlayer handle = getHandle(); + data.setInt("newExp", handle.newExp); + data.setInt("newTotalExp", handle.newTotalExp); + data.setInt("newLevel", handle.newLevel); + data.setInt("expToDrop", handle.expToDrop); + data.setBoolean("keepLevel", handle.keepLevel); data.setLong("firstPlayed", getFirstPlayed()); data.setLong("lastPlayed", System.currentTimeMillis()); } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 03bc3827..c1bb8b36 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -316,7 +316,6 @@ public class CraftEventFactory { org.bukkit.World world = entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); - // TODO: Possibly a way to persist this incase of disconnect victim.keepLevel = event.getKeepLevel(); victim.newLevel = event.getNewLevel(); victim.newTotalExp = event.getNewTotalExp(); @@ -329,8 +328,7 @@ public class CraftEventFactory { if (stack instanceof CraftItemStack) { // Use the internal item to preserve possible data. victim.a(((CraftItemStack) stack).getHandle(), 0.0f); - } - else { + } else { world.dropItemNaturally(entity.getLocation(), stack); } } |