Skip to content

Commit

Permalink
fix plugin scanning prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Dec 27, 2023
1 parent 70abf9e commit 52c1151
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class PreventPluginScanning implements AnarchyExploitFixesModule, Listene

/*
* Credits go to YouHaveTrouble (https://github.com/YouHaveTrouble/CommandWhitelist)
* Code was mainly only implemented into AEF by xGinko.
* Code was only implemented into AEF by xGinko.
*/

public PreventPluginScanning() {}
Expand All @@ -37,7 +37,8 @@ public void enable() {

@Override
public boolean shouldEnable() {
return AnarchyExploitFixes.getConfiguration().getBoolean("chat.prevent-scanning-server-plugins.enable", true, "Prevents hacked clients running .plugins to find out what plugins the server is using");
return AnarchyExploitFixes.getConfiguration().getBoolean("chat.prevent-scanning-server-plugins.enable", true,
"Prevents hacked clients running .plugins to find out what plugins the server is using");
}

@Override
Expand All @@ -58,12 +59,12 @@ private void onAsyncCommandTabComplete(AsyncTabCompleteEvent event) {
}
}

@EventHandler(priority = EventPriority.NORMAL)
@EventHandler(priority = EventPriority.HIGHEST)
private void onCommandTabComplete(TabCompleteEvent event) {
if (event.getSender().hasPermission("anarchyexploitfixes.chatbypass")) return;
if (!(event.getSender() instanceof Player)) return;
if (isSuspectedScanPacket(event.getBuffer())) {
event.setCancelled(true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class PreventPluginScanning implements AnarchyExploitFixesModule, Listene

/*
* Credits go to YouHaveTrouble (https://github.com/YouHaveTrouble/CommandWhitelist)
* Code was mainly only implemented into AEF by xGinko.
* Code was only implemented into AEF by xGinko.
*/

public PreventPluginScanning() {}
Expand All @@ -36,28 +36,29 @@ public void enable() {

@Override
public boolean shouldEnable() {
return AnarchyExploitFixes.getConfiguration().getBoolean("chat.prevent-scanning-server-plugins.enable", true, "Prevents hacked clients running .plugins to find out what plugins the server is using");
return AnarchyExploitFixes.getConfiguration().getBoolean("chat.prevent-scanning-server-plugins.enable", true,
"Prevents hacked clients running .plugins to find out what plugins the server is using");
}

private static boolean isSuspectedScanPacket(String buffer) {
private boolean isSuspectedScanPacket(String buffer) {
return (buffer.split(" ").length == 1 && !buffer.endsWith(" ")) || !buffer.startsWith("/");
}

@EventHandler(priority = EventPriority.HIGHEST)
private void onAsyncCommandTabComplete(AsyncTabCompleteEvent event) {
if (event.getSender().hasPermission("anarchyexploitfixes.chatbypass")) return;
if (!(event.getSender() instanceof Player)) return;
if (isSuspectedScanPacket(event.getBuffer())) {
if (this.isSuspectedScanPacket(event.getBuffer())) {
event.setCancelled(true);
}
}

@EventHandler(priority = EventPriority.NORMAL)
@EventHandler(priority = EventPriority.HIGHEST)
private void onCommandTabComplete(TabCompleteEvent event) {
if (event.getSender().hasPermission("anarchyexploitfixes.chatbypass")) return;
if (!(event.getSender() instanceof Player)) return;
if (isSuspectedScanPacket(event.getBuffer())) {
if (this.isSuspectedScanPacket(event.getBuffer())) {
event.setCancelled(true);
}
}
}
}

0 comments on commit 52c1151

Please sign in to comment.