From 0bfbeac52d6ccf5dfdb92a7e4a291d058255e20f Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Sun, 9 Jan 2022 05:11:31 +0100 Subject: [PATCH] fix worldguard block-command bug --- pom.xml | 2 +- src/main/java/de/jatitv/opsecurity/listener/Events.java | 9 +++++---- .../java/de/jatitv/opsecurity/listener/OPCommand.java | 3 +++ .../de/jatitv/opsecurity/listener/PlugManCommand.java | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 12fc2bd..f8a95de 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ de.jatitv OPSecurity - 2.4.0 + 2.4.1_DEV jar OPSecurity diff --git a/src/main/java/de/jatitv/opsecurity/listener/Events.java b/src/main/java/de/jatitv/opsecurity/listener/Events.java index d878123..c613a04 100644 --- a/src/main/java/de/jatitv/opsecurity/listener/Events.java +++ b/src/main/java/de/jatitv/opsecurity/listener/Events.java @@ -17,7 +17,10 @@ public class Events implements org.bukkit.event.Listener { public void CommandSendEvent(PlayerCommandPreprocessEvent event) { if (SelectConfig.CheckOnCommand) { Player player = event.getPlayer(); - event.setCancelled(Check.onCheck(player, false)); + if (Check.onCheck(player, false)) { + if (event.isCancelled()) return; + event.setCancelled(true); + } } } @@ -26,9 +29,7 @@ public class Events implements org.bukkit.event.Listener { if (SelectConfig.CheckOnChat) { Player player = event.getPlayer(); if (Check.onCheck(player, false)) { - if (event.isCancelled()) { - return; - } + if (event.isCancelled()) return; event.setCancelled(true); } } diff --git a/src/main/java/de/jatitv/opsecurity/listener/OPCommand.java b/src/main/java/de/jatitv/opsecurity/listener/OPCommand.java index 1e7dc9b..d66fb4f 100644 --- a/src/main/java/de/jatitv/opsecurity/listener/OPCommand.java +++ b/src/main/java/de/jatitv/opsecurity/listener/OPCommand.java @@ -23,6 +23,7 @@ public class OPCommand implements Listener { @EventHandler public void onOPServer(ServerCommandEvent event) { + if ((event.getCommand().toLowerCase().startsWith("op ") || event.getCommand().toLowerCase().startsWith("minecraft:op ")) && SelectConfig.OP_Whitelist_Enable) { switch (this.isNotOPWTL(event.getCommand())) { case 1: @@ -40,6 +41,7 @@ public class OPCommand implements Listener { @EventHandler public void onOpPlayer(PlayerCommandPreprocessEvent event) { + if (SelectConfig.OP_Whitelist_Enable) { if ((event.getMessage().toLowerCase().startsWith("/op ") || event.getMessage().toLowerCase().startsWith("/minecraft:op "))) { switch (this.isNotOPWTL(event.getMessage())) { @@ -57,6 +59,7 @@ public class OPCommand implements Listener { } private int isNotOPWTL(String command) { + if (!command.contains("op")) return 0; if (command.charAt(0) == '/') command = command.replaceFirst("/", ""); String arg = command.replace("op ", ""); diff --git a/src/main/java/de/jatitv/opsecurity/listener/PlugManCommand.java b/src/main/java/de/jatitv/opsecurity/listener/PlugManCommand.java index 1656d2b..b392afb 100644 --- a/src/main/java/de/jatitv/opsecurity/listener/PlugManCommand.java +++ b/src/main/java/de/jatitv/opsecurity/listener/PlugManCommand.java @@ -15,6 +15,7 @@ public class PlugManCommand implements Listener { @EventHandler public void onOPServer(ServerCommandEvent event) { + if ((event.getCommand().toLowerCase().contains("plugman disable") && event.getCommand().toLowerCase().contains(Main.plugin.getDescription().getName().toLowerCase())) || (event.getCommand().toLowerCase().contains("plugman reload") && event.getCommand().toLowerCase().contains(Main.plugin.getDescription().getName().toLowerCase())) || (event.getCommand().toLowerCase().contains("plugman unload") && event.getCommand().toLowerCase().contains(Main.plugin.getDescription().getName().toLowerCase())) @@ -27,6 +28,7 @@ public class PlugManCommand implements Listener { @EventHandler public void onOpPlayer(PlayerCommandPreprocessEvent event) { + if (event.getMessage().toLowerCase().startsWith("/plugman disable") && event.getMessage().toLowerCase().contains(Main.plugin.getDescription().getName().toLowerCase()) || (event.getMessage().toLowerCase().startsWith("/plugman reload") && event.getMessage().toLowerCase().contains(Main.plugin.getDescription().getName().toLowerCase())) || (event.getMessage().toLowerCase().startsWith("/plugman unload") && event.getMessage().toLowerCase().contains(Main.plugin.getDescription().getName().toLowerCase()))