Skip to content

Commit

Permalink
changed event priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSwag committed Sep 25, 2023
1 parent 823fd40 commit 5503921
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
public class CommandListener implements Listener {
private final CraftCommander commander;

@EventHandler(ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCommandSend(PlayerCommandSendEvent event) {
event.getCommands().removeIf(literal -> commander.commandRegistry().isCommandRemoved(literal));
}

@EventHandler(ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCommand(ServerCommandEvent event) {
var literal = event.getCommand().split(" ")[0];
if (commander.platform().commandRegistry().isCommandRegistered(literal)
Expand All @@ -30,15 +30,15 @@ public void onCommand(ServerCommandEvent event) {
event.setCancelled(true);
}

@EventHandler
@EventHandler(priority = EventPriority.HIGHEST)
public void onUnknownCommand(UnknownCommandEvent event) {
var literal = event.getCommandLine().split(" ")[0];
if (!commander.commandRegistry().isCommandRemoved(literal)) return;
event.message(commander.bundle().component(event.getSender(), "command.unknown",
Placeholder.parsed("command", literal)));
}

@EventHandler(ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCommand(PlayerCommandPreprocessEvent event) {
var player = event.getPlayer();
var literal = event.getMessage().substring(1).split(" ")[0];
Expand Down

0 comments on commit 5503921

Please sign in to comment.