mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-12 09:35:26 +02:00
Change user matching for enderchest.
Update SetExpFix to 2.9 Version
This commit is contained in:
@@ -12,7 +12,7 @@ public class Commandenderchest extends EssentialsCommand
|
||||
{
|
||||
if (args.length > 0 && Permissions.ENDERCHEST_OTHERS.isAuthorized(user))
|
||||
{
|
||||
final IUser invUser = ess.getUserMap().getUser(args[0]);
|
||||
final IUser invUser = ess.getUserMap().matchUser(args[0], false, false);
|
||||
user.getPlayer().openInventory(invUser.getPlayer().getEnderChest());
|
||||
user.setEnderSee(true);
|
||||
}
|
||||
|
@@ -16,13 +16,13 @@ public class SetExpFix
|
||||
player.setExp(0);
|
||||
player.setLevel(0);
|
||||
player.setTotalExperience(0);
|
||||
|
||||
|
||||
//This following code is technically redundant now, as bukkit now calulcates levels more or less correctly
|
||||
//At larger numbers however... player.getExp(3000), only seems to give 2999, putting the below calculations off.
|
||||
int amount = exp;
|
||||
while (amount > 0)
|
||||
{
|
||||
final int expToLevel = getExpToLevel(player);
|
||||
final int expToLevel = getExpAtLevel(player);
|
||||
amount -= expToLevel;
|
||||
if (amount >= 0)
|
||||
{
|
||||
@@ -39,27 +39,56 @@ public class SetExpFix
|
||||
}
|
||||
}
|
||||
|
||||
private static int getExpToLevel(final Player player)
|
||||
{
|
||||
return getExpToLevel(player.getLevel());
|
||||
private static int getExpAtLevel(final Player player)
|
||||
{
|
||||
return getExpAtLevel(player.getLevel());
|
||||
}
|
||||
|
||||
public static int getExpAtLevel(final int level)
|
||||
{
|
||||
if (level > 29)
|
||||
{
|
||||
return 62 + (level - 30) * 7;
|
||||
}
|
||||
if (level > 15)
|
||||
{
|
||||
return 17 + (level - 15) * 3;
|
||||
}
|
||||
return 17;
|
||||
}
|
||||
|
||||
private static int getExpToLevel(final int level)
|
||||
{
|
||||
return 7 + (level * 7 >> 1);
|
||||
public static int getExpToLevel(final int level)
|
||||
{
|
||||
int currentLevel = 0;
|
||||
int exp = 0;
|
||||
|
||||
while (currentLevel < level)
|
||||
{
|
||||
exp += getExpAtLevel(currentLevel);
|
||||
currentLevel++;
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
|
||||
//This method is required because the bukkit player.getTotalExperience() method, shows exp that has been 'spent'.
|
||||
//Without this people would be able to use exp and then still sell it.
|
||||
public static int getTotalExperience(final Player player)
|
||||
{
|
||||
int exp = (int)Math.round(getExpToLevel(player) * player.getExp());
|
||||
int exp = (int)Math.round(getExpAtLevel(player) * player.getExp());
|
||||
int currentLevel = player.getLevel();
|
||||
|
||||
while (currentLevel > 0) {
|
||||
|
||||
while (currentLevel > 0)
|
||||
{
|
||||
currentLevel--;
|
||||
exp += getExpToLevel(currentLevel);
|
||||
exp += getExpAtLevel(currentLevel);
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
public static int getExpUntilNextLevel(final Player player)
|
||||
{
|
||||
int exp = (int)Math.round(getExpAtLevel(player) * player.getExp());
|
||||
int nextLevel = player.getLevel();
|
||||
return getExpAtLevel(nextLevel) - exp;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user