This will fix negative exp.
Add to MapleCharacter.java
After public int getExp() {}
Code:
public void setExp(int amount) {
exp.set(amount);
}
Add to MapleClient.java
At public void disconnect() {
Change
Code:
chr.saveToDB(true);
to
Code:
//fix negative exp on logout
if (chr.getExp() < 0) {
chr.setExp(0);
}
chr.saveToDB(true);
Alternative method would be to set the players exp to 0 if its under 0 when the player gains exp again. In MapleCharacter.java add this in public void gainExp.
Code:
if (this.getExp() < 0) {
this.setExp(0);
}
*MULTI LEVEL VERSION*
Another method would be to set the players exp to positive then issue a levelup if the players new positive exp is greater than or equal to the the required exp to levelup.
Code:
//if the player has negative exp while gaining exp convert to absolute value and levelup if value is greater than exp needed for level
if (getExp() < 0) {
setExp(Math.abs(getExp()));
while (level < 200 && getExp() >= ExpTable.getExpNeededForLevel(level + 1)) {
levelUp();
}
}
*SINGLE LEVEL VERSION*
Set the players exp to positive then issue a levelup if the players new positive exp is greater than or equal to the the required exp to levelup then set it to 0 after one level.
Code:
//if the player has negative exp while gaining exp convert to absolute value and levelup if value is greater than exp needed for level
if (getExp() < 0) {
setExp(Math.abs(getExp()));
if (level < 200 && getExp() >= ExpTable.getExpNeededForLevel(level + 1)) {
levelUp();
setExp(0);
}
}