From e2b8924c22aabdf535a9e775b65704ccdb7604ee Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Thu, 30 Jul 2020 02:58:35 -0400 Subject: [PATCH] Disable Compass if player has WorldEdit jumpto permission --- .../main/java/me/blackvein/quests/Quester.java | 15 ++++++++++++--- .../quests/listeners/PlayerListener.java | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index 879e1d1e0..b2732cd83 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -3817,6 +3817,15 @@ public class Quester { ex.printStackTrace(); } } + + public boolean canUseCompass() { + if (!getPlayer().hasPermission("worldedit.navigation.jumpto")) { + if (getPlayer().hasPermission("quests.compass")) { + return true; + } + } + return false; + } /** * Reset compass target to Quester's bed spawn location
@@ -3828,7 +3837,7 @@ public class Quester { if (player == null) { return; } - if (!getPlayer().hasPermission("quests.compass")) { + if (!canUseCompass()) { return; } @@ -3846,7 +3855,7 @@ public class Quester { * Update compass target to current stage of first available current quest, if possible */ public void findCompassTarget() { - if (!getPlayer().hasPermission("quests.compass")) { + if (!canUseCompass()) { return; } for (Quest quest : currentQuests.keySet()) { @@ -3863,7 +3872,7 @@ public class Quester { * @param notify Whether to notify this quester of result */ public void findNextCompassTarget(boolean notify) { - if (!getPlayer().hasPermission("quests.compass")) { + if (!canUseCompass()) { return; } Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { diff --git a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java index cf5b9f745..d6083148b 100644 --- a/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java +++ b/main/src/main/java/me/blackvein/quests/listeners/PlayerListener.java @@ -342,7 +342,7 @@ public class PlayerListener implements Listener { } } if (evt.getItem() != null && evt.getItem().getType().equals(Material.COMPASS)) { - if (!player.hasPermission("quests.compass")) { + if (!quester.canUseCompass()) { return; } if (evt.getAction().equals(Action.LEFT_CLICK_AIR) @@ -808,7 +808,7 @@ public class PlayerListener implements Listener { if (quester.hasJournal) { quester.updateJournal(); } - if (evt.getPlayer().hasPermission("quests.compass")) { + if (quester.canUseCompass()) { quester.resetCompass(); } }