mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-11 22:16:57 +00:00
guess what, legacy issues again.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>eu.endermite</groupId>
|
||||
<artifactId>CommandWhitelist</artifactId>
|
||||
<version>1.7.4</version>
|
||||
<version>1.7.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>CommandWhitelist</name>
|
||||
|
||||
@@ -63,4 +63,11 @@ public class CommandsList {
|
||||
return last;
|
||||
}
|
||||
|
||||
public static String getCommandLabel(String cmd) {
|
||||
String[] parts = cmd.split(" ");
|
||||
if (parts[0].startsWith("/"))
|
||||
parts[0] = parts[0].substring(1);
|
||||
return parts[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+30
@@ -19,6 +19,7 @@ public class LegacyPlayerTabChatCompleteListener {
|
||||
public static void protocol(CommandWhitelist plugin) {
|
||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
tabCompleteServerBound(protocolManager, plugin);
|
||||
tabCompleteClientBound(protocolManager, plugin);
|
||||
}
|
||||
|
||||
public static void tabCompleteServerBound(ProtocolManager protocolManager, Plugin plugin) {
|
||||
@@ -52,4 +53,33 @@ public class LegacyPlayerTabChatCompleteListener {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void tabCompleteClientBound(ProtocolManager protocolManager, Plugin plugin) {
|
||||
protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.TAB_COMPLETE) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
try {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission("commandwhitelist.bypass")) {
|
||||
return;
|
||||
}
|
||||
PacketContainer packet = event.getPacket();
|
||||
String command = packet.getSpecificModifier(String.class).read(0);
|
||||
String label = CommandsList.getCommandLabel(command);
|
||||
List<String> commandList = CommandsList.getCommands(player);
|
||||
if (command.equals("/"))
|
||||
return;
|
||||
for (String cmd : commandList) {
|
||||
if (cmd.startsWith("/"+label+" "))
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user