From b70bd4d49b459aaa67a1d767ea26cb871749130b Mon Sep 17 00:00:00 2001 From: Zrips Date: Mon, 28 Sep 2020 16:21:02 +0300 Subject: [PATCH] Adjusting permission requirements --- .../gamingmesh/jobs/PermissionManager.java | 2 +- .../jobs/Placeholders/Placeholder.java | 2 +- .../com/gamingmesh/jobs/PlayerManager.java | 28 +++++++++++-------- .../jobs/config/BlockProtectionManager.java | 13 ++++----- .../jobs/config/GeneralConfigManager.java | 19 +++++++------ .../gamingmesh/jobs/container/JobsPlayer.java | 2 -- .../jobs/listeners/JobsPaymentListener.java | 2 +- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/PermissionManager.java b/src/main/java/com/gamingmesh/jobs/PermissionManager.java index be6031a1..25150b4e 100644 --- a/src/main/java/com/gamingmesh/jobs/PermissionManager.java +++ b/src/main/java/com/gamingmesh/jobs/PermissionManager.java @@ -117,7 +117,7 @@ public class PermissionManager { } public Double getMaxPermission(JobsPlayer jPlayer, String perm) { - return getMaxPermission(jPlayer, perm, false); + return getMaxPermission(jPlayer, perm, false, false); } public Double getMaxPermission(JobsPlayer jPlayer, String perm, boolean force) { diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index a385f15b..5baf317a 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -554,7 +554,7 @@ public class Placeholder { return convert(true); case maxjobs: - int max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max", false, false).intValue(); + int max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max", false).intValue(); max = max == 0 ? Jobs.getGCManager().getMaxJobs() : max; return Integer.toString(max); diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index a994569d..da83c5c6 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -765,7 +765,7 @@ public class PlayerManager { for (JobCommands command : job.getCommands()) { if ((command.getLevelFrom() == 0 && command.getLevelUntil() == 0) || newLevel >= command.getLevelFrom() - && newLevel <= command.getLevelUntil()) { + && newLevel <= command.getLevelUntil()) { for (String commandString : new ArrayList(command.getCommands())) { commandString = commandString.replace("[player]", player.getName()); commandString = commandString.replace("[oldlevel]", String.valueOf(oldLevel)); @@ -783,7 +783,7 @@ public class PlayerManager { * @return True if he have permission */ public boolean getJobsLimit(JobsPlayer jPlayer, short currentCount) { - int max = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.max", false, false).intValue(); + int max = Jobs.getPermissionManager().getMaxPermission(jPlayer, "jobs.max", false).intValue(); max = max == 0 ? Jobs.getGCManager().getMaxJobs() : max; return max > currentCount; } @@ -958,19 +958,22 @@ public class PlayerManager { if (HookManager.getMcMMOManager().mcMMOPresent || HookManager.getMcMMOManager().mcMMOOverHaul) boost.add(BoostOf.McMMO, new BoostMultiplier().add(HookManager.getMcMMOManager().getMultiplier(player.getPlayer()))); + Double petPay = null; + if (ent instanceof Tameable) { Tameable t = (Tameable) ent; if (t.isTamed() && t.getOwner() instanceof Player) { - Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay"); - if (amount != null) - boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount)); + petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay"); + if (petPay != null) + boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); } } if (ent != null && HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(ent)) { - Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay"); - if (amount != null) - boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount)); + if (petPay == null) + petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay"); + if (petPay != null) + boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); } if (victim != null && victim.hasMetadata(getMobSpawnerMetadata())) { @@ -980,10 +983,11 @@ public class PlayerManager { } if (getall) { - Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force); - if (amount != null) - boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount)); - amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force); + if (petPay == null) + petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay", force); + if (petPay != null) + boost.add(BoostOf.PetPay, new BoostMultiplier().add(petPay)); + Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner", force); if (amount != null) boost.add(BoostOf.NearSpawner, new BoostMultiplier().add(amount)); } diff --git a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java index 96180767..34012fd2 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java @@ -150,20 +150,17 @@ public class BlockProtectionManager { HashMap chunk = region.get(locToChunk(loc)); if (chunk == null) return null; - String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ(); - return chunk.get(v); + return chunk.get(loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ()); } private static String locToChunk(Location loc) { - int x = (int) Math.floor(loc.getBlockX() / 16); - int z = (int) Math.floor(loc.getBlockZ() / 16); - return x + ":" + z; + return (int) Math.floor(loc.getBlockX() / 16D) + ":" + (int) Math.floor(loc.getBlockZ() / 16D); } private static String locToRegion(Location loc) { - int x = (int) Math.floor(loc.getBlockX() / 16); - int z = (int) Math.floor(loc.getBlockZ() / 16); - return (int) Math.floor(x / 32) + ":" + (int) Math.floor(z / 32); + int x = (int) Math.floor(loc.getBlockX() / 16D); + int z = (int) Math.floor(loc.getBlockZ() / 16D); + return (int) Math.floor(x / 32D) + ":" + (int) Math.floor(z / 32D); } public Integer getBlockDelayTime(Block block) { diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 1999758b..d2ffd510 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -50,7 +50,8 @@ public class GeneralConfigManager { /** * @deprecated use {@link ScheduleManager} */ - @Deprecated public List BoostSchedule = new ArrayList<>(); + @Deprecated + public List BoostSchedule = new ArrayList<>(); public final HashMap> whiteListedItems = new HashMap<>(); private final HashMap currencyLimitUse = new HashMap<>(); @@ -61,21 +62,21 @@ public class GeneralConfigManager { private ConfigReader c = null; protected boolean economyAsync, isBroadcastingSkillups, isBroadcastingLevelups, payInCreative, payExploringWhenFlying, - addXpPlayer, hideJobsWithoutPermission, payNearSpawner, modifyChat, saveOnDisconnect, MultiServerCompatability; + addXpPlayer, hideJobsWithoutPermission, payNearSpawner, modifyChat, saveOnDisconnect, MultiServerCompatability; public String modifyChatPrefix, modifyChatSuffix, modifyChatSeparator, FireworkType, SoundLevelupSound, - SoundTitleChangeSound, ServerAccountName, ServertaxesAccountName, localeString = ""; + SoundTitleChangeSound, ServerAccountName, ServertaxesAccountName, localeString = ""; private String getSelectionTool, DecimalPlacesMoney, DecimalPlacesExp, DecimalPlacesPoints; public int jobExpiryTime, BlockProtectionDays, FireworkPower, ShootTime, - globalblocktimer, CowMilkingTimer, InfoUpdateInterval, JobsTopAmount, PlaceholdersPage, ConfirmExpiryTime, - SegmentCount, BossBarTimer, AutoJobJoinDelay, DBCleaningJobsLvl, DBCleaningUsersDays, BlastFurnacesMaxDefault, SmokersMaxDefault; + globalblocktimer, CowMilkingTimer, InfoUpdateInterval, JobsTopAmount, PlaceholdersPage, ConfirmExpiryTime, + SegmentCount, BossBarTimer, AutoJobJoinDelay, DBCleaningJobsLvl, DBCleaningUsersDays, BlastFurnacesMaxDefault, SmokersMaxDefault; protected int savePeriod, maxJobs, economyBatchDelay; private int ResetTimeHour, ResetTimeMinute, DailyQuestsSkips, FurnacesMaxDefault, BrewingStandsMaxDefault, - BrowseAmountToShow, JobsGUIRows, JobsGUIBackButton, JobsGUINextButton, JobsGUIStartPosition, JobsGUIGroupAmount, JobsGUISkipAmount; + BrowseAmountToShow, JobsGUIRows, JobsGUIBackButton, JobsGUINextButton, JobsGUIStartPosition, JobsGUIGroupAmount, JobsGUISkipAmount; public double skipQuestCost, MinimumOveralPaymentLimit, MinimumOveralPointsLimit, MonsterDamagePercentage, - DynamicPaymentMaxPenalty, DynamicPaymentMaxBonus, TaxesAmount; + DynamicPaymentMaxPenalty, DynamicPaymentMaxBonus, TaxesAmount; public Double TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier; @@ -90,8 +91,8 @@ public class GeneralConfigManager { SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames, PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps, BrowseUseNewLook, payExploringWhenGliding, disablePaymentIfMaxLevelReached, disablePaymentIfRiding, - boostedItemsInOffHand, preventCropResizePayment, payItemDurabilityLoss, - applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useBreederFinder = false, + boostedItemsInOffHand, preventCropResizePayment, payItemDurabilityLoss, + applyToNegativeIncome, useMinimumOveralPayment, useMinimumOveralPoints, useBreederFinder = false, CancelCowMilking, fixAtMaxLevel, TitleChangeChat, TitleChangeActionBar, LevelChangeChat, LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAccountChat, EmptyServerAccountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 8d0a1df3..536435c4 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -926,8 +926,6 @@ public class JobsPlayer { if (qProgression.containsKey(job.getName())) { qProgression.remove(job.getName()); } - - oneQ.getQuest().setObjectives(null); } } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index f58a93aa..ea28939d 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -1776,7 +1776,7 @@ public class JobsPaymentListener implements Listener { return true; for (Entry oneG : got.entrySet()) { - if (!hand.getEnchantments().containsKey(oneG.getKey()) || hand.getEnchantments().get(oneG.getKey()) != oneG.getValue()) + if (!hand.getEnchantments().containsKey(oneG.getKey()) || hand.getEnchantments().get(oneG.getKey()).equals(oneG.getValue())) return false; }