Skip to content

Commit

Permalink
optimize shared modules
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Aug 1, 2024
1 parent d54682b commit beffa3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandSendEvent;

import java.util.Set;

Expand All @@ -26,8 +27,8 @@ public CWCommandSendListener(Set<String> allowedCommands) {
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onInitialTabCompleteListSend(org.bukkit.event.player.PlayerCommandSendEvent event) {
if (!event.getPlayer().hasPermission(AEFPermission.BYPASS_CMD_WHITELIST.string())) {
private void onInitialTabCompleteListSend(PlayerCommandSendEvent event) {
if (!event.getPlayer().hasPermission(AEFPermission.BYPASS_CMD_WHITELIST.bukkit())) {
event.getCommands().retainAll(allowedCommands);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@

public class SignCommandListener implements Listener {

private static boolean isSupported;

static {
try {
Class.forName("io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent");
isSupported = true;
} catch (ClassNotFoundException e) {
isSupported = false;
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onSignCommandPreprocess(PlayerSignCommandPreprocessEvent event) {
if (!event.getPlayer().hasPermission(AEFPermission.BYPASS_PREVENTION_COMMANDSIGN.string())) {
if (!event.getPlayer().hasPermission(AEFPermission.BYPASS_PREVENTION_COMMANDSIGN.bukkit())) {
event.setCancelled(true);
}
}

public static boolean isSupported() {
try {
Class.forName("io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent");
return true;
} catch (ClassNotFoundException e) {
return false;
}
return isSupported;
}
}

0 comments on commit beffa3e

Please sign in to comment.