Compare commits

...

7 Commits

Author SHA1 Message Date
YouHaveTrouble 2ede673f52 some base logic for tab completion and command execution 2023-08-10 14:44:37 +02:00
YouHaveTrouble de4124aa73 the great cleanup 2023-06-08 01:04:18 +02:00
YouHaveTrouble cd3ee4b214 bump version 2023-04-29 13:22:09 +02:00
YouHaveTrouble ea54ae3175 Merge "Improved Velocity Module" #69 from 4drian3d/velocity
Improved Velocity Module
2023-04-29 13:19:46 +02:00
Adrian c36ac056d5 Simplified suggestions 2023-04-28 18:25:19 -05:00
Adrian 7186c4de6c Improved Velocity Module 2023-04-28 17:53:37 -05:00
YouHaveTrouble dfa254f263 update funding 2023-04-26 23:48:01 +02:00
41 changed files with 534 additions and 2015 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
# These are supported funding model platforms # These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] github: YouHaveTrouble
patreon: # Replace with a single Patreon username patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username open_collective: # Replace with a single Open Collective username
ko_fi: YouHaveTrouble ko_fi: YouHaveTrouble
-113
View File
@@ -1,113 +0,0 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# Common working directory
run/
-129
View File
@@ -1,129 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.6.0</version>
</parent>
<artifactId>Bukkit</artifactId>
<packaging>jar</packaging>
<name>CommandWhitelist-Bukkit</name>
<description>You decide what commands players can use or tab complete on your server!</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>youhavetrouble.me</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.name}-${project.parent.version}</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>eu.endermite.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>eu.endermite</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.11.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>Common</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>brigadier</artifactId>
<version>1.0.17</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -1,166 +0,0 @@
package eu.endermite.commandwhitelist.bukkit;
import eu.endermite.commandwhitelist.bukkit.command.BukkitCommandExecutor;
import eu.endermite.commandwhitelist.bukkit.listeners.AsyncTabCompleteBlockerListener;
import eu.endermite.commandwhitelist.bukkit.listeners.PlayerCommandPreProcessListener;
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.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.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.help.HelpTopic;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.*;
import java.util.concurrent.CompletableFuture;
public class CommandWhitelistBukkit extends JavaPlugin {
private static CommandWhitelistBukkit commandWhitelist;
private static ConfigCache configCache;
private static BukkitAudiences audiences;
@Override
public void onEnable() {
commandWhitelist = this;
audiences = BukkitAudiences.create(this);
reloadPluginConfig();
Plugin protocollib = getServer().getPluginManager().getPlugin("ProtocolLib");
if (!getConfigCache().useProtocolLib || protocollib == null || !protocollib.isEnabled()) {
getServer().getPluginManager().registerEvents(new PlayerCommandPreProcessListener(), this);
} else {
PacketCommandPreProcessListener.protocol(this);
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
Class.forName("com.destroystokyo.paper.event.server.AsyncTabCompleteEvent");
getServer().getPluginManager().registerEvents(new AsyncTabCompleteBlockerListener(), this);
} catch (ClassNotFoundException ignored) {
}
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this);
PluginCommand command = getCommand("commandwhitelist");
if (command != null) {
BukkitCommandExecutor executor = new BukkitCommandExecutor();
command.setExecutor(executor);
command.setTabCompleter(executor);
}
new Metrics(this, 8705);
}
private void reloadPluginConfig() {
File configFile = new File("plugins/CommandWhitelist/config.yml");
if (configCache == null) {
try {
configCache = new ConfigCache(configFile, true, getSLF4JLogger());
} catch (NoSuchMethodError e) {
configCache = new ConfigCache(configFile, true, null);
}
return;
}
configCache.reloadConfig();
}
public void reloadPluginConfig(CommandSender sender) {
CompletableFuture.runAsync(() -> {
reloadPluginConfig();
try {
for (Player p : Bukkit.getOnlinePlayers()) {
p.updateCommands();
}
} catch (Exception ignored) {}
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.config_reloaded));
});
}
public static CommandWhitelistBukkit getPlugin() {
return commandWhitelist;
}
public static ConfigCache getConfigCache() {
return configCache;
}
public static BukkitAudiences getAudiences() {
return audiences;
}
/**
* @param player Bukkit Player
* @return commands available to the player
*/
public static HashSet<String> getCommands(org.bukkit.entity.Player player) {
HashSet<String> commandList = new HashSet<>();
HashMap<String, CWGroup> groups = configCache.getGroupList();
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
if (s.getKey().equalsIgnoreCase("default"))
commandList.addAll(s.getValue().getCommands());
else if (player.hasPermission(s.getValue().getPermission()))
commandList.addAll(s.getValue().getCommands());
}
return commandList;
}
/**
* @param player Bukkit Player
* @return subcommands unavailable for the player
*/
public static HashSet<String> getSuggestions(org.bukkit.entity.Player player) {
HashSet<String> suggestionList = new HashSet<>();
HashMap<String, CWGroup> groups = configCache.getGroupList();
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
if (s.getKey().equalsIgnoreCase("default"))
suggestionList.addAll(s.getValue().getSubCommands());
if (player.hasPermission(s.getValue().getPermission())) continue;
suggestionList.addAll(s.getValue().getSubCommands());
}
return suggestionList;
}
/**
* @return Command denied message. Will use custom if command exists in any group.
*/
public static String getCommandDeniedMessage(String command) {
String commandDeniedMessage = configCache.command_denied;
HashMap<String, CWGroup> groups = configCache.getGroupList();
for (CWGroup group : groups.values()) {
if (group.getCommands().contains(command)) {
if (group.getCommandDeniedMessage() == null || group.getCommandDeniedMessage().isEmpty()) continue;
commandDeniedMessage = group.getCommandDeniedMessage();
break; // get first message we find
}
}
return commandDeniedMessage;
}
public static ArrayList<String> getServerCommands() {
try {
return new ArrayList<>(Bukkit.getCommandMap().getKnownCommands().keySet());
} catch (NoSuchMethodError error) {
HashSet<String> commands = new HashSet<>();
for (HelpTopic topic : Bukkit.getHelpMap().getHelpTopics()) {
String cmd = topic.getName();
if (Character.isUpperCase(cmd.charAt(0))) continue;
commands.add(topic.getName());
}
return new ArrayList<>(commands);
}
}
}
@@ -1,96 +0,0 @@
package eu.endermite.commandwhitelist.bukkit.command;
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import java.io.File;
import java.util.List;
public class BukkitCommandExecutor implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
if (args.length == 0) {
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
return true;
}
try {
CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase());
switch (commandType) {
case RELOAD:
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
return true;
}
CommandWhitelistBukkit.getPlugin().reloadPluginConfig(sender);
return true;
case ADD:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
return true;
}
if (args.length == 3) {
if (CWCommand.addToWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1]))
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().added_to_whitelist, args[2], args[1])));
else
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
} else
audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>"));
return true;
case REMOVE:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
return true;
}
if (args.length == 3) {
if (CWCommand.removeFromWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1]))
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().removed_from_whitelist, args[2], args[1])));
else
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
} else
audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>"));
return true;
case DUMP:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
return true;
}
audiences.sender(sender).sendMessage(Component.text("Dumping all available commands to a file..."));
if (CommandUtil.dumpAllBukkitCommands(CommandWhitelistBukkit.getServerCommands(), new File("plugins/CommandWhitelist/command_dump.yml"))) {
audiences.sender(sender).sendMessage(Component.text("Commands dumped to command_dump.yml"));
} else {
audiences.sender(sender).sendMessage(Component.text("Failed to save the file."));
}
return true;
case HELP:
default:
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
}
} catch (IllegalArgumentException e) {
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return CWCommand.commandSuggestions(
CommandWhitelistBukkit.getConfigCache(),
CommandWhitelistBukkit.getServerCommands(),
args,
sender.hasPermission(CWPermission.RELOAD.permission()),
sender.hasPermission(CWPermission.ADMIN.permission()),
CWCommand.ImplementationType.BUKKIT
);
}
}
@@ -1,31 +0,0 @@
package eu.endermite.commandwhitelist.bukkit.listeners;
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent;
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class AsyncTabCompleteBlockerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onCommandTabComplete(AsyncTabCompleteEvent event) {
if (!(event.getSender() instanceof Player)) return;
Player player = (Player) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String buffer = event.getBuffer();
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)));
}
}
@@ -1,48 +0,0 @@
package eu.endermite.commandwhitelist.bukkit.listeners;
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.HashSet;
public class PlayerCommandPreProcessListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String caseSensitiveLabel = CommandUtil.getCommandLabel(event.getMessage());
String label = caseSensitiveLabel.toLowerCase();
String fullCommand = event.getMessage().substring(label.length()+1);
fullCommand = "/"+label+fullCommand;
event.setMessage(fullCommand);
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
if (!commands.contains(label)) {
event.setCancelled(true);
audiences.player(player).sendMessage(CWCommand.miniMessage.deserialize(config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)));
return;
}
HashSet<String> bannedSubCommands = CommandWhitelistBukkit.getSuggestions(player);
for (String bannedSubCommand : bannedSubCommands) {
if (event.getMessage().toLowerCase().substring(1).startsWith(bannedSubCommand)) {
event.setCancelled(true);
audiences.player(player).sendMessage(CWCommand.miniMessage.deserialize(config.prefix + config.subcommand_denied));
return;
}
}
}
}
@@ -1,20 +0,0 @@
package eu.endermite.commandwhitelist.bukkit.listeners;
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.HashSet;
public class PlayerCommandSendListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandSendEvent event) {
Player player = event.getPlayer();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
HashSet<String> commandList = CommandWhitelistBukkit.getCommands(player);
event.getCommands().removeIf((cmd) -> !commandList.contains(cmd));
}
}
@@ -1,36 +0,0 @@
package eu.endermite.commandwhitelist.bukkit.listeners;
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.TabCompleteEvent;
public class TabCompleteBlockerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onCommandTabComplete(TabCompleteEvent event) {
if (!(event.getSender() instanceof Player)) return;
Player player = (Player) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String buffer = event.getBuffer();
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)
)
);
}
}
@@ -1,60 +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 eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.HashSet;
public class PacketCommandPreProcessListener {
public static void protocol(CommandWhitelistBukkit plugin) {
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
commandExecListener(protocolManager, plugin);
}
public static void commandExecListener(ProtocolManager protocolManager, Plugin plugin) {
protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
@Override
public void onPacketReceiving(PacketEvent event) {
PacketContainer packet = event.getPacket();
String string = packet.getStrings().read(0);
if (!string.startsWith("/")) return;
Player player = event.getPlayer();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
String caseSensitiveLabel = CommandUtil.getCommandLabel(string);
String label = caseSensitiveLabel.toLowerCase();
packet.getStrings().write(0, string.replaceFirst(caseSensitiveLabel, label));
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
if (!commands.contains(label)) {
event.setCancelled(true);
audiences.player(player).sendMessage(CWCommand.miniMessage.deserialize(config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)));
return;
}
HashSet<String> bannedSubCommands = CommandWhitelistBukkit.getSuggestions(player);
for (String bannedSubCommand : bannedSubCommands) {
if (string.toLowerCase().substring(1).startsWith(bannedSubCommand)) {
event.setCancelled(true);
CommandWhitelistBukkit.getAudiences().player(player).sendMessage(CWCommand.miniMessage.deserialize(config.prefix + config.subcommand_denied));
return;
}
}
}
});
}
}
-108
View File
@@ -1,108 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.6.0</version>
</parent>
<artifactId>Common</artifactId>
<packaging>jar</packaging>
<name>CommandWhitelist-Common</name>
<description>You decide what commands players can use or tab complete on your server!</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>youhavetrouble.me</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.name}-${project.parent.version}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>pluginwiki-repo</id>
<url>https://ci.pluginwiki.us/plugin/repository/everything/</url>
</repository>
<repository>
<id>velocitypowered-repo</id>
<url>https://repo.velocitypowered.com/releases/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.thatsmusic99</groupId>
<artifactId>ConfigurationMaster-API</artifactId>
<version>v2.0.0-BETA-1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.13.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.waterfallmc</groupId>
<artifactId>waterfall-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -1,65 +0,0 @@
package eu.endermite.commandwhitelist.common;
import org.jetbrains.annotations.Nullable;
import java.util.*;
public class CWGroup {
private final String id, permission, commandDeniedMessage;
private final HashSet<String> commands = new HashSet<>();
private final HashSet<String> subCommands = new HashSet<>();
public CWGroup(String id, Collection<String> commands, Collection<String> subCommands, String custom_command_denied_message) {
this.id = id;
this.permission = "commandwhitelist.group." + id;
this.commands.addAll(commands);
this.commandDeniedMessage = custom_command_denied_message;
this.subCommands.addAll(subCommands);
}
public String getId() {
return id;
}
public String getPermission() {
return permission;
}
public HashSet<String> getCommands() {
return commands;
}
public @Nullable String getCommandDeniedMessage() {
return commandDeniedMessage;
}
public void addCommand(String command) {
commands.add(command);
}
public void removeCommand(String command) {
commands.remove(command);
}
public HashSet<String> getSubCommands() {
return subCommands;
}
public void addSubCommand(String subCommand) {
subCommands.add(subCommand);
}
public void removeSubCommand(String subCommand) {
subCommands.remove(subCommand);
}
public HashMap<String, Object> serialize() {
HashMap<String, Object> serializedGroup = new LinkedHashMap<>();
List<String> commands = new ArrayList<>(this.commands);
List<String> subCommands = new ArrayList<>(this.subCommands);
serializedGroup.put("commands", commands);
serializedGroup.put("subcommands", subCommands);
return serializedGroup;
}
}
-113
View File
@@ -1,113 +0,0 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# Common working directory
run/
-101
View File
@@ -1,101 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.6.0</version>
</parent>
<artifactId>Velocity</artifactId>
<packaging>jar</packaging>
<name>CommandWhitelist-Velocity</name>
<description>You decide what commands players can use or tab complete on your server!</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>youhavetrouble.me</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.name}-${project.parent.version}</finalName>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>eu.endermite.bstats</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>minecraft-libraries</id>
<url>https://libraries.minecraft.net/</url>
</repository>
<repository>
<id>spongepowered-repo</id>
<url>https://repo.spongepowered.org/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>Common</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-velocity</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -1,144 +0,0 @@
package eu.endermite.commandwhitelist.velocity;
import com.velocitypowered.api.command.CommandMeta;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.command.CommandExecuteEvent;
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEvent;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import eu.endermite.commandwhitelist.common.CWGroup;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
import net.kyori.adventure.identity.Identity;
import org.bstats.charts.SimplePie;
import org.bstats.velocity.Metrics;
import org.slf4j.Logger;
import javax.inject.Inject;
import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
public class CommandWhitelistVelocity {
private static CommandWhitelistVelocity plugin;
private static ProxyServer server;
private static ConfigCache configCache;
private static Path folder;
private static Logger logger;
private final Metrics.Factory metricsFactory;
@Inject
public CommandWhitelistVelocity(ProxyServer server, Logger logger, @DataDirectory final Path folder, Metrics.Factory metricsFactory) {
CommandWhitelistVelocity.server = server;
CommandWhitelistVelocity.folder = folder;
CommandWhitelistVelocity.plugin = this;
CommandWhitelistVelocity.logger = logger;
this.metricsFactory = metricsFactory;
}
private static void reloadConfig() {
if (configCache == null)
configCache = new ConfigCache(new File(String.valueOf(folder), "config.yml"), false, logger);
else
configCache.reloadConfig();
}
public static void reloadConfig(CommandSource source) {
server.getScheduler().buildTask(plugin, () -> {
reloadConfig();
source.sendMessage(Identity.nil(), CWCommand.miniMessage.deserialize(getConfigCache().prefix + getConfigCache().config_reloaded));
}).schedule();
}
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
reloadConfig();
CommandMeta commandMeta = server.getCommandManager().metaBuilder("vcw").build();
server.getCommandManager().register(commandMeta, new VelocityMainCommand());
Metrics metrics = metricsFactory.make(this, 8704);
metrics.addCustomChart(new SimplePie("proxy", () -> "Velocity"));
}
@Subscribe
public void onUserCommandSendEvent(PlayerAvailableCommandsEvent event) {
Player player = event.getPlayer();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
event.getRootNode().getChildren().removeIf((commandNode) ->
server.getCommandManager().hasCommand(commandNode.getName())
&& !allowedCommands.contains(commandNode.getName())
);
}
@Subscribe
public void onUserCommandExecuteEvent(com.velocitypowered.api.event.command.CommandExecuteEvent event) {
if (!(event.getCommandSource() instanceof Player)) return;
Player player = (Player) event.getCommandSource();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
// Workaround for velocity executing "/ command" as valid command
String command = event.getCommand().trim();
HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
String label = CommandUtil.getCommandLabel(command);
if (server.getCommandManager().hasCommand(label) && !allowedCommands.contains(label))
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
}
public static ConfigCache getConfigCache() {
return configCache;
}
public static Path getConfigPath() {
return folder;
}
/**
* @param player Velocity Player
* @return commands available to the player
*/
public static HashSet<String> getCommands(Player player) {
HashMap<String, CWGroup> groups = configCache.getGroupList();
HashSet<String> commandList = new HashSet<>();
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
CWGroup group = s.getValue();
if (s.getKey().equalsIgnoreCase("default"))
commandList.addAll(group.getCommands());
else if (player.hasPermission(group.getPermission()))
commandList.addAll(group.getCommands());
}
return commandList;
}
/**
* @param player Velocity Player
* @return subcommands unavailable for the player
*/
public static HashSet<String> getSuggestions(Player player, HashMap<String, CWGroup> groups) {
HashSet<String> suggestionList = new HashSet<>();
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
if (s.getKey().equalsIgnoreCase("default"))
suggestionList.addAll(s.getValue().getSubCommands());
if (player.hasPermission(s.getValue().getPermission())) continue;
suggestionList.addAll(s.getValue().getSubCommands());
}
return suggestionList;
}
public static ArrayList<String> getServerCommands() {
return new ArrayList<>(server.getCommandManager().getAliases());
}
}
@@ -1,104 +0,0 @@
package eu.endermite.commandwhitelist.velocity.command;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity;
import net.kyori.adventure.text.Component;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class VelocityMainCommand implements SimpleCommand {
@Override
public void execute(final Invocation invocation) {
CommandSource sender = invocation.source();
String[] args = invocation.arguments();
String label = invocation.alias();
if (args.length == 0) {
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
return;
}
try {
CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase());
switch (commandType) {
case RELOAD:
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
sender.sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
return;
}
CommandWhitelistVelocity.reloadConfig(sender);
return;
case ADD:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
sender.sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
return;
}
if (args.length == 3) {
if (CWCommand.addToWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
sender.sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().added_to_whitelist, args[2], args[1])));
else
sender.sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
} else
sender.sendMessage(Component.text("/" + label + " add <group> <command>"));
return;
case REMOVE:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
sender.sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
return;
}
if (args.length == 3) {
if (CWCommand.removeFromWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
sender.sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().removed_from_whitelist, args[2], args[1])));
else
sender.sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
} else
sender.sendMessage(Component.text("/" + label + " remove <group> <command>"));
return;
case DUMP:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
sender.sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
return;
}
sender.sendMessage(Component.text("Dumping all available commands to a file..."));
if (CommandUtil.dumpAllBukkitCommands(CommandWhitelistVelocity.getServerCommands(), new File(String.valueOf(CommandWhitelistVelocity.getConfigPath()), "command_dump.yml"))) {
sender.sendMessage(Component.text("Commands dumped to command_dump.yml"));
} else {
sender.sendMessage(Component.text("Failed to save the file."));
}
return;
case HELP:
default:
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
}
} catch (IllegalArgumentException e) {
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
}
return;
}
@Override
public CompletableFuture<List<String>> suggestAsync(Invocation invocation) {
CommandSource source = invocation.source();
String[] args = invocation.arguments();
return CompletableFuture.supplyAsync(() -> {
List<String> serverCommands = CommandWhitelistVelocity.getServerCommands();
return CWCommand.commandSuggestions(
CommandWhitelistVelocity.getConfigCache(),
serverCommands,
args,
source.hasPermission(CWPermission.RELOAD.permission()),
source.hasPermission(CWPermission.ADMIN.permission()),
CWCommand.ImplementationType.VELOCITY
);
});
}
}
@@ -1,9 +0,0 @@
{
"id": "commandwhitelist",
"name": "CommandWhitelist",
"version": "${project.version}",
"description": "You decide what commands players can use or tab complete on your server!",
"authors": ["YouHaveTrouble"],
"dependencies": [],
"main": "eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity"
}
-113
View File
@@ -1,113 +0,0 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# Common working directory
run/
-113
View File
@@ -1,113 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.6.0</version>
</parent>
<artifactId>Waterfall</artifactId>
<packaging>jar</packaging>
<name>CommandWhitelist-Waterfall</name>
<description>You decide what commands players can use or tab complete on your server!</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>youhavetrouble.me</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.name}-${project.parent.version}</finalName>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>eu.endermite.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>eu.endermite</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>Common</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.github.waterfallmc</groupId>
<artifactId>waterfall-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.10.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bungeecord</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -1,132 +0,0 @@
package eu.endermite.commandwhitelist.waterfall;
import eu.endermite.commandwhitelist.common.CWGroup;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.waterfall.command.BungeeMainCommand;
import eu.endermite.commandwhitelist.waterfall.listeners.BungeeChatEventListener;
import eu.endermite.commandwhitelist.waterfall.listeners.BungeeTabcompleteListener;
import eu.endermite.commandwhitelist.waterfall.listeners.WaterfallDefineCommandsListener;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.Plugin;
import org.bstats.bungeecord.Metrics;
import org.bstats.charts.SimplePie;
import java.io.File;
import java.util.*;
public final class CommandWhitelistWaterfall extends Plugin {
private static CommandWhitelistWaterfall plugin;
private static ConfigCache configCache;
private static BungeeAudiences audiences;
@Override
public void onEnable() {
plugin = this;
getLogger().info("Running on " + ChatColor.DARK_AQUA + getProxy().getName());
loadConfig();
audiences = BungeeAudiences.create(this);
Metrics metrics = new Metrics(this, 8704);
this.getProxy().getPluginManager().registerListener(this, new BungeeChatEventListener());
try {
Class.forName("io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent");
metrics.addCustomChart(new SimplePie("proxy", () -> "Waterfall"));
this.getProxy().getPluginManager().registerListener(this, new WaterfallDefineCommandsListener());
} catch (ClassNotFoundException e) {
metrics.addCustomChart(new SimplePie("proxy", () -> "Bungee"));
getLogger().severe("Bungee command completion blocker requires Waterfall other Waterfall fork.");
}
this.getProxy().getPluginManager().registerListener(this, new BungeeTabcompleteListener());
getProxy().getPluginManager().registerCommand(this, new BungeeMainCommand("bcw"));
}
public static CommandWhitelistWaterfall getPlugin() {
return plugin;
}
public static ConfigCache getConfigCache() {
return configCache;
}
public static BungeeAudiences getAudiences() {
return audiences;
}
public void loadConfig() {
if (configCache == null)
configCache = new ConfigCache(new File(getDataFolder(), "config.yml"), false, getLogger());
else
configCache.reloadConfig();
}
public void loadConfigAsync(CommandSender sender) {
getProxy().getScheduler().runAsync(this, () -> {
loadConfig();
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistWaterfall.getConfigCache().prefix + CommandWhitelistWaterfall.getConfigCache().config_reloaded));
});
}
/**
* @param player Bungee Player
* @return commands available to the player
*/
public static HashSet<String> getCommands(ProxiedPlayer player) {
HashSet<String> commandList = new HashSet<>();
HashMap<String, CWGroup> groups = configCache.getGroupList();
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
if (s.getKey().equalsIgnoreCase("default"))
commandList.addAll(s.getValue().getCommands());
else if (player.hasPermission(s.getValue().getPermission()))
commandList.addAll(s.getValue().getCommands());
}
return commandList;
}
/**
* @param player Bungee Player
* @return subcommands unavailable for the player
*/
public static HashSet<String> getSuggestions(ProxiedPlayer player) {
HashMap<String, CWGroup> groups = configCache.getGroupList();
HashSet<String> suggestionList = new HashSet<>();
for (Map.Entry<String, CWGroup> s : groups.entrySet()) {
if (s.getKey().equalsIgnoreCase("default"))
suggestionList.addAll(s.getValue().getSubCommands());
if (player.hasPermission(s.getValue().getPermission())) continue;
suggestionList.addAll(s.getValue().getSubCommands());
}
return suggestionList;
}
/**
* @return Command denied message. Will use custom if command exists in any group.
*/
public static String getCommandDeniedMessage(String command) {
String commandDeniedMessage = configCache.command_denied;
HashMap<String, CWGroup> groups = configCache.getGroupList();
for (CWGroup group : groups.values()) {
if (group.getCommands().contains(command)) {
if (group.getCommandDeniedMessage() == null || group.getCommandDeniedMessage().isEmpty()) continue;
commandDeniedMessage = group.getCommandDeniedMessage();
break; // get first message we find
}
}
return commandDeniedMessage;
}
public static ArrayList<String> getServerCommands() {
ArrayList<String> serverCommands = new ArrayList<>();
for (Map.Entry<String, Command> command : CommandWhitelistWaterfall.getPlugin().getProxy().getPluginManager().getCommands()) {
serverCommands.add(command.getValue().getName());
}
return serverCommands;
}
}
@@ -1,106 +0,0 @@
package eu.endermite.commandwhitelist.waterfall.command;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class BungeeMainCommand extends Command implements TabExecutor {
public BungeeMainCommand(String name) {
super(name);
}
public void execute(CommandSender sender, String[] args) {
String label = getName();
ConfigCache configCache = CommandWhitelistWaterfall.getConfigCache();
BungeeAudiences audiences = CommandWhitelistWaterfall.getAudiences();
if (args.length == 0) {
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
return;
}
try {
CWCommand.CommandType commandType = CWCommand.CommandType.valueOf(args[0].toUpperCase());
switch (commandType) {
case RELOAD:
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistWaterfall.getConfigCache().prefix + configCache.no_permission));
return;
}
CommandWhitelistWaterfall.getPlugin().loadConfigAsync(sender);
return;
case ADD:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.no_permission));
return;
}
if (args.length == 3) {
if (CWCommand.addToWhitelist(configCache, args[2], args[1]))
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.added_to_whitelist));
else
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.group_doesnt_exist));
} else
audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>"));
return;
case REMOVE:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.no_permission));
return;
}
if (args.length == 3) {
if (CWCommand.removeFromWhitelist(configCache, args[2], args[1]))
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.removed_from_whitelist));
else
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.group_doesnt_exist));
} else
audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>"));
return;
case DUMP:
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistWaterfall.getConfigCache().prefix + CommandWhitelistWaterfall.getConfigCache().no_permission));
return;
}
audiences.sender(sender).sendMessage(Component.text("Dumping all available commands to a file..."));
if (CommandUtil.dumpAllBukkitCommands(CommandWhitelistWaterfall.getServerCommands(), new File("plugins/CommandWhitelist/command_dump.yml"))) {
audiences.sender(sender).sendMessage(Component.text("Commands dumped to command_dump.yml"));
} else {
audiences.sender(sender).sendMessage(Component.text("Failed to save the file."));
}
return;
case HELP:
default:
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
}
} catch (IllegalArgumentException e) {
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
}
return;
}
@Override
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
return CWCommand.commandSuggestions(
CommandWhitelistWaterfall.getConfigCache(),
CommandWhitelistWaterfall.getServerCommands(),
args,
sender.hasPermission(CWPermission.RELOAD.permission()),
sender.hasPermission(CWPermission.ADMIN.permission()),
CWCommand.ImplementationType.WATERFALL
);
}
}
@@ -1,48 +0,0 @@
package eu.endermite.commandwhitelist.waterfall.listeners;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.common.ConfigCache;
import eu.endermite.commandwhitelist.common.commands.CWCommand;
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
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.HashSet;
public class BungeeChatEventListener implements Listener {
@EventHandler
public void onChatEvent(net.md_5.bungee.api.event.ChatEvent event) {
if (event.isCancelled()) return;
if (!(event.getSender() instanceof ProxiedPlayer)) return;
if (!event.isProxyCommand()) return;
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String command = event.getMessage().toLowerCase();
if (command.startsWith("/"))
command = command.substring(1);
ConfigCache configCache = CommandWhitelistWaterfall.getConfigCache();
BungeeAudiences audiences = CommandWhitelistWaterfall.getAudiences();
String label = CommandUtil.getCommandLabel(command);
HashSet<String> commands = CommandWhitelistWaterfall.getCommands(player);
if (!commands.contains(label)) {
event.setCancelled(true);
CommandWhitelistWaterfall.getAudiences().player(player).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + CommandWhitelistWaterfall.getCommandDeniedMessage(label)));
return;
}
HashSet<String> bannedSubCommands = CommandWhitelistWaterfall.getSuggestions(player);
for (String bannedSubCommand : bannedSubCommands) {
if (command.startsWith(bannedSubCommand)) {
event.setCancelled(true);
audiences.player(player).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.subcommand_denied));
return;
}
}
}
}
@@ -1,25 +0,0 @@
package eu.endermite.commandwhitelist.waterfall.listeners;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.common.CommandUtil;
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
public class BungeeTabcompleteListener implements Listener {
@EventHandler
public void onTabcomplete(net.md_5.bungee.api.event.TabCompleteEvent event) {
if (!(event.getReceiver() instanceof ProxiedPlayer)) return;
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
if (event.getSuggestions().isEmpty()) return;
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
CommandUtil.filterSuggestions(
event.getCursor(),
event.getSuggestions(),
CommandWhitelistWaterfall.getSuggestions(player)
);
}
}
@@ -1,28 +0,0 @@
package eu.endermite.commandwhitelist.waterfall.listeners;
import eu.endermite.commandwhitelist.common.CWPermission;
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import java.util.HashMap;
public class WaterfallDefineCommandsListener implements Listener {
@EventHandler
public void onProxyDefineCommandsEvent(io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent event) {
if (event.getReceiver() instanceof ProxiedPlayer) {
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
HashMap<String, Command> commandHashMap = new HashMap<>();
CommandWhitelistWaterfall.getCommands(player).forEach(cmdName ->
CommandWhitelistWaterfall.getPlugin().getProxy().getPluginManager().getCommands()
.stream()
.filter(commandEntry -> cmdName.equalsIgnoreCase(commandEntry.getValue().getName()))
.forEach(commandEntry -> commandHashMap.put(commandEntry.getKey(), commandEntry.getValue())));
event.getCommands().values().removeIf((cmd) -> !commandHashMap.containsValue(cmd));
}
}
}
@@ -1,5 +0,0 @@
name: CommandWhitelist
author: YouHaveTrouble
version: ${project.version}
main: eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall
description: You decide what commands players can use or tab complete on your server!
+72 -10
View File
@@ -6,21 +6,15 @@
<groupId>eu.endermite.commandwhitelist</groupId> <groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId> <artifactId>CommandWhitelist</artifactId>
<version>2.6.0</version> <version>3.0.0</version>
<modules>
<module>CommandWhitelistCommon</module>
<module>CommandWhitelistBukkit</module>
<module>CommandWhitelistVelocity</module>
<module>CommandWhitelistWaterfall</module>
</modules>
<packaging>pom</packaging>
<name>CommandWhitelist</name> <name>CommandWhitelist</name>
<description>Control what commands players can use</description> <description>Control what commands players can use</description>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<website>https://youhavetrouble.me</website>
</properties> </properties>
<build> <build>
@@ -47,6 +41,16 @@
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>${project.name}-${project.version}</finalName> <finalName>${project.name}-${project.version}</finalName>
<relocations>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>me.youhavetrouble</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.thatsmusic99</pattern>
<shadedPattern>me.youhavetrouble</shadedPattern>
</relocation>
</relocations>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
@@ -61,18 +65,76 @@
</build> </build>
<repositories> <repositories>
<repository>
<id>pluginwiki-repo</id>
<url>https://ci.pluginwiki.us/plugin/repository/everything/</url>
</repository>
<repository> <repository>
<id>sonatype</id> <id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url> <url>https://oss.sonatype.org/content/groups/public/</url>
</repository> </repository>
<repository>
<id>velocitypowered-repo</id>
<url>https://repo.velocitypowered.com/releases/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency>
<groupId>com.github.thatsmusic99</groupId>
<artifactId>ConfigurationMaster-API</artifactId>
<version>v2.0.0-BETA-6</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId> <artifactId>adventure-api</artifactId>
<version>4.11.0</version> <version>4.13.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.13.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.waterfallmc</groupId>
<artifactId>waterfall-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
+2 -1
View File
@@ -1,6 +1,8 @@
Command Whitelist is a plugin that allows you to control Command Whitelist is a plugin that allows you to control
precisely what commands players can see and use. precisely what commands players can see and use.
<h1>WARNING: This is an experimental branch, literally everything here is subject to change</h1>
[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/youhavetrouble/commandwhitelist?style=flat-square)](https://www.codefactor.io/repository/github/youhavetrouble/commandwhitelist) [![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/youhavetrouble/commandwhitelist?style=flat-square)](https://www.codefactor.io/repository/github/youhavetrouble/commandwhitelist)
[![GitHub all releases](https://img.shields.io/github/downloads/youhavetrouble/commandwhitelist/total?style=flat-square&label=direct%20release%20downloads)](https://github.com/YouHaveTrouble/CommandWhitelist/releases) [![GitHub all releases](https://img.shields.io/github/downloads/youhavetrouble/commandwhitelist/total?style=flat-square&label=direct%20release%20downloads)](https://github.com/YouHaveTrouble/CommandWhitelist/releases)
[![Discord](https://img.shields.io/discord/821565102108573706?style=flat-square&color=%237289da&label=Discord)](https://discord.gg/j8KK5dGBps) [![Discord](https://img.shields.io/discord/821565102108573706?style=flat-square&color=%237289da&label=Discord)](https://discord.gg/j8KK5dGBps)
@@ -15,7 +17,6 @@ precisely what commands players can see and use.
<li>Overwrite default "no such command" message with your branding <li>Overwrite default "no such command" message with your branding
<li>Block tab completion</li> <li>Block tab completion</li>
<li>Block command execution</li> <li>Block command execution</li>
<li>Block completion and execution of specified subcommands</li>
</ul> </ul>
<b>Compatible versions</b>: 1.13+ <b>Compatible versions</b>: 1.13+
@@ -0,0 +1,60 @@
package me.youhavetrouble.commandwhitelist.bukkit;
import me.youhavetrouble.commandwhitelist.bukkit.listeners.CommandExecuteListener;
import me.youhavetrouble.commandwhitelist.bukkit.listeners.CommandSendListener;
import me.youhavetrouble.commandwhitelist.bukkit.listeners.CommandTabCompleteListener;
import me.youhavetrouble.commandwhitelist.common.CWConfig;
import me.youhavetrouble.commandwhitelist.common.commands.CWCommand;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.concurrent.CompletableFuture;
public class CommandWhitelistBukkit extends JavaPlugin {
private CWConfig CWConfig;
private BukkitAudiences audiences;
@Override
public void onEnable() {
reloadPluginConfig();
audiences = BukkitAudiences.create(this);
getServer().getPluginManager().registerEvents(new CommandSendListener(this), this);
getServer().getPluginManager().registerEvents(new CommandExecuteListener(this), this);
getServer().getPluginManager().registerEvents(new CommandTabCompleteListener(this), this);
}
private void reloadPluginConfig() {
File configFile = new File("plugins/CommandWhitelist/config.yml");
if (CWConfig != null) {
CWConfig.reloadConfig();
return;
}
try {
CWConfig = new CWConfig(configFile, true, getSLF4JLogger());
} catch (NoSuchMethodError e) {
CWConfig = new CWConfig(configFile, true, null);
}
}
public CompletableFuture<Void> reloadPluginConfig(CommandSender sender) {
return CompletableFuture.runAsync(() -> {
reloadPluginConfig();
try {
for (Player p : Bukkit.getOnlinePlayers()) {
p.updateCommands();
}
} catch (Exception ignored) {}
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CWConfig.prefix + CWConfig.config_reloaded));
});
}
public CWConfig getCWConfig() {
return CWConfig;
}
}
@@ -0,0 +1,33 @@
package me.youhavetrouble.commandwhitelist.bukkit.listeners;
import me.youhavetrouble.commandwhitelist.bukkit.CommandWhitelistBukkit;
import me.youhavetrouble.commandwhitelist.common.CWCommandEntry;
import me.youhavetrouble.commandwhitelist.common.CWPermission;
import me.youhavetrouble.commandwhitelist.common.CWPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandExecuteListener implements Listener {
private final CommandWhitelistBukkit plugin;
public CommandExecuteListener(CommandWhitelistBukkit plugin ) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCommandPreProcess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
CWPlayer cwPlayer = new CWPlayer(player);
for (CWCommandEntry entry : cwPlayer.getCommands(plugin.getCWConfig())) {
if (entry.matches(event.getMessage())) return;
}
event.setCancelled(true);
}
}
@@ -0,0 +1,39 @@
package me.youhavetrouble.commandwhitelist.bukkit.listeners;
import me.youhavetrouble.commandwhitelist.bukkit.CommandWhitelistBukkit;
import me.youhavetrouble.commandwhitelist.common.CWCommandEntry;
import me.youhavetrouble.commandwhitelist.common.CWPermission;
import me.youhavetrouble.commandwhitelist.common.CWPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandSendEvent;
import java.util.Iterator;
public class CommandSendListener implements Listener {
private final CommandWhitelistBukkit plugin;
public CommandSendListener(CommandWhitelistBukkit plugin) {
this.plugin = plugin;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onCommandSend(PlayerCommandSendEvent event) {
Player player = event.getPlayer();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
Iterator<String> iterator = event.getCommands().iterator();
CWPlayer cwPlayer = new CWPlayer(player);
while (iterator.hasNext()) {
String command = iterator.next();
for (CWCommandEntry entry : cwPlayer.getCommands(plugin.getCWConfig())) {
if (entry.argumentMatches(command, 0)) continue;
iterator.remove();
break;
}
}
}
}
@@ -0,0 +1,69 @@
package me.youhavetrouble.commandwhitelist.bukkit.listeners;
import me.youhavetrouble.commandwhitelist.bukkit.CommandWhitelistBukkit;
import me.youhavetrouble.commandwhitelist.common.CWCommandEntry;
import me.youhavetrouble.commandwhitelist.common.CWPermission;
import me.youhavetrouble.commandwhitelist.common.CWPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.TabCompleteEvent;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class CommandTabCompleteListener implements Listener {
private final CommandWhitelistBukkit plugin;
public CommandTabCompleteListener(CommandWhitelistBukkit plugin ) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCommandTabComplete(TabCompleteEvent event) {
if (!(event.getSender() instanceof Player)) return;
Player player = (Player) event.getSender();
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
String buffer = event.getBuffer();
if ((buffer.split(" ").length == 1 && !buffer.endsWith(" ")) || !buffer.startsWith("/")) {
plugin.getCWConfig().debug("Actively prevented "+event.getSender().getName()+"'s tab completion (sus packet)");
event.setCancelled(true);
return;
}
if (event.getCompletions().isEmpty()) return;
String[] split = buffer.split(" ");
if (split.length == 0) return;
String[] splitWithoutLastArg = new String[split.length - 1];
System.arraycopy(split, 0, splitWithoutLastArg, 0, splitWithoutLastArg.length);
String commandWithoutLastArg = String.join(" ", splitWithoutLastArg);
CWPlayer cwPlayer = new CWPlayer(player);
List<CWCommandEntry> validCompletions = new ArrayList<>();
for (CWCommandEntry entry : cwPlayer.getCommands(plugin.getCWConfig())) {
if (!entry.partiallyMatches(commandWithoutLastArg)) continue;
validCompletions.add(entry);
}
int index = split.length - 1;
List<String> completions = event.getCompletions();
Iterator<String> iterator = completions.iterator();
while (iterator.hasNext()) {
String completion = iterator.next();
for (CWCommandEntry entry : validCompletions) {
if (entry.argumentMatches(completion, index)) continue;
iterator.remove();
break;
}
}
event.setCompletions(completions);
}
}
@@ -0,0 +1,83 @@
package me.youhavetrouble.commandwhitelist.common;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
public class CWCommandEntry {
private final String rawEntry;
private final List<Pattern> parts;
protected CWCommandEntry(String command) {
this.rawEntry = command;
String[] parts = command.split(" ");
this.parts = new ArrayList<>(parts.length);
for (String part : parts) {
Pattern pattern = Pattern.compile(part);
this.parts.add(pattern);
}
}
/**
* Gets the command parts.
* @return command parts
*/
public List<Pattern> getParts() {
return Collections.unmodifiableList(parts);
}
/**
* Gets the raw command entry as given in the constructor.
* @return raw command entry
*/
public String getRawEntry() {
return rawEntry;
}
/**
* Checks if a full command input matches this command entry. Input is a match if all entry slices match the
* corresponding command slices, even if there are more command slices than entry slices.
* @param command full command input
* @return true if the command matches this command entry
*/
public boolean matches(String command) {
if (command == null) return false;
if (command.startsWith("/")) command = command.substring(1); // Remove leading slash (if present)
String[] parts = command.split(" ");
if (parts.length < this.parts.size()) return false;
for (int i = 0; i < this.parts.size(); i++) {
if (!argumentMatches(parts[i], i)) return false;
}
return true;
}
/**
* Checks if a command input partially matches this command entry.
* @param command command input
* @return true if the command partially matches this command entry
*/
public boolean partiallyMatches(String command) {
if (command == null) return false;
if (command.startsWith("/")) command = command.substring(1); // Remove leading slash (if present)
String[] parts = command.split(" ");
for (int i = 0; i < this.parts.size() || i < parts.length; i++) {
if (!argumentMatches(parts[i], i)) return false;
}
return true;
}
/**
* Checks if a command argument matches this command entry.
* @param argument command argument
* @param index argument index
* @return true if the argument matches this command entry
*/
public boolean argumentMatches(String argument, int index) {
if (index < 0 || index >= parts.size()) return false;
return parts.get(index).matcher(argument).matches();
}
}
@@ -1,4 +1,4 @@
package eu.endermite.commandwhitelist.common; package me.youhavetrouble.commandwhitelist.common;
import io.github.thatsmusic99.configurationmaster.api.ConfigFile; import io.github.thatsmusic99.configurationmaster.api.ConfigFile;
import io.github.thatsmusic99.configurationmaster.api.ConfigSection; import io.github.thatsmusic99.configurationmaster.api.ConfigSection;
@@ -7,7 +7,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
public class ConfigCache { public class CWConfig {
private final File configFile; private final File configFile;
private ConfigFile config; private ConfigFile config;
@@ -19,7 +19,7 @@ public class ConfigCache {
public boolean useProtocolLib = false; public boolean useProtocolLib = false;
public boolean debug = false; public boolean debug = false;
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) { public CWConfig(File configFile, boolean canDoProtocolLib, Object logger) {
this.configFile = configFile; this.configFile = configFile;
this.canDoProtocolLib = canDoProtocolLib; this.canDoProtocolLib = canDoProtocolLib;
this.logger = logger; this.logger = logger;
@@ -30,11 +30,14 @@ public class ConfigCache {
public boolean reloadConfig() { public boolean reloadConfig() {
createFiles(); createFiles();
config = ConfigFile.loadConfig(configFile); try {
config = ConfigFile.loadConfig(configFile);
} catch (Exception e) {
throw new RuntimeException(e);
}
config.addDefault("messages.prefix", "CommandWhitelist > "); config.addDefault("messages.prefix", "CommandWhitelist > ");
config.addDefault("messages.command_denied", "No such command."); config.addDefault("messages.command_denied", "No such command.");
config.addDefault("messages.subcommand_denied", "You cannot use this subcommand");
config.addDefault("messages.no_permission", "<red>You don't have permission to do this."); config.addDefault("messages.no_permission", "<red>You don't have permission to do this.");
config.addDefault("messages.no_such_subcommand", "<red>No subcommand by that name."); config.addDefault("messages.no_such_subcommand", "<red>No subcommand by that name.");
config.addDefault("messages.config_reloaded", "<yellow>Configuration reloaded."); config.addDefault("messages.config_reloaded", "<yellow>Configuration reloaded.");
@@ -75,12 +78,8 @@ public class ConfigCache {
defaultCommands.add("tpaccept"); defaultCommands.add("tpaccept");
defaultCommands.add("tpdeny"); defaultCommands.add("tpdeny");
defaultCommands.add("warp"); defaultCommands.add("warp");
List<String> defaultSubcommands = new ArrayList<>();
defaultSubcommands.add("help about");
String defaultCustomCommandDeniedMessage = ""; config.addDefault("groups.default", new CWGroup("default", defaultCommands).serialize());
config.addDefault("groups.default", new CWGroup("default", defaultCommands, defaultSubcommands, defaultCustomCommandDeniedMessage).serialize());
prefix = config.getString("messages.prefix"); prefix = config.getString("messages.prefix");
command_denied = config.getString("messages.command_denied"); command_denied = config.getString("messages.command_denied");
@@ -106,7 +105,7 @@ public class ConfigCache {
try { try {
config.save(); config.save();
return true; return true;
} catch (IOException e) { } catch (Exception e) {
return false; return false;
} }
} }
@@ -134,16 +133,8 @@ public class ConfigCache {
if (commands.contains(cmd)) continue; if (commands.contains(cmd)) continue;
commands.add(cmd); commands.add(cmd);
} }
List<String> subCommands = new ArrayList<>();
for (String subCmd : section.getStringList(id + ".subcommands")) { return new CWGroup(id, commands);
if (!subCmd.contains(" ")) {
warn("CommandWhitelist - \"" + subCmd + "\" is not a subcommand. Skipping it.");
continue;
}
subCommands.add(subCmd);
}
String customCommandDeniedMessage = section.getString(id + ".custom_command_denied_message");
return new CWGroup(id, commands, subCommands, customCommandDeniedMessage);
} }
public void saveCWGroup(String id, CWGroup group) { public void saveCWGroup(String id, CWGroup group) {
@@ -0,0 +1,46 @@
package me.youhavetrouble.commandwhitelist.common;
import java.util.*;
public class CWGroup {
private final String id;
private final HashSet<CWCommandEntry> commands = new HashSet<>();
public CWGroup(String id, Collection<String> commands) {
this.id = id;
for (String command : commands) {
this.commands.add(new CWCommandEntry(command));
}
}
public String getId() {
return id;
}
public String getPermission() {
return "commandwhitelist.group." + id;
}
public Set<CWCommandEntry> getCommands() {
return commands;
}
public void addCommand(String command) {
this.commands.add(new CWCommandEntry(command));
}
public void removeCommand(String command) {
commands.removeIf(cwCommandEntry -> cwCommandEntry.getRawEntry().equals(command));
}
public HashMap<String, Object> serialize() {
HashMap<String, Object> serializedGroup = new LinkedHashMap<>();
List<String> commands = new ArrayList<>();
for (CWCommandEntry command : this.commands) {
commands.add(command.getRawEntry());
}
serializedGroup.put("commands", commands);
return serializedGroup;
}
}
@@ -1,4 +1,4 @@
package eu.endermite.commandwhitelist.common; package me.youhavetrouble.commandwhitelist.common;
public enum CWPermission { public enum CWPermission {
@@ -19,14 +19,9 @@ public enum CWPermission {
/** /**
* Allows to check specific group permission * Allows to check specific group permission
* *
* @param configCache
* @param groupId
* @return
*/ */
public static String getGroupPermission(ConfigCache configCache, String groupId) { public static String getGroupPermission(String groupId) {
if (configCache.getGroupList().containsKey(groupId)) return "commandwhitelist.group." + groupId;
return configCache.getGroupList().get(groupId).getPermission();
return null;
} }
} }
@@ -0,0 +1,57 @@
package me.youhavetrouble.commandwhitelist.common;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Represents a player on any supported platform.
*/
public class CWPlayer {
private org.bukkit.entity.Player bukkitPlayer;
private com.velocitypowered.api.proxy.Player velocityPlayer;
private net.md_5.bungee.api.connection.ProxiedPlayer waterfallPlayer;
public CWPlayer(org.bukkit.entity.Player player) {
this.bukkitPlayer = player;
}
public CWPlayer(com.velocitypowered.api.proxy.Player player) {
this.velocityPlayer = player;
}
public CWPlayer(net.md_5.bungee.api.connection.ProxiedPlayer player) {
this.waterfallPlayer = player;
}
/**
* Checks if this player has a permission.
* @param permission Permission to check
* @return Whether this player has the permission
*/
public boolean hasPermission(String permission) {
if (bukkitPlayer != null) return bukkitPlayer.hasPermission(permission);
if (velocityPlayer != null) return velocityPlayer.hasPermission(permission);
if (waterfallPlayer != null) return waterfallPlayer.hasPermission(permission);
return false;
}
/**
* Get the commands that this player can use.
* @param CWConfig Current configuration cache
* @return Set of commands that this player can use
*/
public Set<CWCommandEntry> getCommands(CWConfig CWConfig) {
HashSet<CWCommandEntry> commands = new HashSet<>();
Map<String, CWGroup> groups = CWConfig.getGroupList();
for (Map.Entry<String, CWGroup> groupEntry : groups.entrySet()) {
CWGroup group = groupEntry.getValue();
String groupId = groupEntry.getKey();
if (groupId.equalsIgnoreCase("default")) commands.addAll(group.getCommands());
else if (hasPermission(group.getPermission())) commands.addAll(group.getCommands());
}
return commands;
}
}
@@ -1,4 +1,4 @@
package eu.endermite.commandwhitelist.common; package me.youhavetrouble.commandwhitelist.common;
import io.github.thatsmusic99.configurationmaster.api.ConfigFile; import io.github.thatsmusic99.configurationmaster.api.ConfigFile;
@@ -10,28 +10,13 @@ import java.util.List;
public class CommandUtil { public class CommandUtil {
/**
* Filters blocked command suggestions from provided collection of strings public static List<String> filterCommandList(Collection<String> allCommands, Collection<String> allowedCommands) {
* List<String> filteredCommands = new ArrayList<>();
* @param buffer Command buffer
* @param suggestions Full suggestions list
* @param blockedSubCommands Subcommands to filter out
* @return Filtered list of suggestions return filteredCommands;
*/
public static List<String> filterSuggestions(String buffer, Collection<String> suggestions, Collection<String> blockedSubCommands) {
if (buffer.startsWith("/"))
buffer = buffer.substring(1);
List<String> suggestionsList = new ArrayList<>(suggestions);
if (suggestions.isEmpty() || blockedSubCommands.isEmpty()) return suggestionsList;
for (String s : blockedSubCommands) {
String scommand = cutLastArgument(s);
if (buffer.startsWith(scommand)) {
String slast = getLastArgument(s);
while (suggestionsList.contains(slast))
suggestionsList.remove(slast);
}
}
return suggestionsList;
} }
/** /**
@@ -80,15 +65,10 @@ public class CommandUtil {
parent.mkdir(); parent.mkdir();
if (!file.exists()) if (!file.exists())
file.createNewFile(); file.createNewFile();
} catch (IOException e) { ConfigFile dumpFile = ConfigFile.loadConfig(file);
return false; dumpFile.set("commands", serverCommands);
}
ConfigFile dumpFile = ConfigFile.loadConfig(file);
dumpFile.set("commands", serverCommands);
try {
dumpFile.save(); dumpFile.save();
} catch (IOException e) { } catch (Exception e) {
return false; return false;
} }
return true; return true;
@@ -1,8 +1,9 @@
package eu.endermite.commandwhitelist.common.commands; package me.youhavetrouble.commandwhitelist.common.commands;
import eu.endermite.commandwhitelist.common.CWGroup; import me.youhavetrouble.commandwhitelist.common.CWGroup;
import eu.endermite.commandwhitelist.common.ConfigCache; import me.youhavetrouble.commandwhitelist.common.CWConfig;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import java.util.ArrayList; import java.util.ArrayList;
@@ -13,38 +14,38 @@ public class CWCommand {
public static MiniMessage miniMessage = MiniMessage.miniMessage(); public static MiniMessage miniMessage = MiniMessage.miniMessage();
public static boolean addToWhitelist(ConfigCache configCache, String command, String group) { public static boolean addToWhitelist(CWConfig CWConfig, String command, String group) {
CWGroup cwGroup = configCache.getGroupList().get(group); CWGroup cwGroup = CWConfig.getGroupList().get(group);
if (cwGroup == null) return false; if (cwGroup == null) return false;
cwGroup.addCommand(command); cwGroup.addCommand(command);
configCache.saveCWGroup(group, cwGroup); CWConfig.saveCWGroup(group, cwGroup);
return true; return true;
} }
public static boolean removeFromWhitelist(ConfigCache configCache, String command, String group) { public static boolean removeFromWhitelist(CWConfig CWConfig, String command, String group) {
CWGroup cwGroup = configCache.getGroupList().get(group); CWGroup cwGroup = CWConfig.getGroupList().get(group);
if (cwGroup == null) if (cwGroup == null)
return false; return false;
cwGroup.removeCommand(command); cwGroup.removeCommand(command);
configCache.saveCWGroup(group, cwGroup); CWConfig.saveCWGroup(group, cwGroup);
return true; return true;
} }
public static Component helpComponent(String baseCommand, boolean showReloadCommand, boolean showAdminCommands) { public static Component helpComponent(String baseCommand, boolean showReloadCommand, boolean showAdminCommands) {
Component component = miniMessage.deserialize("<rainbow><bold>CommandWhitelist by YouHaveTrouble</bold>") final TextComponent.Builder builder = Component.text();
.append(Component.newline()); builder.append(miniMessage.deserialize("<rainbow><bold>CommandWhitelist by YouHaveTrouble</bold>"), Component.newline());
component = component.append(Component.text(baseCommand + " help").color(NamedTextColor.AQUA).append(Component.text(" - Displays this message").color(NamedTextColor.BLUE))); builder.append(Component.text(baseCommand + " help", NamedTextColor.AQUA), Component.text(" - Displays this message", NamedTextColor.BLUE));
if (showReloadCommand) { if (showReloadCommand) {
component = component.append(Component.newline()); builder.append(Component.newline());
component = component.append(Component.text(baseCommand + " reload").color(NamedTextColor.AQUA).append(Component.text(" - Reloads plugin configuration").color(NamedTextColor.BLUE))); builder.append(Component.text(baseCommand + " reload", NamedTextColor.AQUA), Component.text(" - Reloads plugin configuration", NamedTextColor.BLUE));
} }
if (showAdminCommands) { if (showAdminCommands) {
component = component.append(Component.newline()); builder.append(Component.newline());
component = component.append(Component.text(baseCommand + " add <group> <command>").color(NamedTextColor.AQUA).append(Component.text(" - Add a command to selected permission group").color(NamedTextColor.BLUE))); builder.append(Component.text(baseCommand + " add <group> <command>", NamedTextColor.AQUA), Component.text(" - Add a command to selected permission group", NamedTextColor.BLUE));
component = component.append(Component.newline()); builder.append(Component.newline());
component = component.append(Component.text(baseCommand + " remove <group> <command>").color(NamedTextColor.AQUA).append(Component.text(" - Removes a command from selected permission group").color(NamedTextColor.BLUE))); builder.append(Component.text(baseCommand + " remove <group> <command>", NamedTextColor.AQUA), Component.text(" - Removes a command from selected permission group", NamedTextColor.BLUE));
} }
return component; return builder.build();
} }
public enum CommandType { public enum CommandType {
@@ -56,7 +57,7 @@ public class CWCommand {
} }
public static List<String> commandSuggestions( public static List<String> commandSuggestions(
ConfigCache config, CWConfig config,
Collection<String> serverCommands, Collection<String> serverCommands,
String[] args, boolean reloadPerm, String[] args, boolean reloadPerm,
boolean adminPerm, boolean adminPerm,
@@ -103,10 +104,7 @@ public class CWCommand {
if (!adminPerm) return list; if (!adminPerm) return list;
CWGroup group = config.getGroupList().get(args[1]); CWGroup group = config.getGroupList().get(args[1]);
if (group == null) return list; if (group == null) return list;
for (String s : group.getCommands()) { // TODO
if (s.startsWith(args[2]))
list.add(s);
}
return list; return list;
} }
if (args[0].equalsIgnoreCase("add")) { if (args[0].equalsIgnoreCase("add")) {
@@ -0,0 +1,13 @@
package me.youhavetrouble.commandwhitelist.common.commands;
import java.util.Collection;
public interface CWCommandInterface {
void execute(String[] args);
Collection<String> tabComplete(String[] args);
String getPermission();
}
+5
View File
@@ -0,0 +1,5 @@
groups:
default:
commands:
- "spawn"
- "help version"
@@ -1,14 +1,14 @@
name: CommandWhitelist name: "${project.name}"
prefix: CommandWhitelist
version: ${project.version} version: ${project.version}
api-version: 1.13 api-version: 1.13
main: eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit main: "${project.groupId}.bukkit.CommandWhitelistBukkit"
authors: [YouHaveTrouble] authors:
website: youhavetrouble.me - "YouHaveTrouble"
website: "${project.url}"
folia-supported: true folia-supported: true
softdepend: softdepend:
- ProtocolLib - ProtocolLib
description: Control what commands players can use description: "${project.description}"
commands: commands:
commandwhitelist: commandwhitelist:
aliases: aliases: