Skip to content

Commit

Permalink
do not complete from legacy tab complete packet
Browse files Browse the repository at this point in the history
  • Loading branch information
YouHaveTrouble committed Dec 29, 2022
1 parent ed1024c commit e8b284d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;


public class AsyncTabCompleteBlockerListener implements Listener {

@EventHandler(priority = EventPriority.HIGHEST)
Expand All @@ -18,8 +17,14 @@ public void onCommandTabComplete(AsyncTabCompleteEvent event) {
Player player = (Player) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String buffer = event.getBuffer();
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) event.setCancelled(true);
if (event.getCompletions().isEmpty()) return;
if ((buffer.split(" ").length == 1 && !buffer.endsWith(" ")) || !buffer.startsWith("/")) {
CommandWhitelistBukkit.getConfigCache().debug("Actively prevented "+event.getSender().getName()+"'s tab completion (sus packet)");
event.setCancelled(true);
return;
}
if (event.getCompletions().isEmpty()) {
return;
}
event.setCompletions(CommandUtil.filterSuggestions(buffer, event.getCompletions(), CommandWhitelistBukkit.getSuggestions(player)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ public void onCommandTabComplete(TabCompleteEvent event) {
Player player = (Player) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String buffer = event.getBuffer();
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) {
CommandWhitelistBukkit.getConfigCache().debug("Actively prevented "+event.getSender().getName()+"'s tab completion (/[tab] packet)");
if ((buffer.split(" ").length == 1 && !buffer.endsWith(" ")) || !buffer.startsWith("/")) {
CommandWhitelistBukkit.getConfigCache().debug("Actively prevented "+event.getSender().getName()+"'s tab completion (sus packet)");
event.setCancelled(true);
return;
}
if (event.getCompletions().isEmpty()) {
CommandWhitelistBukkit.getConfigCache().debug("Tab completion not provided");
return;
}
event.setCompletions(
Expand Down

0 comments on commit e8b284d

Please sign in to comment.