mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99f7c245da | |||
| cd4c41f1f2 | |||
| 8a86568ce9 | |||
| b08234d268 |
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||
<artifactId>CommandWhitelist</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<version>2.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>Bukkit</artifactId>
|
||||
@@ -86,19 +86,19 @@
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.19-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.1.0</version>
|
||||
<version>4.1.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.10.1</version>
|
||||
<version>4.11.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -110,7 +110,7 @@
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.6.0</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
+5
-7
@@ -6,14 +6,12 @@ import eu.endermite.commandwhitelist.bukkit.listeners.PlayerCommandPreProcessLis
|
||||
import eu.endermite.commandwhitelist.bukkit.listeners.PlayerCommandSendListener;
|
||||
import eu.endermite.commandwhitelist.bukkit.listeners.TabCompleteBlockerListener;
|
||||
import eu.endermite.commandwhitelist.bukkit.listeners.protocollib.PacketCommandPreProcessListener;
|
||||
import eu.endermite.commandwhitelist.bukkit.listeners.protocollib.PacketCommandSendListener;
|
||||
import eu.endermite.commandwhitelist.common.CWGroup;
|
||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -42,11 +40,10 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
||||
|
||||
if (!getConfigCache().useProtocolLib || protocollib == null || !protocollib.isEnabled()) {
|
||||
getServer().getPluginManager().registerEvents(new PlayerCommandPreProcessListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this);
|
||||
} else {
|
||||
PacketCommandPreProcessListener.protocol(this);
|
||||
PacketCommandSendListener.protocol(this);
|
||||
getLogger().info(ChatColor.AQUA + "Using ProtocolLib for command filter!");
|
||||
getLogger().warning("Using ProtocolLib for command filter!");
|
||||
getLogger().warning("Please make sure you actually need this. This is not a \"better way to do it\".");
|
||||
}
|
||||
try {
|
||||
// Use paper's async tab completions if possible
|
||||
@@ -55,6 +52,7 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this);
|
||||
|
||||
PluginCommand command = getCommand("commandwhitelist");
|
||||
if (command != null) {
|
||||
@@ -74,9 +72,9 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
||||
} catch (NoSuchMethodError e) {
|
||||
configCache = new ConfigCache(configFile, true, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
configCache.reloadConfig();
|
||||
configCache.reloadConfig();
|
||||
}
|
||||
|
||||
public void reloadPluginConfig(CommandSender sender) {
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
package eu.endermite.commandwhitelist.bukkit.listeners.protocollib;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class PacketCommandSendListener {
|
||||
|
||||
public static void protocol(CommandWhitelistBukkit plugin) {
|
||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
commandSendListener(protocolManager, plugin);
|
||||
}
|
||||
|
||||
public static void commandSendListener(ProtocolManager protocolManager, Plugin plugin) {
|
||||
protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Server.COMMANDS) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.isPlayerTemporary()) return;
|
||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||
HashSet<String> commandList = CommandWhitelistBukkit.getCommands(player);
|
||||
PacketContainer packet = event.getPacket();
|
||||
RootCommandNode<?> node = (RootCommandNode<?>) packet.getModifier().getValues().get(0);
|
||||
node.getChildren().removeIf((cmd) -> !commandList.contains(cmd.getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||
<artifactId>CommandWhitelist</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<version>2.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>Common</artifactId>
|
||||
@@ -88,13 +88,13 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.10.1</version>
|
||||
<version>4.11.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.19-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||
<artifactId>CommandWhitelist</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<version>2.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>Velocity</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||
<artifactId>CommandWhitelist</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<version>2.5.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>Waterfall</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||
<artifactId>CommandWhitelist</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<version>2.5.0</version>
|
||||
<modules>
|
||||
<module>CommandWhitelistCommon</module>
|
||||
<module>CommandWhitelistBukkit</module>
|
||||
@@ -71,7 +71,7 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.10.1</version>
|
||||
<version>4.11.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
Reference in New Issue
Block a user