From 54fde9353fa1e2e4d80835c01d69827f44de1ade Mon Sep 17 00:00:00 2001 From: montlikadani Date: Sat, 5 Sep 2020 16:40:41 +0200 Subject: [PATCH] Another fix for max jobs --- .../com/gamingmesh/jobs/PermissionManager.java | 6 ++++-- .../com/gamingmesh/jobs/commands/list/join.java | 3 +-- .../com/gamingmesh/jobs/config/ShopManager.java | 15 +++++---------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/PermissionManager.java b/src/main/java/com/gamingmesh/jobs/PermissionManager.java index dc150593..10dcce5f 100644 --- a/src/main/java/com/gamingmesh/jobs/PermissionManager.java +++ b/src/main/java/com/gamingmesh/jobs/PermissionManager.java @@ -147,8 +147,10 @@ public class PermissionManager { } catch (NumberFormatException e) { } - if (uno.contains("max") && amount < t) { - amount = t; + if (uno.startsWith("jobs.max")) { + if (amount == 0D || t > amount) { + amount = t; + } } else { amount += t; } 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 cc4c2b5a..b10b4251 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/join.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/join.java @@ -58,9 +58,8 @@ public class join implements Cmd { return true; } - int confMaxJobs = Jobs.getGCManager().getMaxJobs(); short PlayerMaxJobs = (short) jPlayer.getJobProgression().size(); - if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(jPlayer, PlayerMaxJobs)) { + if (!Jobs.getPlayerManager().getJobsLimit(jPlayer, PlayerMaxJobs)) { pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.maxjobs")); return true; } diff --git a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java index eebdb612..ece6d8c2 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java @@ -132,7 +132,7 @@ public class ShopManager { } if (item.isHideIfNoEnoughPoints() && item.getRequiredTotalLevels() != -1 && - Jobs.getPlayerManager().getJobsPlayer(player).getTotalLevels() < item.getRequiredTotalLevels()) { + jPlayer.getTotalLevels() < item.getRequiredTotalLevels()) { mat = CMIMaterial.STONE_BUTTON; Lore.add(Jobs.getLanguage().getMessage("command.shop.info.NoPoints")); } @@ -164,7 +164,7 @@ public class ShopManager { String jobColor = ""; String levelColor = ""; - JobProgression prog = Jobs.getPlayerManager().getJobsPlayer(player).getJobProgression(job); + JobProgression prog = jPlayer.getJobProgression(job); if (prog == null) { jobColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsColor"); levelColor = Jobs.getLanguage().getMessage("command.shop.info.reqJobsLevelColor"); @@ -180,7 +180,7 @@ public class ShopManager { if (item.getRequiredTotalLevels() != -1) { Lore.add(Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevel", - "%totalLevel%", (Jobs.getPlayerManager().getJobsPlayer(player).getTotalLevels() < item.getRequiredTotalLevels() + "%totalLevel%", (jPlayer.getTotalLevels() < item.getRequiredTotalLevels() ? Jobs.getLanguage().getMessage("command.shop.info.reqTotalLevelColor") : "") + item.getRequiredTotalLevels())); } @@ -195,7 +195,7 @@ public class ShopManager { skullMeta.setLore(Lore); if (item.isHeadOwner()) { - Jobs.getNms().setSkullOwner(skullMeta, Jobs.getPlayerManager().getJobsPlayer(player).getPlayer()); + Jobs.getNms().setSkullOwner(skullMeta, jPlayer.getPlayer()); } else { @SuppressWarnings("deprecation") OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(item.getCustomHead()); @@ -214,10 +214,6 @@ public class ShopManager { } } - JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); - if (jPlayer == null) - return; - for (Entry oneJob : item.getRequiredJobs().entrySet()) { Job tempJob = Jobs.getJob(oneJob.getKey()); if (tempJob == null) @@ -254,8 +250,7 @@ public class ShopManager { } for (JobItems one : item.getitems()) { - ItemStack itemStack = one.getItemStack(player); - GiveItem.GiveItemForPlayer(player, itemStack); + GiveItem.GiveItemForPlayer(player, one.getItemStack(player)); } pointsInfo.takePoints(item.getPrice());