13
0
geforkt von Mirrors/Paper

Implemented new PlayerDeathEvent methods for exp setting

Dieser Commit ist enthalten in:
Nathan Adams 2012-01-14 18:08:27 +00:00
Ursprung 548ccabe2f
Commit 2ab160e484
2 geänderte Dateien mit 23 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -65,6 +65,9 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public String listName; public String listName;
public org.bukkit.Location compassTarget; public org.bukkit.Location compassTarget;
public int newExp = 0; public int newExp = 0;
public int newLevel = 0;
public int newTotalExp = 0;
public boolean keepLevel = false;
// CraftBukkit end // CraftBukkit end
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
@ -553,6 +556,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void t_() { public void t_() {
this.cf = -99999999; this.cf = -99999999;
this.lastSentExp = -1; // CraftBukkit - Added to reset
} }
public void a(String s) { public void a(String s) {
@ -627,19 +631,31 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
} }
public void reset() { public void reset() {
float exp = 0;
if(this.keepLevel) {
exp = this.exp;
this.newTotalExp = this.expTotal;
this.newLevel = this.expLevel;
}
this.health = 20; this.health = 20;
this.fireTicks = 0; this.fireTicks = 0;
this.fallDistance = 0; this.fallDistance = 0;
this.foodData = new FoodMetaData(); this.foodData = new FoodMetaData();
this.expLevel = 0; this.expLevel = this.newLevel;
this.expTotal = 0; this.expTotal = this.newTotalExp;
this.exp = 0; this.exp = 0;
this.deathTicks = 0; this.deathTicks = 0;
effects.clear(); effects.clear();
this.activeContainer = this.defaultContainer; this.activeContainer = this.defaultContainer;
this.lastSentExp = -1; // lastSentExp. Find line: "if (this.expTotal != this.XXXX) {" this.lastSentExp = -1; // lastSentExp. Find line: "if (this.expTotal != this.XXXX) {"
if(this.keepLevel) {
this.exp = exp;
} else {
this.giveExp(this.newExp); this.giveExp(this.newExp);
} }
this.keepLevel = false;
}
public CraftPlayer getPlayer() { public CraftPlayer getPlayer() {
return (CraftPlayer)getBukkitEntity(); return (CraftPlayer)getBukkitEntity();

Datei anzeigen

@ -330,6 +330,10 @@ public class CraftEventFactory {
org.bukkit.World world = entity.getWorld(); org.bukkit.World world = entity.getWorld();
Bukkit.getServer().getPluginManager().callEvent(event); 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.expToDrop = event.getDroppedExp();
victim.newExp = event.getNewExp(); victim.newExp = event.getNewExp();