From 4d11d4ef03c180bf0660c46e9c8d4167126b0097 Mon Sep 17 00:00:00 2001 From: Zrips Date: Thu, 16 Feb 2023 16:32:28 +0200 Subject: [PATCH] Option to add all bonuses --- src/main/java/com/gamingmesh/jobs/Jobs.java | 2 -- .../jobs/config/BlockProtectionManager.java | 1 - .../jobs/config/GeneralConfigManager.java | 6 ++++- .../jobs/config/NameTranslatorManager.java | 3 +-- .../gamingmesh/jobs/container/JobsPlayer.java | 25 ++++++++++++++++--- .../jobs/listeners/JobsPaymentListener.java | 6 ++--- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index d9e072df..bfcc9c01 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -997,8 +997,6 @@ public final class Jobs extends JavaPlugin { if (jPlayer == null) return; - CMIDebug.d("action"); - List progression = jPlayer.getJobProgression(); int numjobs = progression.size(); diff --git a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java index 931d6534..0fd7ed13 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java @@ -125,7 +125,6 @@ public class BlockProtectionManager { locations = new ConcurrentHashMap<>(); tempCache.put(loc.getWorld(), locations); } - CMIDebug.d("Cached"); locations.put(v, Bp); } diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index b954b986..cfa3afd7 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -95,7 +95,7 @@ public class GeneralConfigManager { SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames, PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps, informOnPaymentDisable, BrowseUseNewLook, payExploringWhenGliding = false, resetExploringData = false, disablePaymentIfMaxLevelReached, disablePaymentIfRiding, - boostedItemsInOffHand = false, boostedItemsInMainHand, boostedArmorItems, boostedItemsSlotSpecific, multiplyBoostedExtraValues/*, preventCropResizePayment*/, payItemDurabilityLoss, + boostedItemsInOffHand = false, boostedItemsInMainHand, boostedArmorItems, boostedItemsSlotSpecific, multiplyBoostedExtraValues, addPermissionBoost /*, preventCropResizePayment*/, payItemDurabilityLoss, applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useMinimumOveralExp, useBreederFinder, CancelCowMilking, fixAtMaxLevel, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAccountChat, @@ -493,6 +493,10 @@ public class GeneralConfigManager { "When set to true and for example nearSpawner set to -0.98 aka 2% of original payment with other bonuses which should double payment will result in you getting 4% instead of corrent 102% payment", "If set to false all bonus are sumed to one"); multiplyBoostedExtraValues = c.get("multiply-boosted-extra-values", false); + + c.addComment("add-permission-boost", "When enabled we will add all permission bonuses and penalties instead of picking highest one", + "This will add access to all permissions from jobs.boost.[jobName].[type].[amount] jobs.boost.all.[type].[amount] jobs.boost.[jobName].all.[amount] and jobs.boost.all.all.[amount] category"); + addPermissionBoost = c.get("add-permission-boost", false); // Better implementation? /*c.addComment("prevent-crop-resize-payment", "Do you want to prevent crop resizing payment when placing more cactus?", diff --git a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java index 2ff15cac..62959b50 100644 --- a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -42,8 +42,7 @@ public class NameTranslatorManager { public String translate(String materialName, ActionType action, int id, String meta, String name) { // Translating name to user friendly - if (materialName.toLowerCase().contains("arrow")) - CMIDebug.d(materialName, meta, Util.getPotionByName(meta)); + if (Jobs.getGCManager().UseCustomNames) switch (action) { case BREAK: diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index f228cd53..8ea2b36d 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -383,10 +383,29 @@ public class JobsPlayer { } private Double getPlayerBoostNew(String jobName, CurrencyType type) { - Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + "." + type.getName(), true, false); - Double boost = v1; - v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + ".all", false, false); + if (Jobs.getGCManager().addPermissionBoost) { + + Double boost = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + "." + type.getName(), true, true); + + Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + ".all", false, true); + if (v1 != 0d) + boost += v1; + + v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all.all", false, true); + if (v1 != 0d) + boost += v1; + + v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost.all." + type.getName(), false, true); + if (v1 != 0d) + boost += v1; + + return boost; + } + + Double boost = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + "." + type.getName(), true, false); + + Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + ".all", false, false); if (v1 != 0d && (v1 > boost || v1 < boost)) boost = v1; diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 3d7e5c7c..8eb06e19 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -434,12 +434,9 @@ public final class JobsPaymentListener implements Listener { if (Jobs.getGCManager().disablePaymentIfRiding && player.isInsideVehicle()) return; - CMIDebug.d("BlockBreakEvent2"); - // check if in creative if (!payIfCreative(player)) return; - CMIDebug.d("BlockBreakEvent3"); if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; @@ -1899,7 +1896,8 @@ public final class JobsPaymentListener implements Listener { } public static boolean payIfCreative(Player player) { - return player.getGameMode() != GameMode.CREATIVE || Jobs.getGCManager().payInCreative() || Jobs.getPermissionManager().hasPermission(Jobs.getPlayerManager().getJobsPlayer(player), "jobs.paycreative"); + return player.getGameMode() != GameMode.CREATIVE || Jobs.getGCManager().payInCreative() || Jobs.getPermissionManager().hasPermission(Jobs.getPlayerManager().getJobsPlayer(player), + "jobs.paycreative"); } // Prevent item durability loss