From 94f4a46cd33dd5a6165052ec5f123bb97d9bb6f3 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Sat, 22 Aug 2020 20:40:25 +0200 Subject: [PATCH] Some things --- README.md | 22 ++++++++ .../gamingmesh/jobs/CMILib/ItemManager.java | 4 -- .../com/gamingmesh/jobs/ItemBoostManager.java | 8 +-- src/main/java/com/gamingmesh/jobs/Jobs.java | 16 +++--- .../com/gamingmesh/jobs/PlayerManager.java | 24 ++++----- .../com/gamingmesh/jobs/Signs/SignUtil.java | 7 +-- .../jobs/commands/JobsCommands.java | 9 ++-- .../gamingmesh/jobs/commands/list/log.java | 11 ++-- .../gamingmesh/jobs/commands/list/quests.java | 5 +- .../jobs/commands/list/resetquest.java | 8 ++- .../jobs/config/ExploreManager.java | 2 +- .../jobs/config/RestrictedAreaManager.java | 18 +++---- .../jobs/config/RestrictedBlockManager.java | 2 +- .../gamingmesh/jobs/config/TitleManager.java | 2 +- .../jobs/container/BlockProtection.java | 14 ++--- .../jobs/container/ExploreChunk.java | 15 ++---- .../jobs/container/ExploreRegion.java | 3 +- .../jobs/container/JobCommands.java | 2 +- .../jobs/container/JobLimitedItems.java | 6 +-- .../gamingmesh/jobs/container/JobsPlayer.java | 18 +++---- .../gamingmesh/jobs/container/PlayerInfo.java | 4 +- .../com/gamingmesh/jobs/container/Quest.java | 22 ++++---- .../jobs/container/QuestProgression.java | 23 ++++---- .../gamingmesh/jobs/container/Schedule.java | 6 +-- .../java/com/gamingmesh/jobs/dao/JobsDAO.java | 52 +++++++++---------- .../gamingmesh/jobs/economy/PointsData.java | 7 +-- .../jobs/listeners/JobsListener.java | 6 +-- .../jobs/listeners/JobsPaymentListener.java | 4 +- .../com/gamingmesh/jobs/stuff/Loging.java | 5 +- .../gamingmesh/jobs/stuff/TabComplete.java | 17 +++--- .../java/com/gamingmesh/jobs/stuff/Util.java | 7 ++- 31 files changed, 161 insertions(+), 188 deletions(-) diff --git a/README.md b/README.md index 70b368a9..e57f8c37 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,25 @@ A fully configurable plugin that allows you to get paid for breaking, placing, k Main pages: - Bukkit: https://dev.bukkit.org/projects/jobs-reborn - Spigot: https://www.spigotmc.org/resources/4216/ + +# Jobs API +You can manually add the jar file to your build path or you can use jitpack if you use maven (don't know gradle): +```xml + + + jitpack.io + https://jitpack.io + + + + + + com.github.Zrips + Jobs + LATEST + provided + + +``` + +For API events: https://github.com/Zrips/Jobs/wiki/API diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index 8d7273ed..f35f70f2 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -1,14 +1,10 @@ package com.gamingmesh.jobs.CMILib; import java.util.HashMap; -import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.OfflinePlayer; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionType; diff --git a/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java b/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java index bad295f6..a0256ef3 100644 --- a/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java +++ b/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java @@ -140,7 +140,7 @@ public class ItemBoostManager { List lore = new ArrayList<>(); if (cfg.getC().contains(one + ".lore") && !cfg.getC().getStringList(one + ".lore").isEmpty()) { for (String eachLine : cfg.get(one + ".lore", Arrays.asList(""))) { - lore.add(org.bukkit.ChatColor.translateAlternateColorCodes('&', eachLine)); + lore.add(CMIChatColor.translate(eachLine)); } } @@ -213,9 +213,9 @@ public class ItemBoostManager { public static List getItemsByJob(Job job) { List ls = new ArrayList<>(); - for (Entry one : items.entrySet()) { - if (one.getValue().getJobs().contains(job)) - ls.add(one.getValue()); + for (JobItems one : items.values()) { + if (one.getJobs().contains(job)) + ls.add(one); } return ls; } diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 62657ff9..e00db258 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -60,7 +60,6 @@ import java.io.File; import java.io.IOException; import java.sql.SQLException; import java.util.*; -import java.util.Map.Entry; import java.util.logging.Logger; public class Jobs extends JavaPlugin { @@ -444,11 +443,11 @@ public class Jobs extends JavaPlugin { HashMap> playersLogs = dao.getAllLogs(); HashMap playersArchives = dao.getAllArchivedJobs(); HashMap playersLimits = dao.loadPlayerLimits(); - for (Iterator> it = temp.entrySet().iterator(); it.hasNext();) { - Entry one = it.next(); - int id = one.getValue().getID(); + for (Iterator it = temp.values().iterator(); it.hasNext();) { + PlayerInfo one = it.next(); + int id = one.getID(); JobsPlayer jPlayer = getPlayerManager().getJobsPlayerOffline( - one.getValue(), + one, playersJobs.get(id), playersPoints.get(id), playersLogs.get(id), @@ -1181,12 +1180,13 @@ public class Jobs extends JavaPlugin { getBpManager().add(block, cd); return true; } + if (time > System.currentTimeMillis() || bp.isPaid() && bp.getAction() != DBAction.DELETE) { int sec = Math.round((time - System.currentTimeMillis()) / 1000L); - if (inform) { - if (player.canGetPaid(info)) - ActionBarManager.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec)); + if (inform && player.canGetPaid(info)) { + ActionBarManager.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec)); } + getBpManager().add(block, cd); return false; } diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index bef97cb8..353f6945 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map.Entry; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -63,30 +62,29 @@ import com.gamingmesh.jobs.container.PlayerPoints; import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.dao.JobsDAOData; import com.gamingmesh.jobs.economy.PaymentData; -import com.gamingmesh.jobs.economy.PointsData; import com.gamingmesh.jobs.hooks.HookManager; import com.gamingmesh.jobs.stuff.PerformCommands; import com.gamingmesh.jobs.stuff.Util; public class PlayerManager { - private ConcurrentHashMap playersCache = new ConcurrentHashMap<>(); - private ConcurrentHashMap playersUUIDCache = new ConcurrentHashMap<>(); - private ConcurrentHashMap players = new ConcurrentHashMap<>(); - private ConcurrentHashMap playersUUID = new ConcurrentHashMap<>(); + private final ConcurrentHashMap playersCache = new ConcurrentHashMap<>(); + private final ConcurrentHashMap playersUUIDCache = new ConcurrentHashMap<>(); + private final ConcurrentHashMap players = new ConcurrentHashMap<>(); + private final ConcurrentHashMap playersUUID = new ConcurrentHashMap<>(); private final String mobSpawnerMetadata = "jobsMobSpawner"; - private HashMap PlayerUUIDMap = new HashMap<>(); - private HashMap PlayerIDMap = new HashMap<>(); - private HashMap PlayerNameMap = new HashMap<>(); + private final HashMap PlayerUUIDMap = new HashMap<>(); + private final HashMap PlayerIDMap = new HashMap<>(); + private final HashMap PlayerNameMap = new HashMap<>(); /** * @deprecated Use {@link Jobs#getPointsData} instead - * @return {@link PointsData} + * @return {@link com.gamingmesh.jobs.economy.PointsData} */ @Deprecated - public PointsData getPointsData() { + public com.gamingmesh.jobs.economy.PointsData getPointsData() { return Jobs.getPointsData(); } @@ -264,9 +262,7 @@ public class PlayerManager { int i = 0; int total = playersUUIDCache.size(); - for (Entry one : playersUUIDCache.entrySet()) { - JobsPlayer jPlayer = one.getValue(); - + for (JobsPlayer jPlayer : playersUUIDCache.values()) { if (resetID) jPlayer.setUserId(-1); diff --git a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java index acf4880e..17db857c 100644 --- a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java +++ b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java @@ -5,7 +5,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -142,8 +141,7 @@ public class SignUtil { conf.createSection("Signs"); int i = 0; - for (Entry one : SignsByLocation.entrySet()) { - jobsSign sign = one.getValue(); + for (jobsSign sign : SignsByLocation.values()) { ++i; String path = "Signs." + i; reader.set(path + ".Loc", sign.locToBlockString()); @@ -204,8 +202,7 @@ public class SignUtil { HashMap> temp = new HashMap<>(); boolean save = false; - for (Entry one : (new HashMap(signs)).entrySet()) { - jobsSign jSign = one.getValue(); + for (jobsSign jSign : (new HashMap(signs)).values()) { String SignJobName = jSign.getJobName(); Location loc = jSign.getLocation(); if (loc == null) diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index 2e864f12..ebdc2804 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -147,13 +147,13 @@ public class JobsCommands implements CommandExecutor { } sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.title")); - for (Entry one : commands.entrySet()) { + for (String one : commands.keySet()) { if (!pi.isEntryOk()) continue; if (pi.isBreak()) break; - String msg = Jobs.getLanguage().getMessage("command.help.output.cmdInfoFormat", "[command]", getUsage(one.getKey()), "[description]", Jobs.getLanguage().getMessage("command." + one.getKey() + String msg = Jobs.getLanguage().getMessage("command.help.output.cmdInfoFormat", "[command]", getUsage(one), "[description]", Jobs.getLanguage().getMessage("command." + one + ".help.info")); sender.sendMessage(msg); } @@ -259,10 +259,7 @@ public class JobsCommands implements CommandExecutor { return; } - if (type == null) { - type = ""; - } else - type = type.toLowerCase(); + type = type == null ? "" : type.toLowerCase(); List message = new ArrayList<>(); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/log.java b/src/main/java/com/gamingmesh/jobs/commands/list/log.java index f742960d..4632103e 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/log.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/log.java @@ -58,8 +58,8 @@ public class log implements Cmd { Map unsortMap = new HashMap<>(); - for (Entry l : logList.entrySet()) { - for (Entry oneMap : l.getValue().getAmountList().entrySet()) { + for (Log l : logList.values()) { + for (Entry oneMap : l.getAmountList().entrySet()) { unsortMap.put(oneMap.getKey(), oneMap.getValue().get(CurrencyType.MONEY)); } } @@ -74,15 +74,14 @@ public class log implements Cmd { int max = 10; sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getName())); - for (Entry l : logList.entrySet()) { - Log one = l.getValue(); + for (Log one : logList.values()) { HashMap AmountList = one.getAmountList(); double totalMoney = 0, totalExp = 0, totalPoints = 0; - for (Entry oneSorted : unsortMap.entrySet()) { + for (String oneSorted : unsortMap.keySet()) { for (Entry oneMap : AmountList.entrySet()) { - if (oneMap.getKey().equalsIgnoreCase(oneSorted.getKey())) { + if (oneMap.getKey().equalsIgnoreCase(oneSorted)) { count++; LogAmounts amounts = oneMap.getValue(); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/quests.java b/src/main/java/com/gamingmesh/jobs/commands/list/quests.java index 24a46d1c..14043a8c 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/quests.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/quests.java @@ -11,7 +11,6 @@ import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; -import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.JobProgression; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.QuestObjective; @@ -109,8 +108,8 @@ public class quests implements Cmd { } } - for (Entry> oneAction : q.getQuest().getObjectives().entrySet()) { - for (Entry oneObjective : oneAction.getValue().entrySet()) { + for (HashMap oneAction : q.getQuest().getObjectives().values()) { + for (Entry oneObjective : oneAction.entrySet()) { hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " + Jobs.getNameTranslatorManager().Translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue() .getTargetMeta(), oneObjective.getValue().getTargetName()) diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/resetquest.java b/src/main/java/com/gamingmesh/jobs/commands/list/resetquest.java index f5c27307..4e82ceb0 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/resetquest.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/resetquest.java @@ -2,7 +2,6 @@ package com.gamingmesh.jobs.commands.list; import java.util.HashMap; import java.util.List; -import java.util.Map.Entry; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -10,7 +9,6 @@ import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; -import com.gamingmesh.jobs.container.ActionType; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.QuestObjective; @@ -58,9 +56,9 @@ public class resetquest implements Cmd { for (QuestProgression one : quests) { one.setValidUntil(System.currentTimeMillis()); - for (Entry> actions : one.getQuest().getObjectives().entrySet()) { - for (java.util.Map.Entry obj : actions.getValue().entrySet()) { - one.setAmountDone(obj.getValue(), 0); + for (HashMap actions : one.getQuest().getObjectives().values()) { + for (QuestObjective obj : actions.values()) { + one.setAmountDone(obj, 0); } } } diff --git a/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java b/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java index 3250a2f7..9a5324a7 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java @@ -18,7 +18,7 @@ import com.gamingmesh.jobs.stuff.Util; public class ExploreManager { - private HashMap worlds = new HashMap<>(); + private final HashMap worlds = new HashMap<>(); private boolean exploreEnabled = false; private int playerAmount = 1; diff --git a/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java b/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java index 84656e8b..80721726 100644 --- a/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java @@ -21,13 +21,13 @@ import com.gamingmesh.jobs.hooks.HookManager; public class RestrictedAreaManager { - protected HashMap restrictedAreas = new HashMap<>(); + protected final HashMap restrictedAreas = new HashMap<>(); private boolean worldGuardArea = false; public boolean isExist(String name) { - for (Entry area : restrictedAreas.entrySet()) { - if (area.getKey().equalsIgnoreCase(name)) + for (String area : restrictedAreas.keySet()) { + if (area.equalsIgnoreCase(name)) return true; } return false; @@ -44,9 +44,9 @@ public class RestrictedAreaManager { } public void remove(String name) { - for (Entry area : restrictedAreas.entrySet()) { - if (area.getKey().equalsIgnoreCase(name)) { - restrictedAreas.remove(area.getKey()); + for (String area : restrictedAreas.keySet()) { + if (area.equalsIgnoreCase(name)) { + restrictedAreas.remove(area); break; } } @@ -120,9 +120,9 @@ public class RestrictedAreaManager { public synchronized List getRestrictedAreasByLoc(Location loc) { List areas = new ArrayList<>(); - for (Entry area : restrictedAreas.entrySet()) { - if (area.getValue().inRestrictedArea(loc)) - areas.add(area.getValue()); + for (RestrictedArea area : restrictedAreas.values()) { + if (area.inRestrictedArea(loc)) + areas.add(area); } if (worldGuardArea && HookManager.getWorldGuardManager() != null) diff --git a/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java b/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java index 0197ede8..6f16199e 100644 --- a/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java @@ -11,7 +11,7 @@ import com.gamingmesh.jobs.CMILib.ItemManager; public class RestrictedBlockManager { - public HashMap restrictedBlocksTimer = new HashMap<>(); + public final HashMap restrictedBlocksTimer = new HashMap<>(); /** * Method to load the restricted blocks configuration diff --git a/src/main/java/com/gamingmesh/jobs/config/TitleManager.java b/src/main/java/com/gamingmesh/jobs/config/TitleManager.java index 1a64c6b9..85f1e9dd 100644 --- a/src/main/java/com/gamingmesh/jobs/config/TitleManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/TitleManager.java @@ -13,7 +13,7 @@ import com.gamingmesh.jobs.stuff.ChatColor; public class TitleManager { - protected List titles = new ArrayList<>(); + protected final List<Title> titles = new ArrayList<>(); /** * Function to return the title for a given level diff --git a/src/main/java/com/gamingmesh/jobs/container/BlockProtection.java b/src/main/java/com/gamingmesh/jobs/container/BlockProtection.java index d5212dba..9e01296d 100644 --- a/src/main/java/com/gamingmesh/jobs/container/BlockProtection.java +++ b/src/main/java/com/gamingmesh/jobs/container/BlockProtection.java @@ -38,9 +38,7 @@ public class BlockProtection { } private static int convert(long time) { - if (time == -1L) - return -1; - return (int) ((time - pre) / 1000L); + return time == -1L ? -1 : (int) ((time - pre) / 1000L); } private static Long deconvert(Integer time) { @@ -48,10 +46,7 @@ public class BlockProtection { } public void setTime(Long time) { - if (time == -1) - this.time = null; - else - this.time = convert(time); + this.time = time == -1 ? null : convert(time); this.recorded = convert(System.currentTimeMillis()); } @@ -74,10 +69,7 @@ public class BlockProtection { } public void setPaid(Boolean paid) { - if (!paid) - this.paid = paid; - else - this.paid = null; + this.paid = !paid ? paid : null; } public void setRecorded(Long recorded) { diff --git a/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java b/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java index 259f4f34..25f12ca5 100644 --- a/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java +++ b/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java @@ -50,15 +50,11 @@ public class ExploreChunk { } public boolean isAlreadyVisited(int playerId) { - if (isFullyExplored()) - return true; - return playerIds.contains(playerId); + return isFullyExplored() ? true : playerIds.contains(playerId); } public int getCount() { - if (isFullyExplored()) - return Jobs.getExplore().getPlayerAmount(); - return playerIds.size(); + return isFullyExplored() ? Jobs.getExplore().getPlayerAmount() : playerIds.size(); } public int getX() { @@ -135,13 +131,10 @@ public class ExploreChunk { } public void setUpdated(boolean updated) { - if (!updated) - this.updated = null; - else - this.updated = true; + this.updated = !updated ? null : true; } public boolean isFullyExplored() { - return full == null ? false : full; + return full != null && full; } } diff --git a/src/main/java/com/gamingmesh/jobs/container/ExploreRegion.java b/src/main/java/com/gamingmesh/jobs/container/ExploreRegion.java index e3553e08..830af18a 100644 --- a/src/main/java/com/gamingmesh/jobs/container/ExploreRegion.java +++ b/src/main/java/com/gamingmesh/jobs/container/ExploreRegion.java @@ -8,7 +8,8 @@ public class ExploreRegion { int x; int z; - private HashMap<String, ExploreChunk> chunks = new HashMap<>(); + + private final HashMap<String, ExploreChunk> chunks = new HashMap<>(); public ExploreRegion(int x, int z) { this.x = x; diff --git a/src/main/java/com/gamingmesh/jobs/container/JobCommands.java b/src/main/java/com/gamingmesh/jobs/container/JobCommands.java index 0cd23210..6ed268c8 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobCommands.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobCommands.java @@ -23,7 +23,7 @@ import java.util.List; public class JobCommands { private String node; - private List<String> commands = new ArrayList<>(); + private final List<String> commands = new ArrayList<>(); private int levelFrom; private int levelUntil; diff --git a/src/main/java/com/gamingmesh/jobs/container/JobLimitedItems.java b/src/main/java/com/gamingmesh/jobs/container/JobLimitedItems.java index 69ca59ad..ff7d9a91 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobLimitedItems.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobLimitedItems.java @@ -23,12 +23,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; -import org.bukkit.ChatColor; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import com.gamingmesh.jobs.CMILib.CMIChatColor; import com.gamingmesh.jobs.CMILib.CMIMaterial; public class JobLimitedItems { @@ -66,11 +66,11 @@ public class JobLimitedItems { item.setAmount(amount); ItemMeta meta = item.getItemMeta(); if (this.name != null) - meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); + meta.setDisplayName(CMIChatColor.translate(name)); if (lore != null && !lore.isEmpty()) { List<String> TranslatedLore = new ArrayList<>(); for (String oneLore : lore) { - TranslatedLore.add(ChatColor.translateAlternateColorCodes('&', oneLore.replace("[player]", player.getName()))); + TranslatedLore.add(CMIChatColor.translate(oneLore.replace("[player]", player.getName()))); } meta.setLore(TranslatedLore); } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index cb57bff4..82a300b4 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -47,12 +47,12 @@ public class JobsPlayer { private String userName = "Unknown"; // progression of the player in each job public UUID playerUUID; - public ArrayList<JobProgression> progression = new ArrayList<>(); + public final ArrayList<JobProgression> progression = new ArrayList<>(); private ArchivedJobs archivedJobs = new ArchivedJobs(); private PaymentData paymentLimits; - private HashMap<String, ArrayList<BoostCounter>> boostCounter = new HashMap<>(); + private final HashMap<String, ArrayList<BoostCounter>> boostCounter = new HashMap<>(); // display honorific private String honorific; @@ -61,12 +61,12 @@ public class JobsPlayer { // player online status private volatile boolean isOnline = false; - private HashMap<CurrencyType, Integer> limits = new HashMap<>(); + private final HashMap<CurrencyType, Integer> limits = new HashMap<>(); private int userid = -1; - private List<BossBarInfo> barMap = new ArrayList<>(); - private List<String> updateBossBarFor = new ArrayList<>(); + private final List<BossBarInfo> barMap = new ArrayList<>(); + private final List<String> updateBossBarFor = new ArrayList<>(); // save lock // public final Object saveLock = new Object(); @@ -78,7 +78,7 @@ public class JobsPlayer { private HashMap<String, Boolean> permissionsCache; private Long lastPermissionUpdate = -1L; - private HashMap<String, HashMap<String, QuestProgression>> qProgression = new HashMap<>(); + private final HashMap<String, HashMap<String, QuestProgression>> qProgression = new HashMap<>(); private int doneQuests = 0; private int skippedQuests = 0; @@ -340,10 +340,8 @@ public class JobsPlayer { } public int getLimit(CurrencyType type) { - if (type == null) - return 0; - Integer value = limits.get(type); - return value == null ? 0 : value; + Integer value = type == null ? 0 : limits.get(type); + return value; } public void resetPaymentLimit() { diff --git a/src/main/java/com/gamingmesh/jobs/container/PlayerInfo.java b/src/main/java/com/gamingmesh/jobs/container/PlayerInfo.java index 8041c78f..001b9595 100644 --- a/src/main/java/com/gamingmesh/jobs/container/PlayerInfo.java +++ b/src/main/java/com/gamingmesh/jobs/container/PlayerInfo.java @@ -31,9 +31,7 @@ public class PlayerInfo { public String getName() { if (player == null) player = Jobs.getPlayerManager().getJobsPlayer(uuid); - if (player != null) - return player.getName(); - return name; + return player != null ? player.getName() : name; } public int getID() { diff --git a/src/main/java/com/gamingmesh/jobs/container/Quest.java b/src/main/java/com/gamingmesh/jobs/container/Quest.java index cc857e80..113c3b33 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Quest.java +++ b/src/main/java/com/gamingmesh/jobs/container/Quest.java @@ -5,7 +5,6 @@ import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map.Entry; import java.util.Set; import com.gamingmesh.jobs.Jobs; @@ -21,14 +20,14 @@ public class Quest { private Integer minLvl = null; private Integer maxLvl = null; - private List<String> rewardCmds = new ArrayList<>(); - private List<String> rewards = new ArrayList<>(); - private List<String> area = new ArrayList<>(); + private final List<String> rewardCmds = new ArrayList<>(); + private final List<String> rewards = new ArrayList<>(); + private final List<String> area = new ArrayList<>(); private boolean stopped = false; private HashMap<ActionType, HashMap<String, QuestObjective>> objectives = new HashMap<>(); - private Set<ActionType> actions = new HashSet<>(); + private final Set<ActionType> actions = new HashSet<>(); public Quest(String questName, Job job) { this.questName = questName; @@ -167,11 +166,10 @@ public class Quest { if (old == null) return false; - for (Entry<String, QuestObjective> one : old.entrySet()) { - if (one.getValue().getTargetId() == objective.getTargetId() && - one.getValue().getAction() == objective.getAction() && - objective.getAmount() == one.getValue().getAmount() && - objective.getTargetName() == one.getValue().getTargetName()) + for (QuestObjective one : old.values()) { + if (one.getTargetId() == objective.getTargetId() && + one.getAction() == objective.getAction() && objective.getAmount() == one.getAmount() + && objective.getTargetName() == one.getTargetName()) return true; } return false; @@ -179,9 +177,7 @@ public class Quest { public void setObjectives(HashMap<ActionType, HashMap<String, QuestObjective>> objectives) { this.objectives = objectives; - for (Entry<ActionType, HashMap<String, QuestObjective>> one : objectives.entrySet()) { - actions.add(one.getKey()); - } + objectives.keySet().forEach(actions::add); } public void addObjective(QuestObjective objective) { diff --git a/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java b/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java index 1222a400..1bf12a70 100644 --- a/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java +++ b/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java @@ -15,7 +15,7 @@ public class QuestProgression { private long validUntil; private boolean givenReward = false; - private HashMap<QuestObjective, Integer> done = new HashMap<>(); + private final HashMap<QuestObjective, Integer> done = new HashMap<>(); public QuestProgression(Quest quest) { this.quest = quest; @@ -34,9 +34,9 @@ public class QuestProgression { public int getTotalAmountNeeded() { int amountNeeded = 0; - for (Entry<ActionType, HashMap<String, QuestObjective>> oneA : quest.getObjectives().entrySet()) { - for (Entry<String, QuestObjective> one : oneA.getValue().entrySet()) { - amountNeeded += one.getValue().getAmount(); + for (HashMap<String, QuestObjective> oneA : quest.getObjectives().values()) { + for (QuestObjective one : oneA.values()) { + amountNeeded += one.getAmount(); } } return amountNeeded; @@ -44,9 +44,10 @@ public class QuestProgression { public int getTotalAmountDone() { int amountDone = 0; - for (Entry<QuestObjective, Integer> one : done.entrySet()) { - amountDone += one.getValue(); + for (Integer one : done.values()) { + amountDone += one; } + return amountDone; } @@ -77,10 +78,10 @@ public class QuestProgression { } public boolean isCompleted() { - for (Entry<ActionType, HashMap<String, QuestObjective>> oneA : quest.getObjectives().entrySet()) { - for (Entry<String, QuestObjective> one : oneA.getValue().entrySet()) { - Integer amountDone = done.get(one.getValue()); - if (amountDone == null || amountDone < one.getValue().getAmount()) + for (HashMap<String, QuestObjective> oneA : quest.getObjectives().values()) { + for (QuestObjective one : oneA.values()) { + Integer amountDone = done.get(one); + if (amountDone == null || amountDone < one.getAmount()) return false; } } @@ -99,7 +100,7 @@ public class QuestProgression { .containsKey(action.getName())) return; - if (quest.getRestrictedAreas() != null && !quest.getRestrictedAreas().isEmpty()) { + if (!quest.getRestrictedAreas().isEmpty()) { for (String area : quest.getRestrictedAreas()) { for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAres().entrySet()) { if (quest.getRestrictedAreas().contains(a.getKey()) && a.getKey().equalsIgnoreCase(area) diff --git a/src/main/java/com/gamingmesh/jobs/container/Schedule.java b/src/main/java/com/gamingmesh/jobs/container/Schedule.java index ed3154e4..eb248a86 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Schedule.java +++ b/src/main/java/com/gamingmesh/jobs/container/Schedule.java @@ -17,14 +17,14 @@ public class Schedule { private boolean nextDay = false; - private BoostMultiplier BM = new BoostMultiplier(); + private final BoostMultiplier BM = new BoostMultiplier(); private String Name = null; private List<String> Days = new ArrayList<>(Arrays.asList("all")); - private List<Job> JobsList = new ArrayList<>(); + private final List<Job> JobsList = new ArrayList<>(); - private List<String> MessageOnStart = new ArrayList<>(), + private final List<String> MessageOnStart = new ArrayList<>(), MessageOnStop = new ArrayList<>(), MessageToBroadcast = new ArrayList<>(); diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index fde49aeb..eee5e938 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -969,9 +969,9 @@ public abstract class JobsDAO { try { exploreStatement = conn.prepareStatement("UPDATE `" + DBTables.ExploreDataTable.getTableName() + "` SET `" + ExploreDataTableFields.worldid.getCollumn() + "` = ? WHERE `" + ExploreDataTableFields.worldname.getCollumn() + "` = ?;"); - for (Entry<String, JobsWorld> jobsWorld : Util.getJobsWorlds().entrySet()) { - exploreStatement.setInt(1, jobsWorld.getValue().getId()); - exploreStatement.setString(2, jobsWorld.getValue().getName()); + for (JobsWorld jobsWorld : Util.getJobsWorlds().values()) { + exploreStatement.setInt(1, jobsWorld.getId()); + exploreStatement.setString(2, jobsWorld.getName()); exploreStatement.execute(); } } catch (SQLException e) { @@ -984,9 +984,9 @@ public abstract class JobsDAO { try { exploreStatementBack = conn.prepareStatement("UPDATE `" + DBTables.ExploreDataTable.getTableName() + "` SET `" + ExploreDataTableFields.worldname.getCollumn() + "` = ? WHERE `" + ExploreDataTableFields.worldid.getCollumn() + "` = ?;"); - for (Entry<String, JobsWorld> jobsWorld : Util.getJobsWorlds().entrySet()) { - exploreStatementBack.setString(1, jobsWorld.getValue().getName()); - exploreStatementBack.setInt(2, jobsWorld.getValue().getId()); + for (JobsWorld jobsWorld : Util.getJobsWorlds().values()) { + exploreStatementBack.setString(1, jobsWorld.getName()); + exploreStatementBack.setInt(2, jobsWorld.getId()); exploreStatementBack.execute(); } } catch (SQLException e) { @@ -999,9 +999,9 @@ public abstract class JobsDAO { try { bpStatement = conn.prepareStatement("UPDATE `" + DBTables.BlocksTable.getTableName() + "` SET `" + BlockTableFields.worldid.getCollumn() + "` = ? WHERE `" + BlockTableFields.world .getCollumn() + "` = ?;"); - for (Entry<String, JobsWorld> jobsWorld : Util.getJobsWorlds().entrySet()) { - bpStatement.setInt(1, jobsWorld.getValue().getId()); - bpStatement.setString(2, jobsWorld.getValue().getName()); + for (JobsWorld jobsWorld : Util.getJobsWorlds().values()) { + bpStatement.setInt(1, jobsWorld.getId()); + bpStatement.setString(2, jobsWorld.getName()); bpStatement.execute(); } } catch (SQLException e) { @@ -1014,9 +1014,9 @@ public abstract class JobsDAO { try { bpStatementback = conn.prepareStatement("UPDATE `" + DBTables.BlocksTable.getTableName() + "` SET `" + BlockTableFields.world.getCollumn() + "` = ? WHERE `" + BlockTableFields.worldid .getCollumn() + "` = ?;"); - for (Entry<String, JobsWorld> jobsWorld : Util.getJobsWorlds().entrySet()) { - bpStatementback.setString(1, jobsWorld.getValue().getName()); - bpStatementback.setInt(2, jobsWorld.getValue().getId()); + for (JobsWorld jobsWorld : Util.getJobsWorlds().values()) { + bpStatementback.setString(1, jobsWorld.getName()); + bpStatementback.setInt(2, jobsWorld.getId()); bpStatementback.execute(); } } catch (SQLException e) { @@ -1997,8 +1997,7 @@ public abstract class JobsDAO { + "` = ? AND `" + LogTableFields.action.getCollumn() + "` = ? AND `" + LogTableFields.itemname.getCollumn() + "` = ?;"); boolean added = false; - for (Entry<String, Log> l : player.getLog().entrySet()) { - Log log = l.getValue(); + for (Log log : player.getLog().values()) { for (Entry<String, LogAmounts> one : log.getAmountList().entrySet()) { if (one.getValue().isNewEntry()) continue; @@ -2025,8 +2024,7 @@ public abstract class JobsDAO { + "` (`" + LogTableFields.userid.getCollumn() + "`, `" + LogTableFields.time.getCollumn() + "`, `" + LogTableFields.action.getCollumn() + "`, `" + LogTableFields.itemname.getCollumn() + "`, `" + LogTableFields.count.getCollumn() + "`, `" + LogTableFields.money.getCollumn() + "`, `" + LogTableFields.exp.getCollumn() + "`, `" + LogTableFields.points.getCollumn() + "`) VALUES (?, ?, ?, ?, ?, ?, ?, ?);"); - for (Entry<String, Log> l : player.getLog().entrySet()) { - Log log = l.getValue(); + for (Log log : player.getLog().values()) { for (Entry<String, LogAmounts> one : log.getAmountList().entrySet()) { if (!one.getValue().isNewEntry()) continue; @@ -2317,13 +2315,13 @@ public abstract class JobsDAO { int id = jobsWorld == null ? 0 : jobsWorld.getId(); if (id != 0) - for (Entry<String, ExploreChunk> oneChunk : worlds.getValue().getChunks().entrySet()) { - if (oneChunk.getValue().getDbId() != null) + for (ExploreChunk oneChunk : worlds.getValue().getChunks().values()) { + if (oneChunk.getDbId() != null) continue; prest2.setInt(1, id); - prest2.setInt(2, oneChunk.getValue().getX()); - prest2.setInt(3, oneChunk.getValue().getZ()); - prest2.setString(4, oneChunk.getValue().serializeNames()); + prest2.setInt(2, oneChunk.getX()); + prest2.setInt(3, oneChunk.getZ()); + prest2.setString(4, oneChunk.serializeNames()); prest2.setString(5, jobsWorld != null ? jobsWorld.getName() : ""); prest2.addBatch(); i++; @@ -2364,14 +2362,14 @@ public abstract class JobsDAO { HashMap<String, ExploreRegion> temp = new HashMap<>(Jobs.getExplore().getWorlds()); - for (Entry<String, ExploreRegion> worlds : temp.entrySet()) { - for (Entry<String, ExploreChunk> oneChunk : worlds.getValue().getChunks().entrySet()) { - if (oneChunk.getValue().getDbId() == null) + for (ExploreRegion worlds : temp.values()) { + for (ExploreChunk oneChunk : worlds.getChunks().values()) { + if (oneChunk.getDbId() == null) continue; - if (!oneChunk.getValue().isUpdated()) + if (!oneChunk.isUpdated()) continue; - prest.setString(1, oneChunk.getValue().serializeNames()); - prest.setInt(2, oneChunk.getValue().getDbId()); + prest.setString(1, oneChunk.serializeNames()); + prest.setInt(2, oneChunk.getDbId()); prest.addBatch(); i++; } diff --git a/src/main/java/com/gamingmesh/jobs/economy/PointsData.java b/src/main/java/com/gamingmesh/jobs/economy/PointsData.java index c04cee02..ffcf63a8 100644 --- a/src/main/java/com/gamingmesh/jobs/economy/PointsData.java +++ b/src/main/java/com/gamingmesh/jobs/economy/PointsData.java @@ -5,19 +5,17 @@ import java.util.UUID; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.container.PlayerPoints; +@Deprecated public class PointsData { - @Deprecated public void addPlayer(UUID uuid) { Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData(); } - @Deprecated public void addPlayer(UUID uuid, double points) { Jobs.getPlayerManager().getJobsPlayer(uuid).addPoints(points); } - @Deprecated public void addPlayer(UUID uuid, double points, double total) { addPlayer(uuid, new PlayerPoints(points, total)); @@ -25,7 +23,6 @@ public class PointsData { Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData().setTotalPoints(total); } - @Deprecated public void addPlayer(UUID uuid, PlayerPoints points) { PlayerPoints pi = Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData(); pi.setPoints(points.getCurrentPoints()); @@ -33,12 +30,10 @@ public class PointsData { pi.setNewEntry(points.isNewEntry()); } - @Deprecated public void addPoints(UUID uuid, Double points) { Jobs.getPlayerManager().getJobsPlayer(uuid).addPoints(points); } - @Deprecated public PlayerPoints getPlayerPointsInfo(UUID uuid) { return Jobs.getPlayerManager().getJobsPlayer(uuid).getPointsData(); } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index 9a5d827c..bfa85a12 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -496,10 +496,10 @@ public class JobsListener implements Listener { List<JobProgression> prog = JPlayer.getJobProgression(); mein: for (JobProgression one : prog) { - for (Entry<String, JobLimitedItems> oneItem : one.getJob().getLimitedItems().entrySet()) { - if (one.getLevel() >= oneItem.getValue().getLevel()) + for (JobLimitedItems oneItem : one.getJob().getLimitedItems().values()) { + if (one.getLevel() >= oneItem.getLevel()) continue; - if (!isThisItem(oneItem.getValue(), CMIMaterial.get(iih), name, lore, enchants)) + if (!isThisItem(oneItem, CMIMaterial.get(iih), name, lore, enchants)) continue; meinOk = one.getJob().getName(); break mein; diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 43e78696..96dc5279 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -376,8 +376,8 @@ public class JobsPaymentListener implements Listener { if (item != null && item.getType() != Material.AIR) { // Protection for block break with silktouch if (Jobs.getGCManager().useSilkTouchProtection) { - for (Entry<Enchantment, Integer> one : item.getEnchantments().entrySet()) { - if (CMIEnchantment.get(one.getKey()) == CMIEnchantment.SILK_TOUCH) { + for (Enchantment one : item.getEnchantments().keySet()) { + if (CMIEnchantment.get(one) == CMIEnchantment.SILK_TOUCH) { if (Jobs.getBpManager().isInBp(block)) return; } diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Loging.java b/src/main/java/com/gamingmesh/jobs/stuff/Loging.java index 4c3a071b..36b355fd 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Loging.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Loging.java @@ -1,7 +1,6 @@ package com.gamingmesh.jobs.stuff; import java.util.HashMap; -import java.util.Map.Entry; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.container.ActionInfo; @@ -18,8 +17,8 @@ public class Loging { public void recordToLog(JobsPlayer jPlayer, String ActionName, String item, HashMap<CurrencyType, Double> amounts) { HashMap<String, Log> logList = jPlayer.getLog(); Log l = null; - for (Entry<String, Log> one : logList.entrySet()) { - l = one.getValue(); + for (Log one : logList.values()) { + l = one; break; } if (l != null && Jobs.getScheduleManager().getDateByInt() != l.getDate()) { diff --git a/src/main/java/com/gamingmesh/jobs/stuff/TabComplete.java b/src/main/java/com/gamingmesh/jobs/stuff/TabComplete.java index 0b24d406..b4ccf654 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/TabComplete.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/TabComplete.java @@ -3,7 +3,6 @@ package com.gamingmesh.jobs.stuff; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -32,8 +31,8 @@ public class TabComplete implements TabCompleter { String PartOfCommand = args[0]; List<String> temp = new ArrayList<>(); - for (Entry<String, Integer> BCmd : Jobs.getCommandManager().GetCommands(sender).entrySet()) { - temp.add(BCmd.getKey()); + for (String BCmd : Jobs.getCommandManager().GetCommands(sender).keySet()) { + temp.add(BCmd); } StringUtil.copyPartialMatches(PartOfCommand, temp, completionList); } @@ -91,20 +90,20 @@ public class TabComplete implements TabCompleter { } break; case "[jobitemname]": - for (Entry<String, JobItems> one : ItemBoostManager.getItems().entrySet()) { - temp.add(one.getValue().getNode()); + for (JobItems one : ItemBoostManager.getItems().values()) { + temp.add(one.getNode()); } if (args.length > 3 && args[3].equalsIgnoreCase("limiteditems")) { Job oneJob = Jobs.getJob(args[i - 1]); if (oneJob != null) - for (Entry<String, JobLimitedItems> limitedItem : oneJob.getLimitedItems().entrySet()) { - temp.add(limitedItem.getValue().getNode()); + for (JobLimitedItems limitedItem : oneJob.getLimitedItems().values()) { + temp.add(limitedItem.getNode()); } } break; case "[boosteditems]": - for (Entry<String, JobItems> one : ItemBoostManager.getItems().entrySet()) { - temp.add(one.getValue().getNode()); + for (JobItems one : ItemBoostManager.getItems().values()) { + temp.add(one.getNode()); } break; case "[oldjob]": diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Util.java b/src/main/java/com/gamingmesh/jobs/stuff/Util.java index d2794098..1ad803d0 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Util.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Util.java @@ -9,7 +9,6 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map.Entry; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.UUID; @@ -179,9 +178,9 @@ public class Util { } public static JobsWorld getJobsWorld(int id) { - for (Entry<String, JobsWorld> one : jobsWorlds.entrySet()) { - if (one.getValue().getId() == id) - return one.getValue(); + for (JobsWorld one : jobsWorlds.values()) { + if (one.getId() == id) + return one; } return null; }