mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 411aba64d6 | |||
| 7591d00847 | |||
| d52139c16f |
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>eu.endermite</groupId>
|
||||
<artifactId>CommandWhitelist</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<version>1.3.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>CommandWhitelist</name>
|
||||
@@ -80,7 +80,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.3-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -92,7 +92,7 @@
|
||||
<dependency>
|
||||
<groupId>io.github.waterfallmc</groupId>
|
||||
<artifactId>waterfall-api</artifactId>
|
||||
<version>1.15-SNAPSHOT</version>
|
||||
<version>1.16-R0.4-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
-1
@@ -5,7 +5,6 @@ import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
-37
@@ -11,17 +11,14 @@ import eu.endermite.commandwhitelist.api.CommandsList;
|
||||
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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) {
|
||||
@@ -36,9 +33,7 @@ public class LegacyPlayerTabChatCompleteListener {
|
||||
}
|
||||
PacketContainer packet = event.getPacket();
|
||||
String[] message = packet.getSpecificModifier(String[].class).read(0);
|
||||
|
||||
List<String> commandList = CommandsList.getCommands(player);
|
||||
|
||||
List<String> finalList = new ArrayList<>();
|
||||
int components = 0;
|
||||
for (String cmd : message) {
|
||||
@@ -63,36 +58,4 @@ 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);
|
||||
System.out.println(command);
|
||||
|
||||
for (Map.Entry<String, List<String>> s : CommandWhitelist.getConfigCache().getPermList().entrySet()) {
|
||||
if (!player.hasPermission("commandwhitelist.commands." + s.getKey()))
|
||||
continue;
|
||||
for (String comm : s.getValue()) {
|
||||
comm = comm.toLowerCase();
|
||||
if (command.equalsIgnoreCase("/" + comm))
|
||||
return;
|
||||
else if (command.startsWith("/" + comm + " ")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user