diff --git a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java index cfb1e985..f0a1fbc3 100644 --- a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java +++ b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java @@ -5,7 +5,6 @@ import java.util.Arrays; import java.util.List; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -97,7 +96,7 @@ public class GuiManager { Job job = jobsList.get(i); List lore = new ArrayList<>(); - for (JobProgression onePJob : jPlayer.progression) { + for (JobProgression onePJob : jPlayer.getJobProgression()) { if (onePJob.getJob().getName().equalsIgnoreCase(job.getName())) { lore.add(Jobs.getLanguage().getMessage("command.info.gui.working")); break; @@ -272,7 +271,7 @@ public class GuiManager { ItemStack guiItem = job.getGuiItem().clone(); int level = prog != null ? prog.getLevel() : 1; - int numjobs = jPlayer.progression.size(); + int numjobs = jPlayer.getJobProgression().size(); int nextButton = Jobs.getGCManager().getJobsGUINextButton(); int backButton = Jobs.getGCManager().getJobsGUIBackButton(); @@ -488,7 +487,7 @@ public class GuiManager { JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); Boost boost = Jobs.getPlayerManager().getFinalBonus(jPlayer, job); - int numjobs = jPlayer.progression.size(); + int numjobs = jPlayer.getJobProgression().size(); int level = jPlayer.getJobProgression(job) != null ? jPlayer.getJobProgression(job).getLevel() : 1; ItemStack guiItem = job.getGuiItem().clone(); @@ -510,15 +509,15 @@ public class GuiManager { double income = jInfo.getIncome(level, numjobs, jPlayer.maxJobsEquation); income = boost.getFinalAmount(CurrencyType.MONEY, income); - String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString(); + String incomeColor = income >= 0 ? "" : CMIChatColor.DARK_RED.toString(); double xp = jInfo.getExperience(level, numjobs, jPlayer.maxJobsEquation); xp = boost.getFinalAmount(CurrencyType.EXP, xp); - String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString(); + String xpColor = xp >= 0 ? "" : CMIChatColor.GRAY.toString(); double points = jInfo.getPoints(level, numjobs, jPlayer.maxJobsEquation); points = boost.getFinalAmount(CurrencyType.POINTS, points); - String pointsColor = points >= 0 ? "" : ChatColor.RED.toString(); + String pointsColor = points >= 0 ? "" : CMIChatColor.RED.toString(); if (income == 0D && points == 0D && xp == 0D) continue; diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index 0c1ed2e3..038e26ea 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -382,7 +382,7 @@ public class Placeholder { try { int id = Integer.parseInt(value); if (id > 0) - return user.progression.get(id - 1); + return user.getJobProgression().get(id - 1); } catch (IndexOutOfBoundsException | NumberFormatException e) { Job job = Jobs.getJob(value); if (job != null) @@ -465,18 +465,18 @@ public class Placeholder { case user_displayhonorific: return user.getDisplayHonorific(); case user_joinedjobcount: - return Integer.toString(user.progression.size()); + return Integer.toString(user.getJobProgression().size()); case user_archived_jobs: return Integer.toString(user.getArchivedJobs().getArchivedJobs().size()); case user_jobs: StringBuilder jobNames = new StringBuilder(); - for (JobProgression prog : user.progression) { + for (JobProgression prog : user.getJobProgression()) { if (!jobNames.toString().isEmpty()) { jobNames.append(LC.info_ListSpliter.getLocale()); } jobNames.append(prog.getJob().getDisplayName()); } - if (user.progression.isEmpty()) { + if (user.getJobProgression().isEmpty()) { if (Jobs.getNoneJob() != null) jobNames.append(Jobs.getNoneJob().getDisplayName()); } @@ -579,7 +579,7 @@ public class Placeholder { if (!Jobs.getCommandManager().hasJobPermission(player, job) || user.isInJob(job) || job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots() || - !job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(user, (short) user.progression.size())) + !job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(user, (short) user.getJobProgression().size())) return convert(false); return convert(true); diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index 87913c5d..085871ba 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -325,7 +325,7 @@ public class PlayerManager { if (!resetID && jPlayer.getUserId() == -1) continue; - for (JobProgression oneJ : jPlayer.progression) + for (JobProgression oneJ : jPlayer.getJobProgression()) dao.insertJob(jPlayer, oneJ); dao.saveLog(jPlayer); @@ -547,7 +547,7 @@ public class PlayerManager { * @param jPlayer {@link JobsPlayer} */ public void leaveAllJobs(JobsPlayer jPlayer) { - for (JobProgression job : new ArrayList<>(jPlayer.progression)) + for (JobProgression job : new ArrayList<>(jPlayer.getJobProgression())) leaveJob(jPlayer, job.getJob()); jPlayer.leaveAllJobs(); @@ -976,7 +976,7 @@ public class PlayerManager { */ public void reload() { for (JobsPlayer jPlayer : playersUUID.values()) { - for (JobProgression progression : jPlayer.progression) { + for (JobProgression progression : jPlayer.getJobProgression()) { Job job = Jobs.getJob(progression.getJob().getName()); if (job != null) progression.setJob(job); @@ -1193,13 +1193,13 @@ public class PlayerManager { return; int playerMaxJobs = getMaxJobs(jPlayer); - int playerCurrentJobs = jPlayer.progression.size(); + int playerCurrentJobs = jPlayer.getJobProgression().size(); if (playerMaxJobs == 0 || playerMaxJobs != -1 && playerCurrentJobs >= playerMaxJobs) return; for (Job one : Jobs.getJobs()) { - if (playerMaxJobs != -1 && jPlayer.progression.size() >= playerMaxJobs) + if (playerMaxJobs != -1 && jPlayer.getJobProgression().size() >= playerMaxJobs) return; if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots()) diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index 70f75052..4fe0baf9 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -364,7 +364,7 @@ public class JobsCommands implements CommandExecutor { } int level = prog != null ? prog.getLevel() : 1; - int numjobs = player.progression.size(); + int numjobs = player.getJobCount(); for (JobInfo info : job.getJobInfo(type)) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/fireall.java b/src/main/java/com/gamingmesh/jobs/commands/list/fireall.java index 26935030..7e40e5c0 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/fireall.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/fireall.java @@ -48,7 +48,7 @@ public class fireall implements Cmd { return true; } - if (jPlayer.progression.isEmpty()) { + if (jPlayer.getJobProgression().isEmpty()) { Language.sendMessage(sender, "command.fireall.error.nojobs"); return true; } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/join.java b/src/main/java/com/gamingmesh/jobs/commands/list/join.java index 113ef57e..10bd4a79 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/join.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/join.java @@ -66,8 +66,8 @@ public class join implements Cmd { Language.sendMessage(sender, "command.join.error.fullslots", "%jobname%", job.getDisplayName()); return true; } - - if (!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.progression.size())) { + + if (!job.isIgnoreMaxJobs() && !Jobs.getPlayerManager().getJobsLimit(jPlayer, (short) jPlayer.getJobCount(false))) { Language.sendMessage(sender, "command.join.error.maxjobs"); return true; } 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 a8e49c1d..a4b56940 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/quests.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/quests.java @@ -89,7 +89,7 @@ public class quests implements Cmd { Language.sendMessage(sender, "command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests()); - for (JobProgression jobProg : jPlayer.progression) { + for (JobProgression jobProg : jPlayer.getJobProgression()) { List list = jPlayer.getQuestProgressions(jobProg.getJob()); for (QuestProgression q : list) { @@ -171,7 +171,7 @@ public class quests implements Cmd { gui.addLock(InvType.Gui); gui.addLock(InvType.Main); - for (JobProgression jobProg : jPlayer.progression) { + for (JobProgression jobProg : jPlayer.getJobProgression()) { List list = jPlayer.getQuestProgressions(jobProg.getJob()); for (QuestProgression q : list) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/stats.java b/src/main/java/com/gamingmesh/jobs/commands/list/stats.java index 16d6e018..a0da689d 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/stats.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/stats.java @@ -35,7 +35,7 @@ public class stats implements Cmd { return true; } - if (jPlayer.progression.isEmpty()) { + if (jPlayer.getJobProgression().isEmpty()) { Language.sendMessage(sender, "command.stats.error.nojob"); return true; } diff --git a/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java b/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java index 06db254a..6ca39104 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java @@ -27,7 +27,7 @@ public class BossBarManager { if (Version.getCurrent().isLower(Version.v1_9_R1) || player == null) return; - for (JobProgression oneJob : player.progression) { + for (JobProgression oneJob : player.getJobProgression()) { if (oneJob.getLastExperience() != 0) { ShowJobProgression(player, oneJob, oneJob.getLastExperience()); } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java index 247e3ac9..47350797 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java @@ -168,14 +168,14 @@ public class JobProgression { public void reloadMaxExperience() { Map param = new HashMap<>(); param.put("joblevel", (double) level); - param.put("numjobs", (double) jPlayer.progression.size()); + param.put("numjobs", (double) jPlayer.getJobProgression().size()); maxExperience = (int) job.getMaxExp(param); } public int getMaxExperience(int level) { Map param = new HashMap<>(); param.put("joblevel", (double) level); - param.put("numjobs", (double) jPlayer.progression.size()); + param.put("numjobs", (double) jPlayer.getJobProgression().size()); return (int) job.getMaxExp(param); } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index a2a1d058..d98950c3 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -46,7 +46,6 @@ import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Container.CMINumber; import net.Zrips.CMILib.Equations.Parser; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Time.CMITimeManager; import net.Zrips.CMILib.Version.Schedulers.CMIScheduler; import net.Zrips.CMILib.Version.Schedulers.CMITask; @@ -476,6 +475,24 @@ public class JobsPlayer { return Collections.unmodifiableList(progression); } + public int getJobCount() { + return getJobCount(true); + } + public int getJobCount(boolean includeIgnoredMaxJobs) { + + if (includeIgnoredMaxJobs) + return progression.size(); + + int count = 0; + for (JobProgression one : progression) { + if (one.getJob().isIgnoreMaxJobs()) + continue; + count++; + } + + return count; + } + /** * Get the job progression from the certain job *