From bf1d0b7a019b701dd562187f659c102f75be38ed Mon Sep 17 00:00:00 2001 From: montlikadani Date: Sun, 11 Apr 2021 15:22:05 +0200 Subject: [PATCH] Get rid from storing job ids directly, now we uses the one from Job --- src/main/java/com/gamingmesh/jobs/Jobs.java | 16 +++++++--------- .../java/com/gamingmesh/jobs/container/Job.java | 4 ---- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 6b76822f..f9e18d6a 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -105,7 +105,6 @@ public class Jobs extends JavaPlugin { private static List jobs; private static Job noneJob; private static Map usedSlots = new WeakHashMap<>(); - private static Map jobsIds = new HashMap<>(); public static BufferedPaymentThread paymentThread; private static DatabaseSaveThread saveTask; @@ -478,20 +477,19 @@ public class Jobs extends JavaPlugin { * @return {@link Job} */ public static Job getJob(int id) { - return jobsIds.get(id); + for (Job job : jobs) { + if (job.getId() == id) { + return job; + } + } + + return null; } public boolean isPlaceholderAPIEnabled() { return placeholderAPIEnabled; } - /** - * @return the cached job id map. - */ - public static Map getJobsIds() { - return jobsIds; - } - private void startup() { reload(true); diff --git a/src/main/java/com/gamingmesh/jobs/container/Job.java b/src/main/java/com/gamingmesh/jobs/container/Job.java index 45907d0d..b5e0ed05 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Job.java +++ b/src/main/java/com/gamingmesh/jobs/container/Job.java @@ -579,11 +579,7 @@ public class Job { } public void setId(int id) { - Jobs.getJobsIds().remove(this.id); - this.id = id; - if (id != 0) - Jobs.getJobsIds().put(id, this); } public List getWorldBlacklist() {