diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 656a38ad..d34fa186 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -599,7 +599,7 @@ public class ConfigManager { int amount = 10; try { - amount = Integer.valueOf(myKey); + amount = Integer.valueOf(myKey); } catch (NumberFormatException e) { Jobs.getPluginLogger().warning("Job " + jobName + " has an invalid " + actionType.getName() + " type property: " + myKey + "!"); return null; diff --git a/src/main/java/com/gamingmesh/jobs/container/CurrencyLimit.java b/src/main/java/com/gamingmesh/jobs/container/CurrencyLimit.java index 2e870d68..ff47304e 100644 --- a/src/main/java/com/gamingmesh/jobs/container/CurrencyLimit.java +++ b/src/main/java/com/gamingmesh/jobs/container/CurrencyLimit.java @@ -1,5 +1,6 @@ package com.gamingmesh.jobs.container; +import java.util.ArrayList; import java.util.List; import com.gamingmesh.jobs.resources.jfep.Parser; @@ -14,10 +15,12 @@ public class CurrencyLimit { public CurrencyLimit(boolean enabled, List stopWith, int timeLimit, int announcementDelay, Parser maxEquation) { this.enabled = enabled; - this.stopWith = stopWith; + this.stopWith = stopWith == null ? new ArrayList<>() : stopWith; this.timeLimit = timeLimit; this.announcementDelay = announcementDelay; - this.maxEquation = maxEquation; + + if (maxEquation != null) + this.maxEquation = maxEquation; } public CurrencyLimit() { @@ -36,7 +39,7 @@ public class CurrencyLimit { } public void setStopWith(List stopWith) { - this.stopWith = stopWith; + this.stopWith = stopWith == null ? new ArrayList<>() : stopWith; } public int getTimeLimit() { @@ -60,7 +63,8 @@ public class CurrencyLimit { } public void setMaxEquation(Parser maxEquation) { - this.maxEquation = maxEquation; + if (maxEquation != null) + this.maxEquation = maxEquation; } } diff --git a/src/main/java/com/gamingmesh/jobs/container/Job.java b/src/main/java/com/gamingmesh/jobs/container/Job.java index 9effd2ba..91310725 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Job.java +++ b/src/main/java/com/gamingmesh/jobs/container/Job.java @@ -33,6 +33,8 @@ import org.bukkit.inventory.ItemStack; import java.util.*; import java.util.function.BiPredicate; +import javax.swing.Box.Filler; + public class Job { private EnumMap> jobInfo = new EnumMap<>(ActionType.class); @@ -150,6 +152,10 @@ public class Job { public void updateTotalPlayers() { totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(jobName); + if (totalPlayers <= 0) { + totalPlayers = Jobs.getJobsDAO().getTotalPlayerAmountByJobName(fullName); + } + updateBonus(); } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 803e3ca2..ec172f35 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -49,7 +49,7 @@ public class JobsPlayer { public ArrayList progression = new ArrayList<>(); private ArchivedJobs archivedJobs = new ArchivedJobs(); - private PaymentData paymentLimits = null; + private PaymentData paymentLimits; private HashMap> boostCounter = new HashMap<>(); @@ -74,7 +74,7 @@ public class JobsPlayer { private Long seen = System.currentTimeMillis(); - private HashMap permissionsCache = null; + private HashMap permissionsCache; private Long lastPermissionUpdate = -1L; private HashMap> qProgression = new HashMap<>(); @@ -83,7 +83,7 @@ public class JobsPlayer { private final HashMap> leftTimes = new HashMap<>(); - private PlayerPoints pointsData = null; + private PlayerPoints pointsData; public JobsPlayer(String userName) { this.userName = userName == null ? "Unknown" : userName; @@ -234,10 +234,7 @@ public class JobsPlayer { * @return the player */ public Player getPlayer() { - if (playerUUID != null) - return Bukkit.getPlayer(playerUUID); - - return null; + return playerUUID != null ? Bukkit.getPlayer(playerUUID) : null; } /** @@ -890,16 +887,12 @@ public class JobsPlayer { return ls; HashMap qpl = qProgression.get(job.getName()); - if (qpl == null) return ls; for (Entry one : qpl.entrySet()) { QuestProgression prog = one.getValue(); - if (prog.isEnded()) - continue; - - if (prog.getQuest() == null) + if (prog.isEnded() || prog.getQuest() == null) continue; for (Entry> oneAction : prog.getQuest().getObjectives().entrySet()) { @@ -948,7 +941,6 @@ public class JobsPlayer { HashMap orprog = qProgression.get(quest.getJob().getName()); Quest q = quest.getJob().getNextQuest(getQuestNameList(quest.getJob(), null), getJobProgression(quest.getJob()).getLevel()); - if (q == null) { for (JobProgression one : this.getJobProgression()) { if (one.getJob().isSame(quest.getJob())) @@ -1211,8 +1203,7 @@ public class JobsPlayer { if (maxV == null || maxV == 0) maxV = (double) Jobs.getGCManager().getBrewingStandsMaxDefault(); - int max = maxV.intValue(); - return max; + return maxV.intValue(); } public int getMaxFurnacesAllowed() { @@ -1221,9 +1212,7 @@ public class JobsPlayer { if (maxV == null || maxV == 0) maxV = (double) Jobs.getGCManager().getFurnacesMaxDefault(); - int max = maxV.intValue(); - - return max; + return maxV.intValue(); } public int getSkippedQuests() { @@ -1244,10 +1233,7 @@ public class JobsPlayer { return false; HashMap map = leftTimes.get(uuid); - if (!map.containsKey(job)) - return false; - - return map.get(job).longValue() < System.currentTimeMillis(); + return map.containsKey(job) && map.get(job).longValue() < System.currentTimeMillis(); } public void setLeftTime(Job job) { diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index 0ba50974..fde49aeb 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -1192,7 +1192,7 @@ public abstract class JobsDAO { ResultSet res = null; try { Job job = Jobs.getJob(JobName); - if (job != null) { + if (job != null && job.getId() != 0) { prest = conn.prepareStatement("SELECT COUNT(*) FROM `" + getJobsTableName() + "` WHERE `" + JobsTableFields.jobid + "` = ?;"); prest.setInt(1, job.getId()); res = prest.executeQuery();