mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e5b5b5fc7 | |||
| 67ca2c2458 | |||
| 99f7c245da | |||
| cd4c41f1f2 | |||
| 8a86568ce9 | |||
| b08234d268 | |||
| 2c7a089fae | |||
| 41ff6d9d3e | |||
| 9e13c7b2f1 | |||
| 0716514787 | |||
| 428ee93996 | |||
| 8b45057544 | |||
| 29f7b6438e | |||
| 8de56d2863 | |||
| d8421126e2 | |||
| 0554ef59f7 | |||
| 0567640eea | |||
| fd5bccc985 | |||
| cacc09365b | |||
| ebc8a823f2 | |||
| 3697bc72ce | |||
| 78b1a646f2 | |||
| b0a6fb2144 | |||
| 2fafc31a10 | |||
| bbb2ffb2c9 | |||
| 1a309ffcd3 | |||
| 9f1beac562 | |||
| 5dc67e0122 | |||
| 7538db2a7f | |||
| 568e7a5ca4 | |||
| 7cb94cce4b | |||
| 7f6315b6b5 | |||
| bbc0e44660 | |||
| 9e255076b0 | |||
| a91af744fd | |||
| 930f73d60a | |||
| c5fdaa95f8 | |||
| 87fc3d7da3 | |||
| 0cc2633604 | |||
| d6909b4f25 | |||
| cd3d527119 | |||
| d43bde0750 |
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>2.5.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Bukkit</artifactId>
|
<artifactId>Bukkit</artifactId>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.3.0-SNAPSHOT</version>
|
<version>3.2.4</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -86,13 +86,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
<version>1.19-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-platform-bukkit</artifactId>
|
<artifactId>adventure-platform-bukkit</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<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>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -104,13 +110,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
<version>4.6.0</version>
|
<version>5.0.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>3.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+51
-15
@@ -1,27 +1,26 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit;
|
package eu.endermite.commandwhitelist.bukkit;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.command.MainCommandExecutor;
|
import eu.endermite.commandwhitelist.bukkit.command.BukkitCommandExecutor;
|
||||||
import eu.endermite.commandwhitelist.bukkit.listeners.*;
|
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.bukkit.listeners.protocollib.PacketCommandPreProcessListener;
|
||||||
import eu.endermite.commandwhitelist.bukkit.listeners.protocollib.PacketCommandSendListener;
|
|
||||||
import eu.endermite.commandwhitelist.common.CWGroup;
|
import eu.endermite.commandwhitelist.common.CWGroup;
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.help.HelpTopic;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CommandWhitelistBukkit extends JavaPlugin {
|
public class CommandWhitelistBukkit extends JavaPlugin {
|
||||||
|
|
||||||
@@ -41,11 +40,10 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
|||||||
|
|
||||||
if (!getConfigCache().useProtocolLib || protocollib == null || !protocollib.isEnabled()) {
|
if (!getConfigCache().useProtocolLib || protocollib == null || !protocollib.isEnabled()) {
|
||||||
getServer().getPluginManager().registerEvents(new PlayerCommandPreProcessListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerCommandPreProcessListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this);
|
|
||||||
} else {
|
} else {
|
||||||
PacketCommandPreProcessListener.protocol(this);
|
PacketCommandPreProcessListener.protocol(this);
|
||||||
PacketCommandSendListener.protocol(this);
|
getLogger().warning("Using ProtocolLib for command filter!");
|
||||||
getLogger().info(ChatColor.AQUA + "Using ProtocolLib for command filter!");
|
getLogger().warning("Please make sure you actually need this. This is not a \"better way to do it\".");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Use paper's async tab completions if possible
|
// Use paper's async tab completions if possible
|
||||||
@@ -54,10 +52,11 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
|||||||
} catch (ClassNotFoundException ignored) {
|
} catch (ClassNotFoundException ignored) {
|
||||||
}
|
}
|
||||||
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
|
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this);
|
||||||
|
|
||||||
PluginCommand command = getCommand("commandwhitelist");
|
PluginCommand command = getCommand("commandwhitelist");
|
||||||
if (command != null) {
|
if (command != null) {
|
||||||
MainCommandExecutor executor = new MainCommandExecutor();
|
BukkitCommandExecutor executor = new BukkitCommandExecutor();
|
||||||
command.setExecutor(executor);
|
command.setExecutor(executor);
|
||||||
command.setTabCompleter(executor);
|
command.setTabCompleter(executor);
|
||||||
}
|
}
|
||||||
@@ -67,19 +66,26 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
|||||||
|
|
||||||
private void reloadPluginConfig() {
|
private void reloadPluginConfig() {
|
||||||
File configFile = new File("plugins/CommandWhitelist/config.yml");
|
File configFile = new File("plugins/CommandWhitelist/config.yml");
|
||||||
if (configCache == null)
|
if (configCache == null) {
|
||||||
|
try {
|
||||||
configCache = new ConfigCache(configFile, true, getSLF4JLogger());
|
configCache = new ConfigCache(configFile, true, getSLF4JLogger());
|
||||||
else
|
} catch (NoSuchMethodError e) {
|
||||||
|
configCache = new ConfigCache(configFile, true, null);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
configCache.reloadConfig();
|
configCache.reloadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadPluginConfig(CommandSender sender) {
|
public void reloadPluginConfig(CommandSender sender) {
|
||||||
getServer().getScheduler().runTaskAsynchronously(this, () -> {
|
getServer().getScheduler().runTaskAsynchronously(this, () -> {
|
||||||
reloadPluginConfig();
|
reloadPluginConfig();
|
||||||
|
try {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
p.updateCommands();
|
p.updateCommands();
|
||||||
}
|
}
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.config_reloaded));
|
} catch (Exception ignored) {}
|
||||||
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.config_reloaded));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,4 +132,34 @@ public class CommandWhitelistBukkit extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return suggestionList;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-16
@@ -2,19 +2,18 @@ package eu.endermite.commandwhitelist.bukkit.command;
|
|||||||
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||||
|
import eu.endermite.commandwhitelist.common.CommandUtil;
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.help.HelpTopic;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MainCommandExecutor implements TabExecutor {
|
public class BukkitCommandExecutor implements TabExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
@@ -30,37 +29,49 @@ public class MainCommandExecutor implements TabExecutor {
|
|||||||
switch (commandType) {
|
switch (commandType) {
|
||||||
case RELOAD:
|
case RELOAD:
|
||||||
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CommandWhitelistBukkit.getPlugin().reloadPluginConfig(sender);
|
CommandWhitelistBukkit.getPlugin().reloadPluginConfig(sender);
|
||||||
return true;
|
return true;
|
||||||
case ADD:
|
case ADD:
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
if (CWCommand.addToWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1]))
|
if (CWCommand.addToWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1]))
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().added_to_whitelist, 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
|
else
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
|
||||||
} else
|
} else
|
||||||
audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>"));
|
audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>"));
|
||||||
return true;
|
return true;
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().no_permission));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
if (CWCommand.removeFromWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1]))
|
if (CWCommand.removeFromWhitelist(CommandWhitelistBukkit.getConfigCache(), args[2], args[1]))
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().removed_from_whitelist, 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
|
else
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist, args[1])));
|
||||||
} else
|
} else
|
||||||
audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>"));
|
audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>"));
|
||||||
return true;
|
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:
|
case HELP:
|
||||||
default:
|
default:
|
||||||
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
||||||
@@ -73,10 +84,13 @@ public class MainCommandExecutor implements TabExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
List<String> serverCommands = new ArrayList<>();
|
return CWCommand.commandSuggestions(
|
||||||
for (HelpTopic topic : Bukkit.getHelpMap().getHelpTopics()) {
|
CommandWhitelistBukkit.getConfigCache(),
|
||||||
serverCommands.add(topic.getName());
|
CommandWhitelistBukkit.getServerCommands(),
|
||||||
}
|
args,
|
||||||
return CWCommand.commandSuggestions(CommandWhitelistBukkit.getConfigCache(), serverCommands, args, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission()));
|
sender.hasPermission(CWPermission.RELOAD.permission()),
|
||||||
|
sender.hasPermission(CWPermission.ADMIN.permission()),
|
||||||
|
CWCommand.ImplementationType.BUKKIT
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-5
@@ -1,6 +1,7 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit.listeners;
|
package eu.endermite.commandwhitelist.bukkit.listeners;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
||||||
|
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||||
import eu.endermite.commandwhitelist.common.CommandUtil;
|
import eu.endermite.commandwhitelist.common.CommandUtil;
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
@@ -16,15 +17,17 @@ public class PlayerCommandPreProcessListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
|
public void PlayerCommandSendEvent(org.bukkit.event.player.PlayerCommandPreprocessEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.hasPermission("commandwhitelist.bypass")) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
String label = CommandUtil.getCommandLabel(event.getMessage().toLowerCase());
|
String caseSensitiveLabel = CommandUtil.getCommandLabel(event.getMessage());
|
||||||
|
String label = caseSensitiveLabel.toLowerCase();
|
||||||
|
event.setMessage(event.getMessage().replaceFirst(caseSensitiveLabel, label));
|
||||||
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
|
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
|
||||||
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
|
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
|
||||||
|
|
||||||
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
|
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
|
||||||
if (!commands.contains(label)) {
|
if (!commands.contains(label)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
audiences.player(player).sendMessage(CWCommand.miniMessage.parse(config.prefix + config.command_denied));
|
audiences.player(player).sendMessage(CWCommand.miniMessage.deserialize(config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,11 +35,10 @@ public class PlayerCommandPreProcessListener implements Listener {
|
|||||||
for (String bannedSubCommand : bannedSubCommands) {
|
for (String bannedSubCommand : bannedSubCommands) {
|
||||||
if (event.getMessage().toLowerCase().substring(1).startsWith(bannedSubCommand)) {
|
if (event.getMessage().toLowerCase().substring(1).startsWith(bannedSubCommand)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
audiences.player(player).sendMessage(CWCommand.miniMessage.parse(config.prefix + config.subcommand_denied));
|
audiences.player(player).sendMessage(CWCommand.miniMessage.deserialize(config.prefix + config.subcommand_denied));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-2
@@ -17,8 +17,15 @@ public class TabCompleteBlockerListener implements Listener {
|
|||||||
Player player = (Player) event.getSender();
|
Player player = (Player) event.getSender();
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
String buffer = event.getBuffer();
|
String buffer = event.getBuffer();
|
||||||
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) event.setCancelled(true);
|
if (!buffer.endsWith(" ") && buffer.split(" ").length == 1) {
|
||||||
if (event.getCompletions().isEmpty()) return;
|
CommandWhitelistBukkit.getConfigCache().debug("Actively prevented "+event.getSender().getName()+"'s tab completion (/[tab] packet)");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.getCompletions().isEmpty()) {
|
||||||
|
CommandWhitelistBukkit.getConfigCache().debug("Tab completion not provided");
|
||||||
|
return;
|
||||||
|
}
|
||||||
event.setCompletions(
|
event.setCompletions(
|
||||||
CommandUtil.filterSuggestions(
|
CommandUtil.filterSuggestions(
|
||||||
buffer,
|
buffer,
|
||||||
|
|||||||
+8
-5
@@ -12,6 +12,7 @@ import eu.endermite.commandwhitelist.common.CWPermission;
|
|||||||
import eu.endermite.commandwhitelist.common.CommandUtil;
|
import eu.endermite.commandwhitelist.common.CommandUtil;
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@@ -33,21 +34,23 @@ public class PacketCommandPreProcessListener {
|
|||||||
if (!string.startsWith("/")) return;
|
if (!string.startsWith("/")) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
|
|
||||||
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
|
ConfigCache config = CommandWhitelistBukkit.getConfigCache();
|
||||||
String label = CommandUtil.getCommandLabel(string.toLowerCase());
|
String caseSensitiveLabel = CommandUtil.getCommandLabel(string);
|
||||||
|
String label = caseSensitiveLabel.toLowerCase();
|
||||||
|
packet.getStrings().write(0, string.replaceFirst(caseSensitiveLabel, label));
|
||||||
|
|
||||||
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
|
HashSet<String> commands = CommandWhitelistBukkit.getCommands(player);
|
||||||
|
BukkitAudiences audiences = CommandWhitelistBukkit.getAudiences();
|
||||||
if (!commands.contains(label)) {
|
if (!commands.contains(label)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
CommandWhitelistBukkit.getAudiences().player(player).sendMessage(CWCommand.miniMessage.parse(config.prefix + config.command_denied));
|
audiences.player(player).sendMessage(CWCommand.miniMessage.deserialize(config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet<String> bannedSubCommands = CommandWhitelistBukkit.getSuggestions(player);
|
HashSet<String> bannedSubCommands = CommandWhitelistBukkit.getSuggestions(player);
|
||||||
for (String bannedSubCommand : bannedSubCommands) {
|
for (String bannedSubCommand : bannedSubCommands) {
|
||||||
if (string.toLowerCase().substring(1).startsWith(bannedSubCommand)) {
|
if (string.toLowerCase().substring(1).startsWith(bannedSubCommand)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
CommandWhitelistBukkit.getAudiences().player(player).sendMessage(CWCommand.miniMessage.parse(config.prefix + config.subcommand_denied));
|
CommandWhitelistBukkit.getAudiences().player(player).sendMessage(CWCommand.miniMessage.deserialize(config.prefix + config.subcommand_denied));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.bukkit.listeners.protocollib;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
import com.mojang.brigadier.tree.RootCommandNode;
|
|
||||||
import eu.endermite.commandwhitelist.bukkit.CommandWhitelistBukkit;
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class PacketCommandSendListener {
|
|
||||||
|
|
||||||
public static void protocol(CommandWhitelistBukkit plugin) {
|
|
||||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
|
||||||
commandSendListener(protocolManager, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void commandSendListener(ProtocolManager protocolManager, Plugin plugin) {
|
|
||||||
protocolManager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Server.COMMANDS) {
|
|
||||||
@Override
|
|
||||||
public void onPacketSending(PacketEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
|
||||||
|
|
||||||
HashSet<String> commandList = CommandWhitelistBukkit.getCommands(player);
|
|
||||||
PacketContainer packet = event.getPacket();
|
|
||||||
RootCommandNode<?> node = (RootCommandNode<?>) packet.getModifier().getValues().get(0);
|
|
||||||
node.getChildren().removeIf((cmd) -> !commandList.contains(cmd.getName()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>2.5.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Common</artifactId>
|
<artifactId>Common</artifactId>
|
||||||
@@ -85,10 +85,16 @@
|
|||||||
<version>1.1.0</version>
|
<version>1.1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
|
<version>4.11.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
<version>1.19-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+9
-2
@@ -1,17 +1,20 @@
|
|||||||
package eu.endermite.commandwhitelist.common;
|
package eu.endermite.commandwhitelist.common;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class CWGroup {
|
public class CWGroup {
|
||||||
|
|
||||||
private final String id, permission;
|
private final String id, permission, commandDeniedMessage;
|
||||||
private final HashSet<String> commands = new HashSet<>();
|
private final HashSet<String> commands = new HashSet<>();
|
||||||
private final HashSet<String> subCommands = new HashSet<>();
|
private final HashSet<String> subCommands = new HashSet<>();
|
||||||
|
|
||||||
public CWGroup(String id, Collection<String> commands, Collection<String> subCommands) {
|
public CWGroup(String id, Collection<String> commands, Collection<String> subCommands, String custom_command_denied_message) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.permission = "commandwhitelist.group." + id;
|
this.permission = "commandwhitelist.group." + id;
|
||||||
this.commands.addAll(commands);
|
this.commands.addAll(commands);
|
||||||
|
this.commandDeniedMessage = custom_command_denied_message;
|
||||||
this.subCommands.addAll(subCommands);
|
this.subCommands.addAll(subCommands);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +30,10 @@ public class CWGroup {
|
|||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable String getCommandDeniedMessage() {
|
||||||
|
return commandDeniedMessage;
|
||||||
|
}
|
||||||
|
|
||||||
public void addCommand(String command) {
|
public void addCommand(String command) {
|
||||||
commands.add(command);
|
commands.add(command);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -18,6 +18,7 @@ public enum CWPermission {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to check specific group permission
|
* Allows to check specific group permission
|
||||||
|
*
|
||||||
* @param configCache
|
* @param configCache
|
||||||
* @param groupId
|
* @param groupId
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
+37
-4
@@ -1,5 +1,9 @@
|
|||||||
package eu.endermite.commandwhitelist.common;
|
package eu.endermite.commandwhitelist.common;
|
||||||
|
|
||||||
|
import io.github.thatsmusic99.configurationmaster.api.ConfigFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -17,15 +21,17 @@ public class CommandUtil {
|
|||||||
public static List<String> filterSuggestions(String buffer, Collection<String> suggestions, Collection<String> blockedSubCommands) {
|
public static List<String> filterSuggestions(String buffer, Collection<String> suggestions, Collection<String> blockedSubCommands) {
|
||||||
if (buffer.startsWith("/"))
|
if (buffer.startsWith("/"))
|
||||||
buffer = buffer.substring(1);
|
buffer = buffer.substring(1);
|
||||||
|
List<String> suggestionsList = new ArrayList<>(suggestions);
|
||||||
|
if (suggestions.isEmpty() || blockedSubCommands.isEmpty()) return suggestionsList;
|
||||||
for (String s : blockedSubCommands) {
|
for (String s : blockedSubCommands) {
|
||||||
String slast = getLastArgument(s);
|
|
||||||
String scommand = cutLastArgument(s);
|
String scommand = cutLastArgument(s);
|
||||||
if (buffer.startsWith(scommand)) {
|
if (buffer.startsWith(scommand)) {
|
||||||
while (suggestions.contains(slast))
|
String slast = getLastArgument(s);
|
||||||
suggestions.remove(slast);
|
while (suggestionsList.contains(slast))
|
||||||
|
suggestionsList.remove(slast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ArrayList<>(suggestions);
|
return suggestionsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,4 +67,31 @@ public class CommandUtil {
|
|||||||
return parts[0];
|
return parts[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps command list to a file
|
||||||
|
*
|
||||||
|
* @param serverCommands Commands to dump
|
||||||
|
* @return True on successful file save
|
||||||
|
*/
|
||||||
|
public static boolean dumpAllBukkitCommands(ArrayList<String> serverCommands, File file) {
|
||||||
|
try {
|
||||||
|
File parent = new File(file.getParent());
|
||||||
|
if (!parent.exists())
|
||||||
|
parent.mkdir();
|
||||||
|
if (!file.exists())
|
||||||
|
file.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigFile dumpFile = ConfigFile.loadConfig(file);
|
||||||
|
dumpFile.set("commands", serverCommands);
|
||||||
|
try {
|
||||||
|
dumpFile.save();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-5
@@ -17,6 +17,7 @@ public class ConfigCache {
|
|||||||
public String prefix, command_denied, no_permission, no_such_subcommand, config_reloaded, added_to_whitelist,
|
public String prefix, command_denied, no_permission, no_such_subcommand, config_reloaded, added_to_whitelist,
|
||||||
removed_from_whitelist, group_doesnt_exist, subcommand_denied;
|
removed_from_whitelist, group_doesnt_exist, subcommand_denied;
|
||||||
public boolean useProtocolLib = false;
|
public boolean useProtocolLib = false;
|
||||||
|
public boolean debug = false;
|
||||||
|
|
||||||
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) {
|
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) {
|
||||||
this.configFile = configFile;
|
this.configFile = configFile;
|
||||||
@@ -41,7 +42,7 @@ public class ConfigCache {
|
|||||||
config.addDefault("messages.removed_from_whitelist", "<yellow>Removed command <gold>%s <yellow>from permission <gold>%s");
|
config.addDefault("messages.removed_from_whitelist", "<yellow>Removed command <gold>%s <yellow>from permission <gold>%s");
|
||||||
config.addDefault("messages.group_doesnt_exist", "<red>Group doesn't exist or error occured");
|
config.addDefault("messages.group_doesnt_exist", "<red>Group doesn't exist or error occured");
|
||||||
|
|
||||||
config.addComment("messages", "Messages use MiniMessage formatting (https://docs.adventure.kyori.net/minimessage.html#format)");
|
config.addComment("messages", "Messages use MiniMessage formatting (https://docs.adventure.kyori.net/minimessage/format)");
|
||||||
|
|
||||||
if (canDoProtocolLib)
|
if (canDoProtocolLib)
|
||||||
config.addDefault("use_protocollib", false, "Do not enable if you don't have issues with aliased commands.\nThis requires server restart to take effect.");
|
config.addDefault("use_protocollib", false, "Do not enable if you don't have issues with aliased commands.\nThis requires server restart to take effect.");
|
||||||
@@ -51,9 +52,11 @@ public class ConfigCache {
|
|||||||
exampleCommands.add("example");
|
exampleCommands.add("example");
|
||||||
List<String> exampleSubCommands = new ArrayList<>();
|
List<String> exampleSubCommands = new ArrayList<>();
|
||||||
exampleSubCommands.add("example of");
|
exampleSubCommands.add("example of");
|
||||||
|
String exampleCustomCommandDeniedMessage = "You don't have commandwhitelist.group.example permission.";
|
||||||
|
|
||||||
config.addExample("groups.example.commands", exampleCommands, "This is the WHITELIST of commands that players will be able to see/use in the group \"example\"");
|
config.addExample("groups.example.commands", exampleCommands, "This is the WHITELIST of commands that players will be able to see/use in the group \"example\"");
|
||||||
config.addExample("groups.example.subcommands", exampleSubCommands, "This is the BLACKLIST of subcommands that players will NOT be able to see/use in the group \"example\"");
|
config.addExample("groups.example.subcommands", exampleSubCommands, "This is the BLACKLIST of subcommands that players will NOT be able to see/use in the group \"example\"");
|
||||||
|
config.addExample("groups.example.custom_command_denied_message", exampleCustomCommandDeniedMessage, "This is a custom message that players will see if they do not have commandwhitelist.group.<group_name> permission.\ncommandwhitelist.group.example in this case\nIf you don't want to use a custom message, set custom_command_denid_message: \"\"");
|
||||||
config.addComment("groups.example", "All groups except from default require commandwhitelist.group.<group_name> permission\ncommandwhitelist.group.example in this case\n If you wish to leave the list empty, put \"commands: []\" or \"subcommands: []\"");
|
config.addComment("groups.example", "All groups except from default require commandwhitelist.group.<group_name> permission\ncommandwhitelist.group.example in this case\n If you wish to leave the list empty, put \"commands: []\" or \"subcommands: []\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +78,9 @@ public class ConfigCache {
|
|||||||
List<String> defaultSubcommands = new ArrayList<>();
|
List<String> defaultSubcommands = new ArrayList<>();
|
||||||
defaultSubcommands.add("help about");
|
defaultSubcommands.add("help about");
|
||||||
|
|
||||||
config.addDefault("groups.default", new CWGroup("default", defaultCommands, defaultSubcommands).serialize());
|
String defaultCustomCommandDeniedMessage = "";
|
||||||
|
|
||||||
|
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");
|
||||||
@@ -87,6 +92,7 @@ public class ConfigCache {
|
|||||||
removed_from_whitelist = config.getString("messages.removed_from_whitelist");
|
removed_from_whitelist = config.getString("messages.removed_from_whitelist");
|
||||||
group_doesnt_exist = config.getString("messages.group_doesnt_exist");
|
group_doesnt_exist = config.getString("messages.group_doesnt_exist");
|
||||||
useProtocolLib = config.getBoolean("use_protocollib");
|
useProtocolLib = config.getBoolean("use_protocollib");
|
||||||
|
debug = config.getBoolean("debug", false);
|
||||||
|
|
||||||
ConfigSection groupSection = config.getConfigSection("groups");
|
ConfigSection groupSection = config.getConfigSection("groups");
|
||||||
for (String key : groupSection.getKeys(false)) {
|
for (String key : groupSection.getKeys(false)) {
|
||||||
@@ -128,9 +134,16 @@ public class ConfigCache {
|
|||||||
if (commands.contains(cmd)) continue;
|
if (commands.contains(cmd)) continue;
|
||||||
commands.add(cmd);
|
commands.add(cmd);
|
||||||
}
|
}
|
||||||
|
List<String> subCommands = new ArrayList<>();
|
||||||
List<String> subCommands = section.getStringList(id + ".subcommands");
|
for (String subCmd : section.getStringList(id + ".subcommands")) {
|
||||||
return new CWGroup(id, commands, subCommands);
|
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) {
|
||||||
@@ -143,6 +156,10 @@ public class ConfigCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void warn(String log) {
|
private void warn(String log) {
|
||||||
|
if (logger == null) {
|
||||||
|
System.out.println("WARNING: "+log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (logger instanceof org.slf4j.Logger) {
|
if (logger instanceof org.slf4j.Logger) {
|
||||||
((org.slf4j.Logger) logger).warn(log);
|
((org.slf4j.Logger) logger).warn(log);
|
||||||
return;
|
return;
|
||||||
@@ -153,4 +170,20 @@ public class ConfigCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void debug(String log) {
|
||||||
|
if (!debug) return;
|
||||||
|
if (logger == null) {
|
||||||
|
System.out.println("DEBUG: "+log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (logger instanceof org.slf4j.Logger) {
|
||||||
|
((org.slf4j.Logger) logger).info(log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (logger instanceof java.util.logging.Logger) {
|
||||||
|
((java.util.logging.Logger) logger).info(log);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-18
@@ -5,23 +5,28 @@ import eu.endermite.commandwhitelist.common.ConfigCache;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
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 net.kyori.adventure.text.minimessage.transformation.TransformationType;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CWCommand {
|
public class CWCommand {
|
||||||
|
|
||||||
public static MiniMessage miniMessage = MiniMessage.builder()
|
public static MiniMessage miniMessage = MiniMessage.builder().tags(
|
||||||
.removeDefaultTransformations()
|
TagResolver.builder()
|
||||||
.transformation(TransformationType.COLOR)
|
.resolver(StandardTags.color())
|
||||||
.transformation(TransformationType.DECORATION)
|
.resolver(StandardTags.decorations())
|
||||||
.transformation(TransformationType.GRADIENT)
|
.resolver(StandardTags.gradient())
|
||||||
.transformation(TransformationType.RESET)
|
.resolver(StandardTags.font())
|
||||||
.transformation(TransformationType.RAINBOW)
|
.resolver(StandardTags.reset())
|
||||||
.transformation(TransformationType.PRE)
|
.resolver(StandardTags.rainbow())
|
||||||
.build();
|
.resolver(StandardTags.translatable())
|
||||||
|
.resolver(StandardTags.newline())
|
||||||
|
.resolver(StandardTags.clickEvent())
|
||||||
|
.resolver(StandardTags.keybind())
|
||||||
|
.build()
|
||||||
|
).build();
|
||||||
|
|
||||||
public static boolean addToWhitelist(ConfigCache configCache, String command, String group) {
|
public static boolean addToWhitelist(ConfigCache configCache, String command, String group) {
|
||||||
CWGroup cwGroup = configCache.getGroupList().get(group);
|
CWGroup cwGroup = configCache.getGroupList().get(group);
|
||||||
@@ -41,37 +46,63 @@ public class CWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Component helpComponent(String baseCommand, boolean showReloadCommand, boolean showAdminCommands) {
|
public static Component helpComponent(String baseCommand, boolean showReloadCommand, boolean showAdminCommands) {
|
||||||
Component component = miniMessage.parse("<rainbow><bold>CommandWhitelist by YouHaveTrouble")
|
Component component = miniMessage.deserialize("<rainbow><bold>CommandWhitelist by YouHaveTrouble</bold>")
|
||||||
.append(Component.newline());
|
.append(Component.newline());
|
||||||
component = component.append(Component.text("/" + baseCommand + " help").color(NamedTextColor.AQUA).append(Component.text(" - Displays this message").color(NamedTextColor.BLUE)));
|
component = component.append(Component.text(baseCommand + " help").color(NamedTextColor.AQUA).append(Component.text(" - Displays this message").color(NamedTextColor.BLUE)));
|
||||||
if (showReloadCommand) {
|
if (showReloadCommand) {
|
||||||
component = component.append(Component.newline());
|
component = component.append(Component.newline());
|
||||||
component = component.append(Component.text("/" + baseCommand + " reload").color(NamedTextColor.AQUA).append(Component.text(" - Reloads plugin configuration").color(NamedTextColor.BLUE)));
|
component = component.append(Component.text(baseCommand + " reload").color(NamedTextColor.AQUA).append(Component.text(" - Reloads plugin configuration").color(NamedTextColor.BLUE)));
|
||||||
}
|
}
|
||||||
if (showAdminCommands) {
|
if (showAdminCommands) {
|
||||||
component = component.append(Component.newline());
|
component = component.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)));
|
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)));
|
||||||
component = component.append(Component.newline());
|
component = component.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)));
|
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)));
|
||||||
}
|
}
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CommandType {
|
public enum CommandType {
|
||||||
ADD, REMOVE, HELP, RELOAD
|
ADD, REMOVE, HELP, RELOAD, DUMP
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> commandSuggestions(ConfigCache config, Collection<String> serverCommands, String[] args, boolean reloadPerm, boolean adminPerm) {
|
public enum ImplementationType {
|
||||||
|
BUKKIT, WATERFALL, VELOCITY
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> commandSuggestions(
|
||||||
|
ConfigCache config,
|
||||||
|
Collection<String> serverCommands,
|
||||||
|
String[] args, boolean reloadPerm,
|
||||||
|
boolean adminPerm,
|
||||||
|
ImplementationType implementationType
|
||||||
|
) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
|
// thanks velocity for handling completions entirely different from everything else
|
||||||
|
if (implementationType.equals(ImplementationType.VELOCITY)) {
|
||||||
|
list.add("help");
|
||||||
|
if (reloadPerm)
|
||||||
|
list.add("reload");
|
||||||
|
if (adminPerm) {
|
||||||
|
list.add("add");
|
||||||
|
list.add("remove");
|
||||||
|
list.add("dump");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
case 1:
|
case 1:
|
||||||
|
if ("help".startsWith(args[0]))
|
||||||
|
list.add("help");
|
||||||
if ("reload".startsWith(args[0]) && reloadPerm)
|
if ("reload".startsWith(args[0]) && reloadPerm)
|
||||||
list.add("reload");
|
list.add("reload");
|
||||||
if ("add".startsWith(args[0]) && adminPerm)
|
if ("add".startsWith(args[0]) && adminPerm)
|
||||||
list.add("add");
|
list.add("add");
|
||||||
if ("remove".startsWith(args[0]) && adminPerm)
|
if ("remove".startsWith(args[0]) && adminPerm)
|
||||||
list.add("remove");
|
list.add("remove");
|
||||||
|
if ("dump".startsWith(args[0]) && adminPerm)
|
||||||
|
list.add("dump");
|
||||||
return list;
|
return list;
|
||||||
case 2:
|
case 2:
|
||||||
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove")) {
|
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove")) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>2.5.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Velocity</artifactId>
|
<artifactId>Velocity</artifactId>
|
||||||
@@ -65,8 +65,8 @@
|
|||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>velocitypowered-repo</id>
|
<id>papermc</id>
|
||||||
<url>https://repo.velocitypowered.com/releases/</url>
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>minecraft-libraries</id>
|
<id>minecraft-libraries</id>
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.velocitypowered</groupId>
|
<groupId>com.velocitypowered</groupId>
|
||||||
<artifactId>velocity-api</artifactId>
|
<artifactId>velocity-api</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.2-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-velocity</artifactId>
|
<artifactId>bstats-velocity</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>3.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
+16
-4
@@ -11,6 +11,7 @@ import com.velocitypowered.api.proxy.Player;
|
|||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import eu.endermite.commandwhitelist.common.CWGroup;
|
import eu.endermite.commandwhitelist.common.CWGroup;
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||||
|
import eu.endermite.commandwhitelist.common.CommandUtil;
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
|
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
|
||||||
@@ -22,6 +23,7 @@ import org.slf4j.Logger;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -55,7 +57,7 @@ public class CommandWhitelistVelocity {
|
|||||||
public static void reloadConfig(CommandSource source) {
|
public static void reloadConfig(CommandSource source) {
|
||||||
server.getScheduler().buildTask(plugin, () -> {
|
server.getScheduler().buildTask(plugin, () -> {
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
source.sendMessage(Identity.nil(), CWCommand.miniMessage.parse(getConfigCache().prefix+getConfigCache().config_reloaded));
|
source.sendMessage(Identity.nil(), CWCommand.miniMessage.deserialize(getConfigCache().prefix + getConfigCache().config_reloaded));
|
||||||
}).schedule();
|
}).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,10 +88,12 @@ public class CommandWhitelistVelocity {
|
|||||||
|
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
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);
|
HashSet<String> allowedCommands = CommandWhitelistVelocity.getCommands(player);
|
||||||
String command = event.getCommand().split(" ")[0];
|
String label = CommandUtil.getCommandLabel(command);
|
||||||
if (server.getCommandManager().hasCommand(command)
|
if (server.getCommandManager().hasCommand(label) && !allowedCommands.contains(label))
|
||||||
&& !allowedCommands.contains(command))
|
|
||||||
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
|
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +101,10 @@ public class CommandWhitelistVelocity {
|
|||||||
return configCache;
|
return configCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Path getConfigPath() {
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param player Velocity Player
|
* @param player Velocity Player
|
||||||
* @return commands available to the player
|
* @return commands available to the player
|
||||||
@@ -129,4 +137,8 @@ public class CommandWhitelistVelocity {
|
|||||||
return suggestionList;
|
return suggestionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArrayList<String> getServerCommands() {
|
||||||
|
return new ArrayList<>(server.getCommandManager().getAliases());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-9
@@ -3,10 +3,12 @@ package eu.endermite.commandwhitelist.velocity.command;
|
|||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.command.SimpleCommand;
|
import com.velocitypowered.api.command.SimpleCommand;
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||||
|
import eu.endermite.commandwhitelist.common.CommandUtil;
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
import eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity;
|
import eu.endermite.commandwhitelist.velocity.CommandWhitelistVelocity;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -29,37 +31,49 @@ public class VelocityMainCommand implements SimpleCommand {
|
|||||||
switch (commandType) {
|
switch (commandType) {
|
||||||
case RELOAD:
|
case RELOAD:
|
||||||
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
||||||
sender.sendMessage(CWCommand.miniMessage.parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
sender.sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CommandWhitelistVelocity.reloadConfig(sender);
|
CommandWhitelistVelocity.reloadConfig(sender);
|
||||||
return;
|
return;
|
||||||
case ADD:
|
case ADD:
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
||||||
sender.sendMessage(CWCommand.miniMessage.parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
sender.sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
if (CWCommand.addToWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
|
if (CWCommand.addToWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
|
||||||
sender.sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().added_to_whitelist, args[2], args[1])));
|
sender.sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().added_to_whitelist, args[2], args[1])));
|
||||||
else
|
else
|
||||||
sender.sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
|
sender.sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
|
||||||
} else
|
} else
|
||||||
sender.sendMessage(Component.text("/" + label + " add <group> <command>"));
|
sender.sendMessage(Component.text("/" + label + " add <group> <command>"));
|
||||||
return;
|
return;
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
||||||
sender.sendMessage(CWCommand.miniMessage.parse(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
sender.sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().no_permission));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
if (CWCommand.removeFromWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
|
if (CWCommand.removeFromWhitelist(CommandWhitelistVelocity.getConfigCache(), args[2], args[1]))
|
||||||
sender.sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().removed_from_whitelist, args[2], args[1])));
|
sender.sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().removed_from_whitelist, args[2], args[1])));
|
||||||
else
|
else
|
||||||
sender.sendMessage(CWCommand.miniMessage.parse(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
|
sender.sendMessage(CWCommand.miniMessage.deserialize(String.format(CommandWhitelistVelocity.getConfigCache().prefix + CommandWhitelistVelocity.getConfigCache().group_doesnt_exist, args[1])));
|
||||||
} else
|
} else
|
||||||
sender.sendMessage(Component.text("/" + label + " remove <group> <command>"));
|
sender.sendMessage(Component.text("/" + label + " remove <group> <command>"));
|
||||||
return;
|
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:
|
case HELP:
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
sender.sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
||||||
@@ -76,8 +90,15 @@ public class VelocityMainCommand implements SimpleCommand {
|
|||||||
CommandSource source = invocation.source();
|
CommandSource source = invocation.source();
|
||||||
String[] args = invocation.arguments();
|
String[] args = invocation.arguments();
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
List<String> serverCommands = new ArrayList<>();
|
List<String> serverCommands = CommandWhitelistVelocity.getServerCommands();
|
||||||
return CWCommand.commandSuggestions(CommandWhitelistVelocity.getConfigCache(), serverCommands, args, source.hasPermission(CWPermission.RELOAD.permission()), source.hasPermission(CWPermission.ADMIN.permission()));
|
return CWCommand.commandSuggestions(
|
||||||
|
CommandWhitelistVelocity.getConfigCache(),
|
||||||
|
serverCommands,
|
||||||
|
args,
|
||||||
|
source.hasPermission(CWPermission.RELOAD.permission()),
|
||||||
|
source.hasPermission(CWPermission.ADMIN.permission()),
|
||||||
|
CWCommand.ImplementationType.VELOCITY
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>2.5.2</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>Waterfall</artifactId>
|
<artifactId>Waterfall</artifactId>
|
||||||
@@ -94,13 +94,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-platform-bungeecord</artifactId>
|
<artifactId>adventure-platform-bungeecord</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<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>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bungeecord</artifactId>
|
<artifactId>bstats-bungeecord</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>3.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
+28
-5
@@ -8,18 +8,16 @@ import eu.endermite.commandwhitelist.waterfall.listeners.BungeeChatEventListener
|
|||||||
import eu.endermite.commandwhitelist.waterfall.listeners.BungeeTabcompleteListener;
|
import eu.endermite.commandwhitelist.waterfall.listeners.BungeeTabcompleteListener;
|
||||||
import eu.endermite.commandwhitelist.waterfall.listeners.WaterfallDefineCommandsListener;
|
import eu.endermite.commandwhitelist.waterfall.listeners.WaterfallDefineCommandsListener;
|
||||||
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
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 net.md_5.bungee.api.plugin.Plugin;
|
||||||
import org.bstats.bungeecord.Metrics;
|
import org.bstats.bungeecord.Metrics;
|
||||||
import org.bstats.charts.SimplePie;
|
import org.bstats.charts.SimplePie;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public final class CommandWhitelistWaterfall extends Plugin {
|
public final class CommandWhitelistWaterfall extends Plugin {
|
||||||
|
|
||||||
@@ -53,6 +51,7 @@ public final class CommandWhitelistWaterfall extends Plugin {
|
|||||||
public static CommandWhitelistWaterfall getPlugin() {
|
public static CommandWhitelistWaterfall getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigCache getConfigCache() {
|
public static ConfigCache getConfigCache() {
|
||||||
return configCache;
|
return configCache;
|
||||||
}
|
}
|
||||||
@@ -71,7 +70,7 @@ public final class CommandWhitelistWaterfall extends Plugin {
|
|||||||
public void loadConfigAsync(CommandSender sender) {
|
public void loadConfigAsync(CommandSender sender) {
|
||||||
getProxy().getScheduler().runAsync(this, () -> {
|
getProxy().getScheduler().runAsync(this, () -> {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistWaterfall.getConfigCache().prefix + CommandWhitelistWaterfall.getConfigCache().config_reloaded));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistWaterfall.getConfigCache().prefix + CommandWhitelistWaterfall.getConfigCache().config_reloaded));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,4 +105,28 @@ public final class CommandWhitelistWaterfall extends Plugin {
|
|||||||
}
|
}
|
||||||
return suggestionList;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-12
@@ -1,6 +1,7 @@
|
|||||||
package eu.endermite.commandwhitelist.waterfall.command;
|
package eu.endermite.commandwhitelist.waterfall.command;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.common.CWPermission;
|
import eu.endermite.commandwhitelist.common.CWPermission;
|
||||||
|
import eu.endermite.commandwhitelist.common.CommandUtil;
|
||||||
import eu.endermite.commandwhitelist.common.ConfigCache;
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
|
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
|
||||||
@@ -10,6 +11,7 @@ import net.md_5.bungee.api.CommandSender;
|
|||||||
import net.md_5.bungee.api.plugin.Command;
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -36,37 +38,49 @@ public class BungeeMainCommand extends Command implements TabExecutor {
|
|||||||
switch (commandType) {
|
switch (commandType) {
|
||||||
case RELOAD:
|
case RELOAD:
|
||||||
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
if (!sender.hasPermission(CWPermission.RELOAD.permission())) {
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(CommandWhitelistWaterfall.getConfigCache().prefix + configCache.no_permission));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(CommandWhitelistWaterfall.getConfigCache().prefix + configCache.no_permission));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CommandWhitelistWaterfall.getPlugin().loadConfigAsync(sender);
|
CommandWhitelistWaterfall.getPlugin().loadConfigAsync(sender);
|
||||||
return;
|
return;
|
||||||
case ADD:
|
case ADD:
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.no_permission));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.no_permission));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
if (CWCommand.addToWhitelist(configCache, args[2], args[1]))
|
if (CWCommand.addToWhitelist(configCache, args[2], args[1]))
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.added_to_whitelist));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.added_to_whitelist));
|
||||||
else
|
else
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.group_doesnt_exist));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.group_doesnt_exist));
|
||||||
} else
|
} else
|
||||||
audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>"));
|
audiences.sender(sender).sendMessage(Component.text("/" + label + " add <group> <command>"));
|
||||||
return;
|
return;
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
if (!sender.hasPermission(CWPermission.ADMIN.permission())) {
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.no_permission));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.no_permission));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
if (CWCommand.removeFromWhitelist(configCache, args[2], args[1]))
|
if (CWCommand.removeFromWhitelist(configCache, args[2], args[1]))
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.removed_from_whitelist));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.removed_from_whitelist));
|
||||||
else
|
else
|
||||||
audiences.sender(sender).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.group_doesnt_exist));
|
audiences.sender(sender).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.group_doesnt_exist));
|
||||||
} else
|
} else
|
||||||
audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>"));
|
audiences.sender(sender).sendMessage(Component.text("/" + label + " remove <group> <command>"));
|
||||||
return;
|
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:
|
case HELP:
|
||||||
default:
|
default:
|
||||||
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
audiences.sender(sender).sendMessage(CWCommand.helpComponent(label, sender.hasPermission(CWPermission.RELOAD.permission()), sender.hasPermission(CWPermission.ADMIN.permission())));
|
||||||
@@ -80,10 +94,13 @@ public class BungeeMainCommand extends Command implements TabExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||||
List<String> serverCommands = new ArrayList<>();
|
return CWCommand.commandSuggestions(
|
||||||
for (Map.Entry<String, Command> command : CommandWhitelistWaterfall.getPlugin().getProxy().getPluginManager().getCommands()) {
|
CommandWhitelistWaterfall.getConfigCache(),
|
||||||
serverCommands.add(command.getValue().getName());
|
CommandWhitelistWaterfall.getServerCommands(),
|
||||||
}
|
args,
|
||||||
return CWCommand.commandSuggestions(CommandWhitelistWaterfall.getConfigCache(), serverCommands, args, sender.hasPermission(CWPermission.RELOAD.permission()),sender.hasPermission(CWPermission.ADMIN.permission()));
|
sender.hasPermission(CWPermission.RELOAD.permission()),
|
||||||
|
sender.hasPermission(CWPermission.ADMIN.permission()),
|
||||||
|
CWCommand.ImplementationType.WATERFALL
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -6,7 +6,6 @@ import eu.endermite.commandwhitelist.common.ConfigCache;
|
|||||||
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
import eu.endermite.commandwhitelist.common.commands.CWCommand;
|
||||||
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
|
import eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall;
|
||||||
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
@@ -33,7 +32,7 @@ public class BungeeChatEventListener implements Listener {
|
|||||||
HashSet<String> commands = CommandWhitelistWaterfall.getCommands(player);
|
HashSet<String> commands = CommandWhitelistWaterfall.getCommands(player);
|
||||||
if (!commands.contains(label)) {
|
if (!commands.contains(label)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
CommandWhitelistWaterfall.getAudiences().player(player).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.command_denied));
|
CommandWhitelistWaterfall.getAudiences().player(player).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + CommandWhitelistWaterfall.getCommandDeniedMessage(label)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ public class BungeeChatEventListener implements Listener {
|
|||||||
for (String bannedSubCommand : bannedSubCommands) {
|
for (String bannedSubCommand : bannedSubCommands) {
|
||||||
if (command.startsWith(bannedSubCommand)) {
|
if (command.startsWith(bannedSubCommand)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
audiences.player(player).sendMessage(CWCommand.miniMessage.parse(configCache.prefix + configCache.subcommand_denied));
|
audiences.player(player).sendMessage(CWCommand.miniMessage.deserialize(configCache.prefix + configCache.subcommand_denied));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -13,15 +13,13 @@ public class BungeeTabcompleteListener implements Listener {
|
|||||||
public void onTabcomplete(net.md_5.bungee.api.event.TabCompleteEvent event) {
|
public void onTabcomplete(net.md_5.bungee.api.event.TabCompleteEvent event) {
|
||||||
if (!(event.getReceiver() instanceof ProxiedPlayer)) return;
|
if (!(event.getReceiver() instanceof ProxiedPlayer)) return;
|
||||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||||
|
if (event.getSuggestions().isEmpty()) return;
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
|
|
||||||
CommandUtil.filterSuggestions(
|
CommandUtil.filterSuggestions(
|
||||||
event.getCursor(),
|
event.getCursor(),
|
||||||
event.getSuggestions(),
|
event.getSuggestions(),
|
||||||
CommandWhitelistWaterfall.getSuggestions(player)
|
CommandWhitelistWaterfall.getSuggestions(player)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -15,8 +15,7 @@ public class WaterfallDefineCommandsListener implements Listener {
|
|||||||
public void onProxyDefineCommandsEvent(io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent event) {
|
public void onProxyDefineCommandsEvent(io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent event) {
|
||||||
if (event.getReceiver() instanceof ProxiedPlayer) {
|
if (event.getReceiver() instanceof ProxiedPlayer) {
|
||||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||||
if (player.hasPermission(CWPermission.BYPASS.permission()))
|
if (player.hasPermission(CWPermission.BYPASS.permission())) return;
|
||||||
return;
|
|
||||||
HashMap<String, Command> commandHashMap = new HashMap<>();
|
HashMap<String, Command> commandHashMap = new HashMap<>();
|
||||||
CommandWhitelistWaterfall.getCommands(player).forEach(cmdName ->
|
CommandWhitelistWaterfall.getCommands(player).forEach(cmdName ->
|
||||||
CommandWhitelistWaterfall.getPlugin().getProxy().getPluginManager().getCommands()
|
CommandWhitelistWaterfall.getPlugin().getProxy().getPluginManager().getCommands()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
name: CommandWhitelist
|
name: CommandWhitelist
|
||||||
|
author: YouHaveTrouble
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
main: eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall
|
main: eu.endermite.commandwhitelist.waterfall.CommandWhitelistWaterfall
|
||||||
description: You decide what commands players can use or tab complete on your server!
|
description: You decide what commands players can use or tab complete on your server!
|
||||||
|
|||||||
@@ -0,0 +1,339 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>eu.endermite.commandwhitelist</groupId>
|
<groupId>eu.endermite.commandwhitelist</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>2.2.1</version>
|
<version>2.5.2</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>CommandWhitelistCommon</module>
|
<module>CommandWhitelistCommon</module>
|
||||||
<module>CommandWhitelistBukkit</module>
|
<module>CommandWhitelistBukkit</module>
|
||||||
@@ -23,6 +23,43 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<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.version}</finalName>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>sonatype</id>
|
<id>sonatype</id>
|
||||||
@@ -34,13 +71,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-api</artifactId>
|
<artifactId>adventure-api</artifactId>
|
||||||
<version>4.9.2</version>
|
<version>4.11.0</version>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
|
||||||
<version>4.1.0-SNAPSHOT</version>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
Reference in New Issue
Block a user