Skip to content

Commit

Permalink
do not correct the command input
Browse files Browse the repository at this point in the history
in case some mongoloid plugin decides to not filter out the / and rawdog the message into Player#performCommand
  • Loading branch information
YouHaveTrouble committed Nov 5, 2023
1 parent 75b91a7 commit 3c31081
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreproce
String caseSensitiveLabel = CommandUtil.getCommandLabel(event.getMessage());
String label = caseSensitiveLabel.toLowerCase();

String fullCommand = event.getMessage().substring(label.length()+1);
fullCommand = "/"+label+fullCommand;

event.setMessage(fullCommand);
CommandWhitelistBukkit.getPlugin().getLogger().info("Message after: "+event.getMessage());
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
ConfigCache config = CommandWhitelistBukkit.getConfigCache();

Expand All @@ -36,8 +33,9 @@ public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreproce
}

HashSet<String> bannedSubCommands = CommandWhitelistBukkit.getSuggestions(player);
String messageWithoutSlash = event.getMessage().startsWith("/") ? event.getMessage().substring(1) : event.getMessage();
for (String bannedSubCommand : bannedSubCommands) {
if (event.getMessage().toLowerCase().substring(1).startsWith(bannedSubCommand)) {
if (messageWithoutSlash.startsWith(bannedSubCommand)) {
event.setCancelled(true);
audiences.player(player).sendMessage(CWCommand.miniMessage.deserialize(config.prefix + config.subcommand_denied));
return;
Expand Down

0 comments on commit 3c31081

Please sign in to comment.