fix format

This commit is contained in:
YouHaveTrouble
2021-05-07 00:23:39 +02:00
parent 862fa193e6
commit 20eb731b93
4 changed files with 11 additions and 13 deletions
@@ -42,9 +42,9 @@ public class MainCommandExecutor implements TabExecutor {
} }
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(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().added_to_whitelist)); audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().added_to_whitelist, args[2], args[1])));
else else
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist)); audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(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;
@@ -55,9 +55,9 @@ public class MainCommandExecutor implements TabExecutor {
} }
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(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().removed_from_whitelist)); audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(String.format(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().removed_from_whitelist, args[2], args[1])));
else else
audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(CommandWhitelistBukkit.getConfigCache().prefix + CommandWhitelistBukkit.getConfigCache().group_doesnt_exist)); audiences.sender(sender).sendMessage(MiniMessage.markdown().parse(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;
@@ -126,6 +126,9 @@ public class MainCommandExecutor implements TabExecutor {
} }
cmd = cmd.replace("/", ""); cmd = cmd.replace("/", "");
if (config.getGroupList().get(args[1]) == null)
continue;
if (config.getGroupList().get(args[1]).getCommands().contains(cmd)) if (config.getGroupList().get(args[1]).getCommands().contains(cmd))
continue; continue;
@@ -2,14 +2,11 @@ package eu.endermite.commandwhitelist.common;
import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
public class ConfigCache { public class ConfigCache {
//TODO probably rewrite this yet again
private final File configFile; private final File configFile;
private final boolean canDoProtocolLib; private final boolean canDoProtocolLib;
private final HashMap<String, CWGroup> groupList = new LinkedHashMap<>(); private final HashMap<String, CWGroup> groupList = new LinkedHashMap<>();
@@ -93,7 +90,7 @@ public class ConfigCache {
this.config_reloaded = messages.get("config_reloaded"); this.config_reloaded = messages.get("config_reloaded");
this.added_to_whitelist = messages.get("added_to_whitelist"); this.added_to_whitelist = messages.get("added_to_whitelist");
this.removed_from_whitelist = messages.get("removed_from_whitelist"); this.removed_from_whitelist = messages.get("removed_from_whitelist");
this.group_doesnt_exist = messages.get("group_doesnt-exist"); this.group_doesnt_exist = messages.get("group_doesnt_exist");
this.subcommand_denied = messages.get("subcommand_denied"); this.subcommand_denied = messages.get("subcommand_denied");
if (canDoProtocolLib) if (canDoProtocolLib)
@@ -129,8 +126,8 @@ public class ConfigCache {
messages.put("no_permission", stringOrDefault(no_permission, "<red>You don't have permission to do this.")); 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("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("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("added_to_whitelist", stringOrDefault(added_to_whitelist, "<yellow>Whitelisted command <gold>%s <yellow>for permission <gold>%s"));
messages.put("removed_from_whitelist", stringOrDefault(removed_from_whitelist, "<yellow>Removed command <orange>%s <yellow>from permission <orange>%s")); messages.put("removed_from_whitelist", stringOrDefault(removed_from_whitelist, "<yellow>Removed command <gold>%s <yellow>from permission <gold>%s"));
messages.put("group_doesnt_exist", stringOrDefault(group_doesnt_exist, "<red>Group doesn't exist or error occured")); messages.put("group_doesnt_exist", stringOrDefault(group_doesnt_exist, "<red>Group doesn't exist or error occured"));
return messages; return messages;
} }
@@ -1,6 +1,5 @@
package eu.endermite.commandwhitelist.common.commands; package eu.endermite.commandwhitelist.common.commands;
import com.mojang.brigadier.tree.LiteralCommandNode;
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 net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@@ -9,7 +8,6 @@ import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
public class CWCommand { public class CWCommand {
public static boolean addToWhitelist(ConfigCache configCache, String command, String group) { public static boolean addToWhitelist(ConfigCache configCache, String command, String group) {
@@ -31,7 +31,7 @@ public final class CommandWhitelistWaterfall extends Plugin {
audiences = BungeeAudiences.create(this); audiences = BungeeAudiences.create(this);
this.getProxy().getPluginManager().registerListener(this, new BungeeChatEventListener()); this.getProxy().getPluginManager().registerListener(this, new BungeeChatEventListener());
try { try {
Class.forName("io.github.waterfallmc.waterfall.conf.WaterfallConfiguration"); Class.forName("io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent");
this.getProxy().getPluginManager().registerListener(this, new WaterfallDefineCommandsListener()); this.getProxy().getPluginManager().registerListener(this, new WaterfallDefineCommandsListener());
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
getLogger().severe(ChatColor.DARK_RED+"Bungee tab completion blocker requires Waterfall other Waterfall fork."); getLogger().severe(ChatColor.DARK_RED+"Bungee tab completion blocker requires Waterfall other Waterfall fork.");