summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayer.java22
-rw-r--r--src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java4
2 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 64821a6e..b9ca7d37 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -65,6 +65,9 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public String listName;
public org.bukkit.Location compassTarget;
public int newExp = 0;
+ public int newLevel = 0;
+ public int newTotalExp = 0;
+ public boolean keepLevel = false;
// CraftBukkit end
public void a(NBTTagCompound nbttagcompound) {
@@ -553,6 +556,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void t_() {
this.cf = -99999999;
+ this.lastSentExp = -1; // CraftBukkit - Added to reset
}
public void a(String s) {
@@ -627,18 +631,30 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
public void reset() {
+ float exp = 0;
+ if(this.keepLevel) {
+ exp = this.exp;
+ this.newTotalExp = this.expTotal;
+ this.newLevel = this.expLevel;
+ }
+
this.health = 20;
this.fireTicks = 0;
this.fallDistance = 0;
this.foodData = new FoodMetaData();
- this.expLevel = 0;
- this.expTotal = 0;
+ this.expLevel = this.newLevel;
+ this.expTotal = this.newTotalExp;
this.exp = 0;
this.deathTicks = 0;
effects.clear();
this.activeContainer = this.defaultContainer;
this.lastSentExp = -1; // lastSentExp. Find line: "if (this.expTotal != this.XXXX) {"
- this.giveExp(this.newExp);
+ if(this.keepLevel) {
+ this.exp = exp;
+ } else {
+ this.giveExp(this.newExp);
+ }
+ this.keepLevel = false;
}
public CraftPlayer getPlayer() {
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index a5f83428..887bbe4b 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -330,6 +330,10 @@ 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();
victim.expToDrop = event.getDroppedExp();
victim.newExp = event.getNewExp();