From 18ed322d112b0fadf47c954c3a6085c013afb367 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 12 Mar 2022 00:01:42 +0000 Subject: [PATCH] Add permission bypass as config option (#3) Signed-off-by: Pugzy --- src/main/java/tc/oc/occ/idly/IdlyConfig.java | 6 ++++++ src/main/java/tc/oc/occ/idly/IdlyManager.java | 2 +- src/main/resources/config.yml | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/tc/oc/occ/idly/IdlyConfig.java b/src/main/java/tc/oc/occ/idly/IdlyConfig.java index 0218d24..501a234 100644 --- a/src/main/java/tc/oc/occ/idly/IdlyConfig.java +++ b/src/main/java/tc/oc/occ/idly/IdlyConfig.java @@ -12,6 +12,7 @@ public class IdlyConfig { private int observerDelay; private int warningDuration; private int warningFrequency; + private boolean bypassEnabled; private boolean requireMatchRunning; private boolean preciseMovement; private boolean movementCheck; @@ -46,6 +47,10 @@ public int getWarningFrequency() { return warningFrequency; } + public boolean isBypassEnabled() { + return bypassEnabled; + } + public boolean isRequireMatchRunning() { return requireMatchRunning; } @@ -73,6 +78,7 @@ public void reload(Configuration config) { this.observerDelay = config.getInt("observer-delay"); this.warningDuration = config.getInt("warning-duration"); this.warningFrequency = config.getInt("warning-frequency"); + this.bypassEnabled = config.getBoolean("bypass-enabled", true); this.requireMatchRunning = config.getBoolean("require-match-running"); this.preciseMovement = config.getBoolean("precise-movement"); this.movementCheck = config.getBoolean("checks.movement"); diff --git a/src/main/java/tc/oc/occ/idly/IdlyManager.java b/src/main/java/tc/oc/occ/idly/IdlyManager.java index 0cd54c2..11e67d3 100644 --- a/src/main/java/tc/oc/occ/idly/IdlyManager.java +++ b/src/main/java/tc/oc/occ/idly/IdlyManager.java @@ -58,7 +58,7 @@ private void checkPlayer(Player player, boolean isPlaying) { if (!config.isKickMode() && !isPlaying) return; // Ignore those with the bypass permission - if (player.hasPermission(IdlyPermissions.BYPASS)) return; + if (config.isBypassEnabled() && player.hasPermission(IdlyPermissions.BYPASS)) return; int duration = (isPlaying ? config.getParticipantDelay() : config.getObserverDelay()); float remaining = duration - inactivity; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 717e1b2..97fae9e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -17,7 +17,10 @@ observer-delay: 120 warning-duration: 15 # Frequency between warning countdown messages (in seconds) -warning-frequency: 5 +warning-frequency: 5 + +# Allow player bypass with 'idly.bypass' permission +bypass-enabled: true # Only check for inactivity when match is running require-match-running: true