mirror of
https://github.com/YouHaveTrouble/CommandWhitelist.git
synced 2026-05-12 06:26:57 +00:00
cleanup and start of config rewrite
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>eu.endermite</groupId>
|
<groupId>eu.endermite</groupId>
|
||||||
<artifactId>CommandWhitelist</artifactId>
|
<artifactId>CommandWhitelist</artifactId>
|
||||||
<version>1.7.2</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>CommandWhitelist</name>
|
<name>CommandWhitelist</name>
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.api;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class RandomStuff {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param list List of strings to pick a random one from
|
|
||||||
* @param single String that will be used as fallback
|
|
||||||
* @return Randomized message
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static String getMessage(List<String> list, String single) {
|
|
||||||
|
|
||||||
if (list == null || list.size() == 0) {
|
|
||||||
return single;
|
|
||||||
}
|
|
||||||
|
|
||||||
Random random = new Random();
|
|
||||||
int r = random.nextInt(list.size());
|
|
||||||
return list.get(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+1
-2
@@ -1,6 +1,5 @@
|
|||||||
package eu.endermite.commandwhitelist.bungee.listeners;
|
package eu.endermite.commandwhitelist.bungee.listeners;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.api.RandomStuff;
|
|
||||||
import eu.endermite.commandwhitelist.bungee.CommandWhitelistBungee;
|
import eu.endermite.commandwhitelist.bungee.CommandWhitelistBungee;
|
||||||
import eu.endermite.commandwhitelist.bungee.config.BungeeConfigCache;
|
import eu.endermite.commandwhitelist.bungee.config.BungeeConfigCache;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@@ -42,7 +41,7 @@ public class BungeeChatEventListener implements Listener {
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BungeeConfigCache config = CommandWhitelistBungee.getConfigCache();
|
BungeeConfigCache config = CommandWhitelistBungee.getConfigCache();
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelistBungee.getConfigCache().getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getCommandDenied())));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelistBungee.getConfigCache().getPrefix() + config.getCommandDenied()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package eu.endermite.commandwhitelist.bungee.listeners;
|
package eu.endermite.commandwhitelist.bungee.listeners;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.api.CommandsList;
|
import eu.endermite.commandwhitelist.common.CommandsList;
|
||||||
import eu.endermite.commandwhitelist.bungee.CommandWhitelistBungee;
|
import eu.endermite.commandwhitelist.bungee.CommandWhitelistBungee;
|
||||||
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.Command;
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package eu.endermite.commandwhitelist.common;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class CWGroup {
|
||||||
|
|
||||||
|
private final String id, permission;
|
||||||
|
private final HashSet<String> commands = new HashSet<>();
|
||||||
|
private final HashSet<String> subCommands = new HashSet<>();
|
||||||
|
|
||||||
|
public CWGroup(String id, Collection<String> commands, Collection<String> subCommands) {
|
||||||
|
this.id = id;
|
||||||
|
this.permission = "commandwhitelist.group."+id;
|
||||||
|
this.commands.addAll(commands);
|
||||||
|
this.subCommands.addAll(subCommands);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPermission() {
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashSet<String> getCommands() {
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCommand(String command) {
|
||||||
|
commands.add(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeCommand(String command) {
|
||||||
|
commands.remove(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashSet<String> getSubCommands() {
|
||||||
|
return subCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSubCommand(String subCommand) {
|
||||||
|
subCommands.add(subCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeSubCommand(String subCommand) {
|
||||||
|
subCommands.remove(subCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> serialize() {
|
||||||
|
HashMap<String, Object> serializedGroup = new LinkedHashMap<>();
|
||||||
|
List<String> commands = new ArrayList<>(this.commands);
|
||||||
|
List<String> subCommands = new ArrayList<>(this.subCommands);
|
||||||
|
serializedGroup.put("commands", commands);
|
||||||
|
serializedGroup.put("subcommands", subCommands);
|
||||||
|
return serializedGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-7
@@ -1,4 +1,4 @@
|
|||||||
package eu.endermite.commandwhitelist.api;
|
package eu.endermite.commandwhitelist.common;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.bungee.CommandWhitelistBungee;
|
import eu.endermite.commandwhitelist.bungee.CommandWhitelistBungee;
|
||||||
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
||||||
@@ -11,11 +11,11 @@ public class CommandsList {
|
|||||||
|
|
||||||
public static List<String> getCommands(org.bukkit.entity.Player player) {
|
public static List<String> getCommands(org.bukkit.entity.Player player) {
|
||||||
List<String> commandList = new ArrayList<>();
|
List<String> commandList = new ArrayList<>();
|
||||||
for (Map.Entry<String, List<String>> s : CommandWhitelist.getConfigCache().getPermList().entrySet()) {
|
for (Map.Entry<String, CWGroup> s : CommandWhitelist.getConfigCache().getGroupList().entrySet()) {
|
||||||
if (s.getKey().equalsIgnoreCase("default"))
|
if (s.getKey().equalsIgnoreCase("default"))
|
||||||
commandList.addAll(s.getValue());
|
commandList.addAll(s.getValue().getCommands());
|
||||||
else if (player.hasPermission("commandwhitelist.commands." + s.getKey()))
|
else if (player.hasPermission("commandwhitelist.group." + s.getKey()))
|
||||||
commandList.addAll(s.getValue());
|
commandList.addAll(s.getValue().getCommands());
|
||||||
}
|
}
|
||||||
return commandList;
|
return commandList;
|
||||||
}
|
}
|
||||||
@@ -44,10 +44,10 @@ public class CommandsList {
|
|||||||
|
|
||||||
public static List<String> getSuggestions(org.bukkit.entity.Player player) {
|
public static List<String> getSuggestions(org.bukkit.entity.Player player) {
|
||||||
List<String> suggestionList = new ArrayList<>();
|
List<String> suggestionList = new ArrayList<>();
|
||||||
for (Map.Entry<String, List<String>> s : CommandWhitelist.getConfigCache().getPermSubList().entrySet()) {
|
for (Map.Entry<String, CWGroup> s : CommandWhitelist.getConfigCache().getGroupList().entrySet()) {
|
||||||
if (player.hasPermission("commandwhitelist.subcommands." + s.getKey()))
|
if (player.hasPermission("commandwhitelist.subcommands." + s.getKey()))
|
||||||
continue;
|
continue;
|
||||||
suggestionList.addAll(s.getValue());
|
suggestionList.addAll(s.getValue().getSubCommands());
|
||||||
}
|
}
|
||||||
return suggestionList;
|
return suggestionList;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package eu.endermite.commandwhitelist.common;
|
||||||
|
|
||||||
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class ConfigCache {
|
||||||
|
|
||||||
|
private final HashMap<String, CWGroup> groupList = new LinkedHashMap<>();
|
||||||
|
public String prefix, command_denied, no_permission, no_such_subcommand, config_reloaded, added_to_whitelist,
|
||||||
|
removed_from_whitelist, group_doesnt_exist, subcommand_denied;
|
||||||
|
public boolean useProtocolLib = false;
|
||||||
|
|
||||||
|
public ConfigCache(File configFile, boolean canDoProtocolLib) {
|
||||||
|
if (!reloadConfig(configFile, canDoProtocolLib))
|
||||||
|
reloadConfig(configFile, canDoProtocolLib);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveDefaultConfig(Map<String, Object> data, File configFile, boolean canDoProtocolLib) {
|
||||||
|
|
||||||
|
data.put("messages", processMessages());
|
||||||
|
|
||||||
|
if (canDoProtocolLib) {
|
||||||
|
data.put("use_protocollib_to_detect_commands", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> defaultCommands = new ArrayList<>();
|
||||||
|
List<String> defaultSubcommands = new ArrayList<>();
|
||||||
|
defaultCommands.add("help");
|
||||||
|
defaultCommands.add("spawn");
|
||||||
|
defaultCommands.add("bal");
|
||||||
|
defaultCommands.add("balance");
|
||||||
|
defaultCommands.add("baltop");
|
||||||
|
defaultCommands.add("pay");
|
||||||
|
defaultCommands.add("r");
|
||||||
|
defaultCommands.add("msg");
|
||||||
|
defaultCommands.add("tpa");
|
||||||
|
defaultCommands.add("tpahere");
|
||||||
|
defaultCommands.add("tpaccept");
|
||||||
|
defaultCommands.add("tpdeny");
|
||||||
|
defaultCommands.add("warp");
|
||||||
|
|
||||||
|
defaultSubcommands.add("help about");
|
||||||
|
|
||||||
|
HashMap<String, Object> groups = new LinkedHashMap<>();
|
||||||
|
groups.put("default", new CWGroup("default", defaultCommands, defaultSubcommands).serialize());
|
||||||
|
|
||||||
|
data.putIfAbsent("groups", groups);
|
||||||
|
|
||||||
|
DumperOptions dumperOptions = new DumperOptions();
|
||||||
|
dumperOptions.setPrettyFlow(true);
|
||||||
|
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||||
|
dumperOptions.setAllowUnicode(true);
|
||||||
|
Yaml yaml = new Yaml(dumperOptions);
|
||||||
|
try {
|
||||||
|
FileWriter writer = new FileWriter(configFile.getPath());
|
||||||
|
yaml.dump(data, writer);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean reloadConfig(File configFile, boolean canDoProtocolLib) {
|
||||||
|
HashMap<String, Object> config = new LinkedHashMap<>();
|
||||||
|
Yaml yaml = new Yaml();
|
||||||
|
try {
|
||||||
|
FileInputStream fileInputStream = new FileInputStream(configFile);
|
||||||
|
config = yaml.load(fileInputStream);
|
||||||
|
} catch (FileNotFoundException ignored) {
|
||||||
|
saveDefaultConfig(config, configFile, canDoProtocolLib);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String, String> messages = (HashMap<String, String>) config.get("messages");
|
||||||
|
this.prefix = messages.get("prefix");
|
||||||
|
this.command_denied = messages.get("command_denied");
|
||||||
|
this.no_such_subcommand = messages.get("no_such_subcommand");
|
||||||
|
this.no_permission = messages.get("no_permission");
|
||||||
|
this.config_reloaded = messages.get("config_reloaded");
|
||||||
|
this.added_to_whitelist = messages.get("added_to_whitelist");
|
||||||
|
this.removed_from_whitelist = messages.get("removed_from_whitelist");
|
||||||
|
this.group_doesnt_exist = messages.get("group_doesnt-exist");
|
||||||
|
this.subcommand_denied = messages.get("subcommand_denied");
|
||||||
|
|
||||||
|
if (canDoProtocolLib)
|
||||||
|
this.useProtocolLib = (boolean) config.get("use_protocollib_to_detect_commands");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HashMap<String, HashMap<String, Object>> groups = (HashMap<String, HashMap<String, Object>>) config.get("groups");
|
||||||
|
for (Map.Entry<String, HashMap<String, Object>> entry : groups.entrySet()) {
|
||||||
|
groupList.put(entry.getKey(), loadCWGroup(entry.getKey(), entry.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
saveDefaultConfig(config, configFile, canDoProtocolLib);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CWGroup loadCWGroup(String id, HashMap<String, Object> map) {
|
||||||
|
List<String> subCommands = new ArrayList<>((Collection<? extends String>) map.get("subcommands"));
|
||||||
|
List<String> commands = new ArrayList<>((Collection<? extends String>) map.get("commands"));
|
||||||
|
return new CWGroup(id, commands, subCommands);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, CWGroup> getGroupList() {
|
||||||
|
return groupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, String> processMessages() {
|
||||||
|
HashMap<String, String> messages = new LinkedHashMap<>();
|
||||||
|
messages.put("prefix", stringOrDefault(prefix, "CommandWhitelist > "));
|
||||||
|
messages.put("command_denied", stringOrDefault(command_denied, "No such command."));
|
||||||
|
messages.put("subcommand_denied", stringOrDefault(subcommand_denied, "You cannot use this subcommand"));
|
||||||
|
messages.put("no_permission", stringOrDefault(no_permission, "<red>You don't have permission to do this."));
|
||||||
|
messages.put("no_such_subcommand", stringOrDefault(no_such_subcommand, "<red>No subcommand by that name."));
|
||||||
|
messages.put("config_reloaded", stringOrDefault(config_reloaded, "<yellow>Configuration reloaded."));
|
||||||
|
messages.put("added_to_whitelist", stringOrDefault(added_to_whitelist, "<yellow>Whitelisted command <orange>%s <yellow>for permission <orange>%s"));
|
||||||
|
messages.put("removed_from_whitelist", stringOrDefault(removed_from_whitelist, "<yellow>Removed command <orange>%s <yellow>from permission <orange>%s"));
|
||||||
|
messages.put("group_doesnt_exist", stringOrDefault(group_doesnt_exist, "<red>Group doesn't exist or error occured"));
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String stringOrDefault(String value, String def) {
|
||||||
|
if (value != null)
|
||||||
|
return value;
|
||||||
|
else
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package eu.endermite.commandwhitelist.spigot;
|
package eu.endermite.commandwhitelist.spigot;
|
||||||
|
|
||||||
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import eu.endermite.commandwhitelist.spigot.command.MainCommand;
|
import eu.endermite.commandwhitelist.spigot.command.MainCommand;
|
||||||
import eu.endermite.commandwhitelist.spigot.config.ConfigCache;
|
|
||||||
import eu.endermite.commandwhitelist.spigot.listeners.*;
|
import eu.endermite.commandwhitelist.spigot.listeners.*;
|
||||||
import eu.endermite.commandwhitelist.spigot.metrics.BukkitMetrics;
|
import eu.endermite.commandwhitelist.spigot.metrics.BukkitMetrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -11,6 +11,8 @@ import org.bukkit.entity.Player;
|
|||||||
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;
|
||||||
|
|
||||||
public class CommandWhitelist extends JavaPlugin {
|
public class CommandWhitelist extends JavaPlugin {
|
||||||
|
|
||||||
private static CommandWhitelist commandWhitelist;
|
private static CommandWhitelist commandWhitelist;
|
||||||
@@ -22,78 +24,48 @@ public class CommandWhitelist extends JavaPlugin {
|
|||||||
|
|
||||||
commandWhitelist = this;
|
commandWhitelist = this;
|
||||||
|
|
||||||
isLegacy = checkLegacy();
|
|
||||||
|
|
||||||
reloadPluginConfig();
|
reloadPluginConfig();
|
||||||
|
|
||||||
Plugin protocollib = getServer().getPluginManager().getPlugin("ProtocolLib");
|
Plugin protocollib = getServer().getPluginManager().getPlugin("ProtocolLib");
|
||||||
|
|
||||||
if (!isLegacy) {
|
if (!getConfigCache().useProtocolLib || protocollib == null || !protocollib.isEnabled()) {
|
||||||
if (!getConfigCache().isUseProtocolLib() || protocollib == null || !protocollib.isEnabled()) {
|
|
||||||
getServer().getPluginManager().registerEvents(new PlayerCommandPreProcessListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerCommandPreProcessListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerCommandSendListener(), this);
|
||||||
} else {
|
} else {
|
||||||
PacketCommandSendListener.protocol(this);
|
PacketCommandSendListener.protocol(this);
|
||||||
getLogger().info(ChatColor.AQUA+"Using ProtocolLib for command filter!");
|
getLogger().info(ChatColor.AQUA + "Using ProtocolLib for command filter!");
|
||||||
}
|
}
|
||||||
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
|
getServer().getPluginManager().registerEvents(new TabCompleteBlockerListener(), this);
|
||||||
} else {
|
|
||||||
getLogger().info(ChatColor.AQUA+"Running in legacy mode...");
|
|
||||||
if (protocollib != null) {
|
|
||||||
LegacyPlayerTabChatCompleteListener.protocol(this);
|
|
||||||
} else {
|
|
||||||
getLogger().info(ChatColor.YELLOW+"ProtocolLib is required for tab completion blocking!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getCommand("commandwhitelist").setExecutor(new MainCommand());
|
getCommand("commandwhitelist").setExecutor(new MainCommand());
|
||||||
getCommand("commandwhitelist").setTabCompleter(new MainCommand());
|
|
||||||
|
|
||||||
int pluginId = 8705;
|
int pluginId = 8705;
|
||||||
new BukkitMetrics(this, pluginId);
|
new BukkitMetrics(this, pluginId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadPluginConfig() {
|
public void reloadPluginConfig() {
|
||||||
saveDefaultConfig();
|
File configFile = new File("plugins/CommandWhitelist/config.yml");
|
||||||
reloadConfig();
|
configCache = new ConfigCache(configFile, true);
|
||||||
configCache = new ConfigCache(getConfig());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadPluginConfig(CommandSender sender) {
|
public void reloadPluginConfig(CommandSender sender) {
|
||||||
getServer().getScheduler().runTaskAsynchronously(this, () -> {
|
getServer().getScheduler().runTaskAsynchronously(this, () -> {
|
||||||
reloadPluginConfig();
|
reloadPluginConfig();
|
||||||
if (!isLegacy()) {
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
p.updateCommands();
|
p.updateCommands();
|
||||||
}
|
}
|
||||||
}
|
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().prefix + CommandWhitelist.getConfigCache().config_reloaded));
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().getPrefix() + CommandWhitelist.getConfigCache().getConfigReloaded()));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLegacy() {
|
public static CommandWhitelist getPlugin() {
|
||||||
return isLegacy;
|
return commandWhitelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkLegacy() {
|
public static ConfigCache getConfigCache() {
|
||||||
|
return configCache;
|
||||||
String version = Bukkit.getServer().getClass().getPackage().getName().replace("org.bukkit.craftbukkit", "").replace(".", "");
|
|
||||||
|
|
||||||
if (version.contains("v1_8_")) {
|
|
||||||
return true;
|
|
||||||
} else if (version.contains("v1_9_")) {
|
|
||||||
return true;
|
|
||||||
} else if (version.contains("v1_10_")) {
|
|
||||||
return true;
|
|
||||||
} else if (version.contains("v1_11_")) {
|
|
||||||
return true;
|
|
||||||
} else if (version.contains("v1_12_")) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandWhitelist getPlugin() {return commandWhitelist;}
|
|
||||||
public static ConfigCache getConfigCache() {return configCache;}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,22 +3,18 @@ package eu.endermite.commandwhitelist.spigot.command;
|
|||||||
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
|
||||||
import org.bukkit.help.HelpTopic;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class MainCommand implements TabExecutor {
|
public class MainCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
if (!sender.hasPermission("commandwhitelist.reload")) {
|
if (!sender.hasPermission("commandwhitelist.reload")) {
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().getPrefix() + CommandWhitelist.getConfigCache().getNoPermission()));
|
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().prefix + CommandWhitelist.getConfigCache().no_permission));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CommandWhitelist.getPlugin().reloadPluginConfig(sender);
|
CommandWhitelist.getPlugin().reloadPluginConfig(sender);
|
||||||
@@ -26,17 +22,11 @@ public class MainCommand implements TabExecutor {
|
|||||||
} else if (args[0].equalsIgnoreCase("add")) {
|
} else if (args[0].equalsIgnoreCase("add")) {
|
||||||
|
|
||||||
if (!sender.hasPermission("commandwhitelist.admin")) {
|
if (!sender.hasPermission("commandwhitelist.admin")) {
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().getPrefix() + CommandWhitelist.getConfigCache().getNoPermission()));
|
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().prefix + CommandWhitelist.getConfigCache().no_permission));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
if (CommandWhitelist.getConfigCache().addCommand(args[2], args[1])) {
|
|
||||||
String msg = String.format(CommandWhitelist.getConfigCache().getWhitelistedCommand(), args[2], args[1]);
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
|
||||||
} else {
|
|
||||||
String msg = CommandWhitelist.getConfigCache().getNoSuchGroup();
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("/cw add <group> <command>");
|
sender.sendMessage("/cw add <group> <command>");
|
||||||
}
|
}
|
||||||
@@ -44,22 +34,16 @@ public class MainCommand implements TabExecutor {
|
|||||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||||
|
|
||||||
if (!sender.hasPermission("commandwhitelist.admin")) {
|
if (!sender.hasPermission("commandwhitelist.admin")) {
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().getPrefix() + CommandWhitelist.getConfigCache().getNoPermission()));
|
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().prefix + CommandWhitelist.getConfigCache().no_permission));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
if (CommandWhitelist.getConfigCache().removeCommand(args[2], args[1])) {
|
|
||||||
String msg = String.format(CommandWhitelist.getConfigCache().getRemovedWhitelistedCommand(), args[2], args[1]);
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
|
||||||
} else {
|
|
||||||
String msg = CommandWhitelist.getConfigCache().getNoSuchGroup();
|
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("/cw remove <group> <command>");
|
sender.sendMessage("/cw remove <group> <command>");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().getPrefix() + CommandWhitelist.getConfigCache().getNoSubCommand()));
|
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', CommandWhitelist.getConfigCache().prefix + CommandWhitelist.getConfigCache().no_such_subcommand));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bCommand Whitelist by YouHaveTrouble"));
|
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bCommand Whitelist by YouHaveTrouble"));
|
||||||
@@ -74,70 +58,5 @@ public class MainCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
if (args.length == 1) {
|
|
||||||
if ("reload".startsWith(args[0]) && sender.hasPermission("commandwhitelist.reload")) {
|
|
||||||
list.add("reload");
|
|
||||||
}
|
|
||||||
if ("add".startsWith(args[0]) && sender.hasPermission("commandwhitelist.admin")) {
|
|
||||||
list.add("add");
|
|
||||||
}
|
|
||||||
if ("remove".startsWith(args[0]) && sender.hasPermission("commandwhitelist.admin")) {
|
|
||||||
list.add("remove");
|
|
||||||
}
|
|
||||||
} else if (args.length == 2) {
|
|
||||||
if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove")) {
|
|
||||||
if (!sender.hasPermission("commandwhitelist.admin"))
|
|
||||||
return list;
|
|
||||||
for (Map.Entry<String, List<String>> s : CommandWhitelist.getConfigCache().getPermList().entrySet()) {
|
|
||||||
if (s.getKey().startsWith(args[1])) {
|
|
||||||
list.add(s.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (args.length == 3) {
|
|
||||||
if (args[0].equalsIgnoreCase("remove")) {
|
|
||||||
if (!sender.hasPermission("commandwhitelist.admin"))
|
|
||||||
return list;
|
|
||||||
try {
|
|
||||||
for (String s : CommandWhitelist.getConfigCache().getPermList().get(args[1])) {
|
|
||||||
if (s.startsWith(args[2])) {
|
|
||||||
list.add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (NullPointerException ignored) {
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("add")) {
|
|
||||||
if (!sender.hasPermission("commandwhitelist.admin"))
|
|
||||||
return list;
|
|
||||||
|
|
||||||
for (HelpTopic s : CommandWhitelist.getPlugin().getServer().getHelpMap().getHelpTopics()) {
|
|
||||||
String cmd = s.getName();
|
|
||||||
if (!cmd.startsWith("/"))
|
|
||||||
continue;
|
|
||||||
try {
|
|
||||||
if (cmd.contains(":")) {
|
|
||||||
cmd = cmd.split(":")[1];
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
cmd = cmd.replace("/", "");
|
|
||||||
|
|
||||||
if (CommandWhitelist.getConfigCache().getPermList().get(args[1]).contains(cmd))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (cmd.startsWith(args[2])) {
|
|
||||||
list.add(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,108 +0,0 @@
|
|||||||
package eu.endermite.commandwhitelist.spigot.config;
|
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ConfigCache {
|
|
||||||
|
|
||||||
private FileConfiguration config;
|
|
||||||
private HashMap<String, List<String>> permList = new HashMap<>();
|
|
||||||
private HashMap<String, List<String>> permSubList = new HashMap<>();
|
|
||||||
private final String prefix, commandDenied, noPermission, noSubCommand, configReloaded, whitelistedCommand,
|
|
||||||
removedWhitelistedCommand, noSuchGroup, subCommandDenied;
|
|
||||||
private final List<String> commandDeniedList;
|
|
||||||
private boolean useProtocolLib;
|
|
||||||
|
|
||||||
public ConfigCache(FileConfiguration config) {
|
|
||||||
|
|
||||||
this.config = config;
|
|
||||||
|
|
||||||
prefix = config.getString("messages.prefix", "");
|
|
||||||
commandDenied = config.getString("messages.command-denied", null);
|
|
||||||
commandDeniedList = config.getStringList("messages.command-denied");
|
|
||||||
subCommandDenied = config.getString("messages.subcommand-denied", "You cannot use this subcommand");
|
|
||||||
noPermission = config.getString("messages.no-permission", "&cYou don't have permission to do this.");
|
|
||||||
noSubCommand = config.getString("messages.no-such-subcommand", "&cNo subcommand by that name.");
|
|
||||||
configReloaded = config.getString("messages.config-reloaded", "&eConfiguration reloaded.");
|
|
||||||
whitelistedCommand = config.getString("messages.added-to-whitelist", "&eWhitelisted command &6%s &efor permission &6%s");
|
|
||||||
removedWhitelistedCommand = config.getString("messages.removed-from-whitelist", "&eRemoved command &6%s &efrom permission &6%s");
|
|
||||||
noSuchGroup = config.getString("messages.group-doesnt-exist", "&cGroup %s doesn't exist");
|
|
||||||
|
|
||||||
useProtocolLib = config.getBoolean("use-protocollib-to-detect-commands", false);
|
|
||||||
|
|
||||||
Set<String> perms = config.getConfigurationSection("commands").getKeys(false);
|
|
||||||
for (String s : perms) {
|
|
||||||
this.permList.put(s, config.getStringList("commands."+s));
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> subperms = config.getConfigurationSection("tabcompletions").getKeys(false);
|
|
||||||
for (String s : subperms) {
|
|
||||||
this.permSubList.put(s, config.getStringList("tabcompletions."+s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, List<String>> getPermList() {
|
|
||||||
return permList;
|
|
||||||
}
|
|
||||||
public HashMap<String, List<String>> getPermSubList() {
|
|
||||||
return permSubList;
|
|
||||||
}
|
|
||||||
public boolean addCommand(String command, String group) {
|
|
||||||
try {
|
|
||||||
if (this.permList.get(group).contains(command)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
this.permList.get(group).add(command);
|
|
||||||
this.config.set("commands."+group, permList.get(group));
|
|
||||||
config.save(CommandWhitelist.getPlugin().getDataFolder()+"/config.yml");
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
player.updateCommands();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public boolean removeCommand(String command, String group) {
|
|
||||||
try {
|
|
||||||
this.permList.get(group).remove(command);
|
|
||||||
this.config.set("commands."+group, permList.get(group));
|
|
||||||
config.save(CommandWhitelist.getPlugin().getDataFolder()+"/config.yml");
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
player.updateCommands();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public String getPrefix() {return prefix;}
|
|
||||||
public String getCommandDenied() {return commandDenied;}
|
|
||||||
public List<String> getCommandDeniedList() {
|
|
||||||
return commandDeniedList;
|
|
||||||
}
|
|
||||||
public String getNoPermission() {return noPermission;}
|
|
||||||
public String getNoSubCommand() {return noSubCommand;}
|
|
||||||
public String getConfigReloaded() {return configReloaded;}
|
|
||||||
public String getWhitelistedCommand() {
|
|
||||||
return whitelistedCommand;
|
|
||||||
}
|
|
||||||
public String getRemovedWhitelistedCommand() {
|
|
||||||
return removedWhitelistedCommand;
|
|
||||||
}
|
|
||||||
public String getNoSuchGroup() {
|
|
||||||
return noSuchGroup;
|
|
||||||
}
|
|
||||||
public String getSubCommandDenied() {
|
|
||||||
return subCommandDenied;
|
|
||||||
}
|
|
||||||
public boolean isUseProtocolLib() {
|
|
||||||
return useProtocolLib;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -7,7 +7,7 @@ import com.comphenix.protocol.events.ListenerPriority;
|
|||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import eu.endermite.commandwhitelist.api.CommandsList;
|
import eu.endermite.commandwhitelist.common.CommandsList;
|
||||||
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|||||||
+7
-7
@@ -7,10 +7,10 @@ import com.comphenix.protocol.events.ListenerPriority;
|
|||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import eu.endermite.commandwhitelist.api.CommandsList;
|
import eu.endermite.commandwhitelist.common.CWGroup;
|
||||||
import eu.endermite.commandwhitelist.api.RandomStuff;
|
import eu.endermite.commandwhitelist.common.CommandsList;
|
||||||
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
||||||
import eu.endermite.commandwhitelist.spigot.config.ConfigCache;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@@ -38,10 +38,10 @@ public class PacketCommandSendListener {
|
|||||||
String cmd = string.replace("/", "");
|
String cmd = string.replace("/", "");
|
||||||
String[] split = cmd.split("\\s+");
|
String[] split = cmd.split("\\s+");
|
||||||
String command = split[0].toLowerCase();
|
String command = split[0].toLowerCase();
|
||||||
for (Map.Entry<String, List<String>> s : CommandWhitelist.getConfigCache().getPermList().entrySet()) {
|
for (Map.Entry<String, CWGroup> s : CommandWhitelist.getConfigCache().getGroupList().entrySet()) {
|
||||||
if (!player.hasPermission("commandwhitelist.commands." + s.getKey()))
|
if (!player.hasPermission("commandwhitelist.commands." + s.getKey()))
|
||||||
continue;
|
continue;
|
||||||
for (String comm : s.getValue()) {
|
for (String comm : s.getValue().getCommands()) {
|
||||||
comm = comm.toLowerCase();
|
comm = comm.toLowerCase();
|
||||||
if (command.equalsIgnoreCase(comm) || command.startsWith(comm + " ")) {
|
if (command.equalsIgnoreCase(comm) || command.startsWith(comm + " ")) {
|
||||||
List<String> bannedSubCommands = CommandsList.getSuggestions(player);
|
List<String> bannedSubCommands = CommandsList.getSuggestions(player);
|
||||||
@@ -49,7 +49,7 @@ public class PacketCommandSendListener {
|
|||||||
if (cmd.startsWith(bannedSubCommand)) {
|
if (cmd.startsWith(bannedSubCommand)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
ConfigCache config = CommandWhitelist.getConfigCache();
|
ConfigCache config = CommandWhitelist.getConfigCache();
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getSubCommandDenied())));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.prefix + config.subcommand_denied));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ public class PacketCommandSendListener {
|
|||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
ConfigCache config = CommandWhitelist.getConfigCache();
|
ConfigCache config = CommandWhitelist.getConfigCache();
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getCommandDenied())));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.prefix + config.command_denied));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+7
-7
@@ -1,9 +1,9 @@
|
|||||||
package eu.endermite.commandwhitelist.spigot.listeners;
|
package eu.endermite.commandwhitelist.spigot.listeners;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.api.CommandsList;
|
import eu.endermite.commandwhitelist.common.CWGroup;
|
||||||
import eu.endermite.commandwhitelist.api.RandomStuff;
|
import eu.endermite.commandwhitelist.common.CommandsList;
|
||||||
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
import eu.endermite.commandwhitelist.spigot.CommandWhitelist;
|
||||||
import eu.endermite.commandwhitelist.spigot.config.ConfigCache;
|
import eu.endermite.commandwhitelist.common.ConfigCache;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -19,10 +19,10 @@ public class PlayerCommandPreProcessListener implements Listener {
|
|||||||
if (player.hasPermission("commandwhitelist.bypass"))
|
if (player.hasPermission("commandwhitelist.bypass"))
|
||||||
return;
|
return;
|
||||||
String command = event.getMessage().toLowerCase();
|
String command = event.getMessage().toLowerCase();
|
||||||
for (Map.Entry<String, List<String>> s : CommandWhitelist.getConfigCache().getPermList().entrySet()) {
|
for (Map.Entry<String, CWGroup> s : CommandWhitelist.getConfigCache().getGroupList().entrySet()) {
|
||||||
if (!player.hasPermission("commandwhitelist.commands." + s.getKey()))
|
if (!player.hasPermission("commandwhitelist.commands." + s.getKey()))
|
||||||
continue;
|
continue;
|
||||||
for (String comm : s.getValue()) {
|
for (String comm : s.getValue().getCommands()) {
|
||||||
comm = comm.toLowerCase();
|
comm = comm.toLowerCase();
|
||||||
if (command.equalsIgnoreCase("/" + comm) || command.startsWith("/" + comm + " ")) {
|
if (command.equalsIgnoreCase("/" + comm) || command.startsWith("/" + comm + " ")) {
|
||||||
String rawCmd = event.getMessage();
|
String rawCmd = event.getMessage();
|
||||||
@@ -31,7 +31,7 @@ public class PlayerCommandPreProcessListener implements Listener {
|
|||||||
if (rawCmd.startsWith("/"+bannedSubCommand)) {
|
if (rawCmd.startsWith("/"+bannedSubCommand)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
ConfigCache config = CommandWhitelist.getConfigCache();
|
ConfigCache config = CommandWhitelist.getConfigCache();
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getSubCommandDenied())));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.prefix + config.subcommand_denied));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,6 @@ public class PlayerCommandPreProcessListener implements Listener {
|
|||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
ConfigCache config = CommandWhitelist.getConfigCache();
|
ConfigCache config = CommandWhitelist.getConfigCache();
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getCommandDenied())));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.prefix + config.command_denied));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package eu.endermite.commandwhitelist.spigot.listeners;
|
package eu.endermite.commandwhitelist.spigot.listeners;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.api.CommandsList;
|
import eu.endermite.commandwhitelist.common.CommandsList;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package eu.endermite.commandwhitelist.spigot.listeners;
|
package eu.endermite.commandwhitelist.spigot.listeners;
|
||||||
|
|
||||||
import eu.endermite.commandwhitelist.api.CommandsList;
|
import eu.endermite.commandwhitelist.common.CommandsList;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
|||||||
@@ -7,11 +7,10 @@ import com.velocitypowered.api.event.Subscribe;
|
|||||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||||
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEvent;
|
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEvent;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
import com.velocitypowered.api.plugin.Plugin;
|
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import eu.endermite.commandwhitelist.api.CommandsList;
|
import eu.endermite.commandwhitelist.common.CommandsList;
|
||||||
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
|
import eu.endermite.commandwhitelist.velocity.command.VelocityMainCommand;
|
||||||
import eu.endermite.commandwhitelist.velocity.config.VelocityConfigCache;
|
import eu.endermite.commandwhitelist.velocity.config.VelocityConfigCache;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ commands:
|
|||||||
usage: /commandwhitelist [args]
|
usage: /commandwhitelist [args]
|
||||||
permissions:
|
permissions:
|
||||||
commandwhitelist.reload:
|
commandwhitelist.reload:
|
||||||
default: OP
|
default: op
|
||||||
commandwhitelist.admin:
|
commandwhitelist.admin:
|
||||||
default: OP
|
default: op
|
||||||
commandwhitelist.bypass:
|
commandwhitelist.bypass:
|
||||||
default: OP
|
default: op
|
||||||
commandwhitelist.commands.default:
|
|
||||||
default: true
|
|
||||||
Reference in New Issue
Block a user