mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-13 04:36:44 +00:00
Merge branch 'refs/heads/master' into release
This commit is contained in:
commit
867e66e774
4 changed files with 70 additions and 48 deletions
|
@ -81,7 +81,7 @@ public class Trade
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exp != null && exp > 0
|
if (exp != null && exp > 0
|
||||||
&& user.getTotalExperience() < exp) {
|
&& SetExpFix.getTotalExperience(user) < exp) {
|
||||||
throw new ChargeException(_("notEnoughExperience"));
|
throw new ChargeException(_("notEnoughExperience"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class Trade
|
||||||
}
|
}
|
||||||
if (getExperience() != null)
|
if (getExperience() != null)
|
||||||
{
|
{
|
||||||
SetExpFix.setTotalExperience(user, user.getTotalExperience() + getExperience());
|
SetExpFix.setTotalExperience(user, SetExpFix.getTotalExperience(user) + getExperience());
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ public class Trade
|
||||||
}
|
}
|
||||||
if (getExperience() != null)
|
if (getExperience() != null)
|
||||||
{
|
{
|
||||||
final int experience = user.getTotalExperience();
|
final int experience = SetExpFix.getTotalExperience(user);
|
||||||
if (experience < getExperience() && getExperience() > 0)
|
if (experience < getExperience() && getExperience() > 0)
|
||||||
{
|
{
|
||||||
throw new ChargeException(_("notEnoughExperience"));
|
throw new ChargeException(_("notEnoughExperience"));
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class SetExpFix
|
||||||
int amount = exp;
|
int amount = exp;
|
||||||
while (amount > 0)
|
while (amount > 0)
|
||||||
{
|
{
|
||||||
final int expToLevel = getExpTolevel(player);
|
final int expToLevel = getExpToLevel(player);
|
||||||
amount -= expToLevel;
|
amount -= expToLevel;
|
||||||
if (amount >= 0)
|
if (amount >= 0)
|
||||||
{
|
{
|
||||||
|
@ -34,8 +34,25 @@ public class SetExpFix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getExpTolevel(final Player player)
|
private static int getExpToLevel(final Player player)
|
||||||
{
|
{
|
||||||
return 7 + (player.getLevel() * 7 >> 1);
|
return getExpToLevel(player.getLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getExpToLevel(final int level)
|
||||||
|
{
|
||||||
|
return 7 + (level * 7 >> 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getTotalExperience(final Player player)
|
||||||
|
{
|
||||||
|
int exp = (int) (getExpToLevel(player) * player.getExp());
|
||||||
|
int currentLevel = player.getLevel();
|
||||||
|
|
||||||
|
while (currentLevel > 0) {
|
||||||
|
currentLevel--;
|
||||||
|
exp += getExpToLevel(currentLevel);
|
||||||
|
}
|
||||||
|
return exp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,3 +85,4 @@ v 1.7:
|
||||||
- Offline player checks now support partial name matches.
|
- Offline player checks now support partial name matches.
|
||||||
- Added custom events so plugins can now be notified of changes within GroupManager.
|
- Added custom events so plugins can now be notified of changes within GroupManager.
|
||||||
- GM now registers with Bukkits ServicesManager.
|
- GM now registers with Bukkits ServicesManager.
|
||||||
|
- deleting the contents of GlobalGroups.yml will no longer thrown a NullPointerException.
|
|
@ -107,13 +107,15 @@ public class GlobalGroups {
|
||||||
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + GlobalGroupsFile.getPath(), ex);
|
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + GlobalGroupsFile.getPath(), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear out old groups
|
||||||
|
resetGlobalGroups();
|
||||||
|
|
||||||
|
if (!GGroups.getKeys(false).isEmpty()) {
|
||||||
// Read all global groups
|
// Read all global groups
|
||||||
Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
|
Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
|
||||||
|
|
||||||
// Load each groups permissions list.
|
// Load each groups permissions list.
|
||||||
if (allGroups != null) {
|
if (allGroups != null) {
|
||||||
// Clear out old groups
|
|
||||||
resetGlobalGroups();
|
|
||||||
for (String groupName : allGroups.keySet()) {
|
for (String groupName : allGroups.keySet()) {
|
||||||
Group newGroup = new Group(groupName.toLowerCase());
|
Group newGroup = new Group(groupName.toLowerCase());
|
||||||
Object element;
|
Object element;
|
||||||
|
@ -150,6 +152,8 @@ public class GlobalGroups {
|
||||||
}
|
}
|
||||||
|
|
||||||
removeGroupsChangedFlag();
|
removeGroupsChangedFlag();
|
||||||
|
}
|
||||||
|
|
||||||
setTimeStampGroups(GlobalGroupsFile.lastModified());
|
setTimeStampGroups(GlobalGroupsFile.lastModified());
|
||||||
GroupManager.setLoaded(true);
|
GroupManager.setLoaded(true);
|
||||||
//GlobalGroupsFile = null;
|
//GlobalGroupsFile = null;
|
||||||
|
|
Loading…
Reference in a new issue