Skip to content

Commit

Permalink
Add permission bypass as config option (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Pugzy <[email protected]>
  • Loading branch information
Pugzy authored Mar 12, 2022
1 parent 9730f95 commit 18ed322
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/main/java/tc/oc/occ/idly/IdlyConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,6 +47,10 @@ public int getWarningFrequency() {
return warningFrequency;
}

public boolean isBypassEnabled() {
return bypassEnabled;
}

public boolean isRequireMatchRunning() {
return requireMatchRunning;
}
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tc/oc/occ/idly/IdlyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 18ed322

Please sign in to comment.