1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Get rid from storing job ids directly, now we uses the one from Job

This commit is contained in:
montlikadani 2021-04-11 15:22:05 +02:00
parent 9c0787c03d
commit bf1d0b7a01
2 changed files with 7 additions and 13 deletions

View File

@ -105,7 +105,6 @@ public class Jobs extends JavaPlugin {
private static List<Job> jobs;
private static Job noneJob;
private static Map<Job, Integer> usedSlots = new WeakHashMap<>();
private static Map<Integer, Job> 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<Integer, Job> getJobsIds() {
return jobsIds;
}
private void startup() {
reload(true);

View File

@ -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<String> getWorldBlacklist() {