diff --git a/src/main/java/com/gamingmesh/jobs/PermissionManager.java b/src/main/java/com/gamingmesh/jobs/PermissionManager.java index 31b73ed3..3b424aea 100644 --- a/src/main/java/com/gamingmesh/jobs/PermissionManager.java +++ b/src/main/java/com/gamingmesh/jobs/PermissionManager.java @@ -29,6 +29,7 @@ import org.bukkit.permissions.PermissionAttachmentInfo; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobsPlayer; +import com.gamingmesh.jobs.stuff.Debug; public class PermissionManager { @@ -117,17 +118,17 @@ public class PermissionManager { } public Double getMaxPermission(JobsPlayer jPlayer, String perm) { - return getMaxPermission(jPlayer, perm, false, false, false); + return getMaxPermission(jPlayer, perm, false, false); } public Double getMaxPermission(JobsPlayer jPlayer, String perm, boolean force) { - return getMaxPermission(jPlayer, perm, force, false, false); + return getMaxPermission(jPlayer, perm, force, false); } - public Double getMaxPermission(JobsPlayer jPlayer, String perm, boolean force, boolean cumulative, boolean allowMinus) { + public Double getMaxPermission(JobsPlayer jPlayer, String perm, boolean force, boolean cumulative) { if (jPlayer == null || jPlayer.getPlayer() == null) return 0D; - + perm = perm.toLowerCase(); if (!perm.endsWith(".")) perm += "."; @@ -139,24 +140,24 @@ public class PermissionManager { jPlayer.setLastPermissionUpdate(System.currentTimeMillis()); } - double amount = 0D; + double amount = Double.NEGATIVE_INFINITY; for (Map.Entry permission : permissions.entrySet()) { if (!permission.getKey().startsWith(perm) || !permission.getValue()) continue; - try { double temp = Double.parseDouble(permission.getKey().replace(perm, "")); if (cumulative) amount += temp; - else if (allowMinus || temp > amount) + else if (temp > amount) amount = temp; } catch (NumberFormatException ignored) { + ignored.printStackTrace(); // Should be ignored } } - return amount; + return amount == Double.NEGATIVE_INFINITY ? 0D : amount; } public boolean hasPermission(JobsPlayer jPlayer, String perm) { diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index c8ca19bb..957c55e4 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -977,7 +977,7 @@ public class PlayerManager { if (ent instanceof Tameable) { Tameable t = (Tameable) ent; if (t.isTamed() && t.getOwner() instanceof Player) { - petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false, true); + petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false); if (petPay != 0D) boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); } @@ -985,20 +985,20 @@ public class PlayerManager { if (ent != null && HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(ent, player.getPlayer())) { if (petPay == 0D) - petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false, true); + petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", false, false); if (petPay != 0D) boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); } if (victim != null && victim.hasMetadata(getMobSpawnerMetadata())) { - Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", false, false, true); + Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", false, false); if (amount != 0D) boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount)); } if (getall) { if (petPay == 0D) - petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force, false, true); + petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force, false); if (petPay != 0D) boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 80e8079e..914a1781 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -286,18 +286,18 @@ public class JobsPlayer { } private Double getPlayerBoostNew(String JobName, CurrencyType type) { - Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + JobName + "." + type.getName(), true, false, true); + Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + JobName + "." + type.getName(), true, false); Double Boost = v1; - v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + JobName + ".all", false, false, true); + v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + JobName + ".all", false, false); if (v1 != 0d && (v1 > Boost || v1 < Boost)) Boost = v1; - v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all.all", false, false, true); + v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all.all", false, false); if (v1 != 0d && (v1 > Boost || v1 < Boost)) Boost = v1; - v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all." + type.getName(), false, false, true); + v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all." + type.getName(), false, false); if (v1 != 0d && (v1 > Boost || v1 < Boost)) Boost = v1; @@ -305,10 +305,10 @@ public class JobsPlayer { } public int getPlayerMaxQuest(String jobName) { - int m1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest." + jobName, false, true, false).intValue(); + int m1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest." + jobName, false, true).intValue(); int max = m1; - m1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest.all", false, true, false).intValue(); + m1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.maxquest.all", false, true).intValue(); if (m1 != 0 && (m1 > max || m1 < max)) { max = m1; } diff --git a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java index 05abb3ff..771132d3 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java +++ b/src/main/java/com/gamingmesh/jobs/economy/BufferedEconomy.java @@ -124,12 +124,12 @@ public class BufferedEconomy { if (Jobs.getGCManager().TakeFromPlayersPayment && Jobs.getGCManager().UseTaxes && ((offPlayer.isOnline() && !offPlayer.getPlayer().hasPermission("jobs.tax.bypass")) || !offPlayer.isOnline())) { JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(offPlayer.getUniqueId()); - double moneyTaxAmount = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.tax.money", false, false, true); + double moneyTaxAmount = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.tax.money", false, false); if (moneyTaxAmount == 0D) { moneyTaxAmount = Jobs.getGCManager().TaxesAmount; } - double pointsTaxAmount = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.tax.points", false, false, true); + double pointsTaxAmount = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.tax.points", false, false); if (pointsTaxAmount == 0D) { pointsTaxAmount = Jobs.getGCManager().TaxesAmount; } @@ -148,12 +148,12 @@ public class BufferedEconomy { if (Jobs.getGCManager().TakeFromPlayersPayment && Jobs.getGCManager().UseTaxes && ((offPlayer.isOnline() && !offPlayer.getPlayer().hasPermission("jobs.tax.bypass")) || !offPlayer.isOnline())) { JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(offPlayer.getUniqueId()); - double moneyTaxAmount = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.tax.money", false, false, true); + double moneyTaxAmount = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.tax.money", false, false); if (moneyTaxAmount == 0D) { moneyTaxAmount = Jobs.getGCManager().TaxesAmount; } - double pointsTaxAmount = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.tax.points", false, false, true); + double pointsTaxAmount = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.tax.points", false, false); if (pointsTaxAmount == 0D) { pointsTaxAmount = Jobs.getGCManager().TaxesAmount; }