mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-16 03:24:31 +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))
|
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.getPlayer().openInventory(invUser.getPlayer().getEnderChest());
|
||||||
user.setEnderSee(true);
|
user.setEnderSee(true);
|
||||||
}
|
}
|
||||||
|
@@ -16,13 +16,13 @@ public class SetExpFix
|
|||||||
player.setExp(0);
|
player.setExp(0);
|
||||||
player.setLevel(0);
|
player.setLevel(0);
|
||||||
player.setTotalExperience(0);
|
player.setTotalExperience(0);
|
||||||
|
|
||||||
//This following code is technically redundant now, as bukkit now calulcates levels more or less correctly
|
//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.
|
//At larger numbers however... player.getExp(3000), only seems to give 2999, putting the below calculations off.
|
||||||
int amount = exp;
|
int amount = exp;
|
||||||
while (amount > 0)
|
while (amount > 0)
|
||||||
{
|
{
|
||||||
final int expToLevel = getExpToLevel(player);
|
final int expToLevel = getExpAtLevel(player);
|
||||||
amount -= expToLevel;
|
amount -= expToLevel;
|
||||||
if (amount >= 0)
|
if (amount >= 0)
|
||||||
{
|
{
|
||||||
@@ -39,27 +39,56 @@ public class SetExpFix
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getExpToLevel(final Player player)
|
private static int getExpAtLevel(final Player player)
|
||||||
{
|
{
|
||||||
return getExpToLevel(player.getLevel());
|
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)
|
public static int getExpToLevel(final int level)
|
||||||
{
|
{
|
||||||
return 7 + (level * 7 >> 1);
|
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'.
|
//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.
|
//Without this people would be able to use exp and then still sell it.
|
||||||
public static int getTotalExperience(final Player player)
|
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();
|
int currentLevel = player.getLevel();
|
||||||
|
|
||||||
while (currentLevel > 0) {
|
while (currentLevel > 0)
|
||||||
|
{
|
||||||
currentLevel--;
|
currentLevel--;
|
||||||
exp += getExpToLevel(currentLevel);
|
exp += getExpAtLevel(currentLevel);
|
||||||
}
|
}
|
||||||
return exp;
|
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