diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index fbbbb2cd..592b5fbf 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -698,8 +698,8 @@ public class ConfigManager { if (Version.isCurrentEqualOrLower(Version.v1_12_R1)) { short legacyData = material.getLegacyData(); - if (legacyData > 0) - subType = ":" + legacyData; + if (legacyData > 0) + subType = ":" + legacyData; } id = material.getId(); diff --git a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java index 7394e070..2fabac83 100644 --- a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -54,11 +54,13 @@ public class NameTranslatorManager { if (nameLs == null) { mat = CMIMaterial.get(materialName.replace(" ", "")); - nameLs = listOfNames.get(mat); - NameList nameMeta = listOfNames.get(CMIMaterial.get(meta.replace(" ", ""))); - if (nameLs != null && nameMeta != null) { - return nameLs + ":" + nameMeta; + if ((nameLs = listOfNames.get(mat)) != null) { + NameList nameMeta = listOfNames.get(CMIMaterial.get(meta.replace(" ", ""))); + + if (nameMeta != null) { + return nameLs + ":" + nameMeta; + } } if (mat == CMIMaterial.NONE) { @@ -76,15 +78,15 @@ public class NameTranslatorManager { CMIMaterial mat = CMIMaterial.get(materialName); NameList nameLs = listOfNames.get(mat); - if (nameLs != null) { - if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Util.getPotionByName(meta) != null) { - return nameLs.getName() + ":" + meta; - } + if (nameLs != null) { + if (meta != null && !meta.isEmpty() && mat.isCanHavePotionType() && Util.getPotionByName(meta) != null) { + return nameLs.getName() + ":" + meta; + } - if (name != null && !name.isEmpty()) { - return nameLs.getName(); + if (name != null && !name.isEmpty()) { + return nameLs.getName(); + } } - } if (id > 0 && meta != null && !meta.isEmpty()) { mat = CMIMaterial.get(id + ":" + meta); diff --git a/src/main/java/com/gamingmesh/jobs/economy/PaymentData.java b/src/main/java/com/gamingmesh/jobs/economy/PaymentData.java index b8ca8509..b6df755c 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/PaymentData.java +++ b/src/main/java/com/gamingmesh/jobs/economy/PaymentData.java @@ -53,10 +53,6 @@ public class PaymentData { return data == null ? 0D : (int) (data.getAmount() * 100) / 100D; } - public Double getAmountBylimit(CurrencyType type, int limit) { - return getAmount(type) > limit ? (double) limit : (int) (getAmount(type) * 100) / 100D; - } - public Long getLastAnnounced() { return lastAnnouced; } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index 9dc51267..f9d77324 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -439,7 +439,7 @@ public class JobsListener implements Listener { @EventHandler(ignoreCancelled = true) public void onChunkChangeMove(PlayerMoveEvent event) { - if (!event.getPlayer().isOnline() || event.getTo() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getTo().getWorld())) + if (!event.getPlayer().isOnline() || !Jobs.getGCManager().canPerformActionInWorld(event.getTo().getWorld())) return; Chunk from = event.getFrom().getChunk(); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java index 05b4fd62..176c4010 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -32,6 +33,8 @@ public final class JobsPayment14Listener implements Listener { if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) return; + Location blockLoc = event.getBlock().getLocation(); + for (Map.Entry> map : campPlayers.entrySet()) { List camps = map.getValue(); @@ -41,7 +44,7 @@ public final class JobsPayment14Listener implements Listener { } for (PlayerCamp camp : new ArrayList<>(camps)) { - if (camp.getBlock().getLocation().equals(event.getBlock().getLocation())) { + if (camp.getBlock().getLocation().equals(blockLoc)) { if (camp.getItem().equals(event.getSource())) { camps.remove(camp); @@ -64,23 +67,27 @@ public final class JobsPayment14Listener implements Listener { if (event.getBlock().getType() != Material.CAMPFIRE || campPlayers.isEmpty()) return; - List camps = campPlayers.get(event.getPlayer().getUniqueId()); + UUID playerUId = event.getPlayer().getUniqueId(); + List camps = campPlayers.get(playerUId); if (camps == null) return; if (camps.isEmpty()) { - campPlayers.remove(event.getPlayer().getUniqueId()); + campPlayers.remove(playerUId); return; } + Location blockLoc = event.getBlock().getLocation(); + for (PlayerCamp camp : new ArrayList<>(camps)) { - if (camp.getBlock().getLocation().equals(event.getBlock().getLocation())) { + if (camp.getBlock().getLocation().equals(blockLoc)) { camps.remove(camp); if (camps.isEmpty()) { campPlayers.remove(event.getPlayer().getUniqueId()); + campPlayers.remove(playerUId); } else { - campPlayers.put(event.getPlayer().getUniqueId(), camps); + campPlayers.put(playerUId, camps); } break; diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index b907adc0..31b7cb2e 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -1662,13 +1662,13 @@ public class JobsPaymentListener implements Listener { && !Jobs.getGCManager().payExploringWhenGliding && player.isGliding()) return; - org.bukkit.World playerWorld = player.getWorld(); - - // check if in creative - if (!Jobs.getGCManager().canPerformActionInWorld(playerWorld) || !payIfCreative(player)) + if (!payIfCreative(player)) return; - if (!Jobs.getPermissionHandler().hasWorldPermission(player, playerWorld.getName())) + org.bukkit.World playerWorld = player.getWorld(); + + if (!Jobs.getGCManager().canPerformActionInWorld(playerWorld) + || !Jobs.getPermissionHandler().hasWorldPermission(player, playerWorld.getName())) return; JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); @@ -1715,7 +1715,9 @@ public class JobsPaymentListener implements Listener { for (Entry oneG : got.entrySet()) { Map map = hand.getEnchantments(); - if (!map.containsKey(oneG.getKey()) || map.get(oneG.getKey()).equals(oneG.getValue())) + Integer key = map.get(oneG.getKey()); + + if (key == null || key.equals(oneG.getValue())) return false; }