From 51ad48fdef73b1fb5ff2c193562e08a78c801a78 Mon Sep 17 00:00:00 2001 From: Zrips Date: Mon, 21 Jun 2021 17:35:40 +0300 Subject: [PATCH] Optimizing permission check --- src/main/java/com/gamingmesh/jobs/PermissionManager.java | 1 + .../com/gamingmesh/jobs/listeners/JobsPaymentListener.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/PermissionManager.java b/src/main/java/com/gamingmesh/jobs/PermissionManager.java index f64f3711..69f687e7 100644 --- a/src/main/java/com/gamingmesh/jobs/PermissionManager.java +++ b/src/main/java/com/gamingmesh/jobs/PermissionManager.java @@ -37,6 +37,7 @@ public class PermissionManager { private enum prm { // jobs_join_JOBNAME(remade("jobs.join.%JOBNAME%"), 60 * 1000), jobs_use(remade("jobs.use"), 2), + jobs_paycreative(remade("jobs.paycreative"), 2), // jobs_boost_JOBNAME_money(remade("jobs.boost.%JOBNAME%.money"), 60 * 1000), // jobs_boost_JOBNAME_exp(remade("jobs.boost.%JOBNAME%.exp"), 60 * 1000), // jobs_boost_JOBNAME_points(remade("jobs.boost.%JOBNAME%.points"), 60 * 1000), diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 35fa7f53..bb40b1ea 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -122,6 +122,7 @@ import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Entities.CMIEntityType; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Version.Version; public final class JobsPaymentListener implements Listener { @@ -423,7 +424,6 @@ public final class JobsPaymentListener implements Listener { } Jobs.FASTPAYMENT.remove(player.getUniqueId()); } - if (!payForItemDurabilityLoss(player)) return; @@ -1728,8 +1728,10 @@ public final class JobsPaymentListener implements Listener { } public static boolean payIfCreative(Player player) { - if (!Jobs.getGCManager().payInCreative() && player.getGameMode() == GameMode.CREATIVE && !player.hasPermission("jobs.paycreative")) + if (!Jobs.getGCManager().payInCreative() && player.getGameMode() == GameMode.CREATIVE && !Jobs.getPermissionManager().hasPermission(Jobs.getPlayerManager().getJobsPlayer(player), + "jobs.paycreative")) { return false; + } return true; }