From 29d7ef7caa91a16954621970ad9f5d6070669821 Mon Sep 17 00:00:00 2001 From: tehbeard Date: Sun, 17 Aug 2025 12:10:04 +0100 Subject: [PATCH 1/2] Return early if PlayerCommandPreprocessEvent already cancelled. Fixes issue of the resource world `disabled_command` message being sent to the user if the command was disabled/prevented by another plugin. --- .../me/nik/resourceworld/modules/impl/DisabledCommands.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/nik/resourceworld/modules/impl/DisabledCommands.java b/src/main/java/me/nik/resourceworld/modules/impl/DisabledCommands.java index 111983f..fbf4fe8 100644 --- a/src/main/java/me/nik/resourceworld/modules/impl/DisabledCommands.java +++ b/src/main/java/me/nik/resourceworld/modules/impl/DisabledCommands.java @@ -22,7 +22,9 @@ public DisabledCommands(ResourceWorld plugin) { @EventHandler(priority = EventPriority.HIGHEST) public void disableWorldCommands(PlayerCommandPreprocessEvent e) { - + + if(e.isCancelled()) return; + Player player = e.getPlayer(); if (player.hasPermission(Permissions.ADMIN.getPermission()) || e.getMessage().equals("/")) return; @@ -61,4 +63,4 @@ && isDisabledCommand(Config.Setting.END_DISABLED_COMMANDS_LIST.getStringList(), private boolean isDisabledCommand(List list, String cmd) { return list.stream().anyMatch(cmd::contains); } -} \ No newline at end of file +} From b9572752a456dc5fdde980b700a31b815fed0cde Mon Sep 17 00:00:00 2001 From: tehbeard Date: Mon, 1 Sep 2025 20:06:22 +0100 Subject: [PATCH 2/2] Switch to annotation based ignore of cancelled event --- .../me/nik/resourceworld/modules/impl/DisabledCommands.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/me/nik/resourceworld/modules/impl/DisabledCommands.java b/src/main/java/me/nik/resourceworld/modules/impl/DisabledCommands.java index fbf4fe8..ea997f4 100644 --- a/src/main/java/me/nik/resourceworld/modules/impl/DisabledCommands.java +++ b/src/main/java/me/nik/resourceworld/modules/impl/DisabledCommands.java @@ -20,11 +20,9 @@ public DisabledCommands(ResourceWorld plugin) { || Config.Setting.END_DISABLED_COMMANDS_ENABLED.getBoolean()), plugin); } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.HIGHEST,ignoreCancelled = true) public void disableWorldCommands(PlayerCommandPreprocessEvent e) { - if(e.isCancelled()) return; - Player player = e.getPlayer(); if (player.hasPermission(Permissions.ADMIN.getPermission()) || e.getMessage().equals("/")) return;