Another fix for /exp

This commit is contained in:
snowleo 2012-08-03 10:29:22 +02:00
parent 80f001fdb7
commit c8a07ecdb5
2 changed files with 14 additions and 3 deletions

View File

@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -122,8 +121,7 @@ public class Commandexp extends EssentialsCommand
private void showExp(final CommandSender sender, final User target)
{
final int totalExp = SetExpFix.getTotalExperience(target);
final int expLeft = (int)Util.roundDouble(((((3.5 * target.getLevel()) + 6.7) - (totalExp - ((1.75 * (target.getLevel() * target.getLevel())) + (5.00 * target.getLevel())))) + 1));
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), expLeft));
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), SetExpFix.getExpUntilNextLevel(target)));
}
private void setExp(final CommandSender sender, final User target, final String strAmount, final boolean give)

View File

@ -71,4 +71,17 @@ public class SetExpFix
}
return exp;
}
public static int getExpUntilNextLevel(final Player player)
{
int exp = 0;
int currentLevel = player.getLevel() + 1;
while (currentLevel > 0)
{
currentLevel--;
exp += getExpToLevel(currentLevel);
}
return exp - getTotalExperience(player);
}
}