From 1af4c554b3e4dfbb26fabab9b95f680991b36899 Mon Sep 17 00:00:00 2001 From: Zrips Date: Sat, 14 Jan 2017 15:20:01 +0200 Subject: [PATCH] Use iterraation to prevent concurrent modification error --- com/gamingmesh/jobs/Jobs.java | 5 ++++- com/gamingmesh/jobs/PlayerManager.java | 1 - com/gamingmesh/jobs/container/JobsPlayer.java | 14 +++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/com/gamingmesh/jobs/Jobs.java b/com/gamingmesh/jobs/Jobs.java index ab6d68db..d15864cf 100644 --- a/com/gamingmesh/jobs/Jobs.java +++ b/com/gamingmesh/jobs/Jobs.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map.Entry; import java.util.UUID; @@ -468,7 +469,9 @@ public class Jobs extends JavaPlugin { int y = 0; int total = Jobs.getPlayerManager().getMapSize(); long time = System.currentTimeMillis(); - for (Entry one : Jobs.getPlayerManager().getPlayersInfoUUIDMap().entrySet()) { + Iterator> it = Jobs.getPlayerManager().getPlayersInfoUUIDMap().entrySet().iterator(); + while (it.hasNext()) { + Entry one = it.next(); if (!running) return; try { diff --git a/com/gamingmesh/jobs/PlayerManager.java b/com/gamingmesh/jobs/PlayerManager.java index c03e9894..76f30816 100644 --- a/com/gamingmesh/jobs/PlayerManager.java +++ b/com/gamingmesh/jobs/PlayerManager.java @@ -629,7 +629,6 @@ public class PlayerManager { } public BoostMultiplier getBoost(JobsPlayer player, Job job, boolean force) { - Debug.D("getting boost"); BoostMultiplier b = new BoostMultiplier(); for (CurrencyType one : CurrencyType.values()) { b.add(one, getBoost(player, job, one, force)); diff --git a/com/gamingmesh/jobs/container/JobsPlayer.java b/com/gamingmesh/jobs/container/JobsPlayer.java index 603fda6a..8f05bb29 100644 --- a/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/com/gamingmesh/jobs/container/JobsPlayer.java @@ -173,7 +173,7 @@ public class JobsPlayer { this.player = Bukkit.getPlayer(this.playerUUID); return this.player; } - + /** * Get the VipSpawnerMultiplier * @return the Multiplier @@ -203,12 +203,9 @@ public class JobsPlayer { public double getBoost(String JobName, CurrencyType type, boolean force) { double Boost = 0D; - Debug.D("1 "+this.isOnline()); - if (!this.isOnline()) return Boost; - Debug.D("4 "); long time = System.currentTimeMillis(); if (this.boostCounter.containsKey(JobName)) { @@ -241,17 +238,16 @@ public class JobsPlayer { private Double getPlayerBoostNew(String JobName, CurrencyType type) { Double Boost = null; Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + JobName + "." + type.getName().toLowerCase(), true); - Boost = v1; + Boost = v1; v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + JobName + ".all"); - if (Boost == null ||v1 != null && v1 > Boost) + if (Boost == null || v1 != null && v1 > Boost) Boost = v1; v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all.all"); - if (Boost == null ||v1 != null && v1 > Boost) + if (Boost == null || v1 != null && v1 > Boost) Boost = v1; v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all." + type.getName().toLowerCase()); - if (Boost == null ||v1 != null &&v1 > Boost) + if (Boost == null || v1 != null && v1 > Boost) Boost = v1; - Debug.D("bonus " + Boost); return Boost == null ? 0D : Boost; }