diff --git a/pom.xml b/pom.xml index cc80e28..0ddd823 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code AliasBungee - 1.0.6 + 1.0.8-Snapshot-B2 jar T2C-AliasBungee diff --git a/src/main/java/net/t2code/alias/Bungee/Main.java b/src/main/java/net/t2code/alias/Bungee/Main.java index 5940603..0e133a9 100644 --- a/src/main/java/net/t2code/alias/Bungee/Main.java +++ b/src/main/java/net/t2code/alias/Bungee/Main.java @@ -2,7 +2,7 @@ package net.t2code.alias.Bungee; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.plugin.Plugin; -import net.t2code.alias.Bungee.objects.Alias_Objekt; +import net.t2code.alias.Bungee.objects.AliasObjekt; import net.t2code.alias.Bungee.system.Load; import net.t2code.alias.Util; import net.t2code.lib.Bungee.Lib.messages.BT2CodeTemplate; @@ -30,7 +30,7 @@ public final class Main extends Plugin { public static Main plugin; - public static HashMap aliasHashMap = new HashMap<>(); + public static HashMap aliasHashMap = new HashMap<>(); public static ArrayList allAliases = new ArrayList<>(); private static Boolean enable= false; diff --git a/src/main/java/net/t2code/alias/Bungee/cmdManagement/Alias_CmdExecuter.java b/src/main/java/net/t2code/alias/Bungee/cmdManagement/Alias_CmdExecuter.java index 878dc9d..fd8f24b 100644 --- a/src/main/java/net/t2code/alias/Bungee/cmdManagement/Alias_CmdExecuter.java +++ b/src/main/java/net/t2code/alias/Bungee/cmdManagement/Alias_CmdExecuter.java @@ -26,7 +26,7 @@ public class Alias_CmdExecuter extends Command implements TabExecutor { // Command if (sender.hasPermission("t2code.alias.command.info")) { Commands.info(sender); - } else Bsend.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info") + } else Bsend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info") .replace("[perm]", "t2code.alias.command.info")); } else { switch (args[0].toLowerCase()) { @@ -34,7 +34,7 @@ public class Alias_CmdExecuter extends Command implements TabExecutor { case "rl": if (sender.hasPermission("t2code.alias.command.reload")) { Commands.reload(sender); - } else Bsend.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias reload") + } else Bsend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias reload") .replace("[perm]", "t2code.alias.command.reload")); break; case "info": @@ -42,7 +42,7 @@ public class Alias_CmdExecuter extends Command implements TabExecutor { case "version": if (sender.hasPermission("t2code.alias.command.info")) { Commands.info(sender); - } else Bsend.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info") + } else Bsend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info") .replace("[perm]", "t2code.alias.command.info")); break; } diff --git a/src/main/java/net/t2code/alias/Bungee/cmdManagement/Commands.java b/src/main/java/net/t2code/alias/Bungee/cmdManagement/Commands.java index 8c98b31..b6d7f83 100644 --- a/src/main/java/net/t2code/alias/Bungee/cmdManagement/Commands.java +++ b/src/main/java/net/t2code/alias/Bungee/cmdManagement/Commands.java @@ -25,12 +25,12 @@ public class Commands { } public static void reload(CommandSender sender) { - if (sender instanceof ProxiedPlayer) sender.sendMessage(SelectMessages.ReloadStart); + if (sender instanceof ProxiedPlayer) sender.sendMessage(SelectMessages.reloadStart); Bsend.console(Main.prefix + "§8-------------------------------"); Bsend.console(Main.prefix + " §6Plugin reload..."); Bsend.console(Main.prefix + "§8-------------------------------"); Load.loadReload(); - if (sender instanceof ProxiedPlayer) sender.sendMessage(SelectMessages.ReloadEnd); + if (sender instanceof ProxiedPlayer) sender.sendMessage(SelectMessages.reloadEnd); Bsend.console(Main.prefix + "§8-------------------------------"); Bsend.console(Main.prefix + " §2Plugin successfully reloaded."); Bsend.console(Main.prefix + "§8-------------------------------"); diff --git a/src/main/java/net/t2code/alias/Bungee/cmdManagement/RegisterCommands.java b/src/main/java/net/t2code/alias/Bungee/cmdManagement/RegisterCommands.java index 0ed9d7f..e8c9348 100644 --- a/src/main/java/net/t2code/alias/Bungee/cmdManagement/RegisterCommands.java +++ b/src/main/java/net/t2code/alias/Bungee/cmdManagement/RegisterCommands.java @@ -6,7 +6,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Command; import net.t2code.alias.Bungee.Main; import net.t2code.alias.Bungee.config.languages.SelectMessages; -import net.t2code.alias.Bungee.objects.Alias_Objekt; +import net.t2code.alias.Bungee.objects.AliasObjekt; import net.t2code.lib.Bungee.Lib.commands.Bcmd; import net.t2code.lib.Bungee.Lib.messages.Bsend; import net.t2code.lib.Bungee.Lib.replace.BReplace; @@ -23,35 +23,44 @@ public class RegisterCommands extends Command { @Override public void execute(CommandSender sender, String[] args) { - Alias_Objekt Alias = Main.aliasHashMap.get(alias); + AliasObjekt Alias = Main.aliasHashMap.get(alias); - if (!Alias.AliasEnable) { - Bsend.sender(sender, SelectMessages.AliasDisabled); + if (!Alias.aliasEnable) { + Bsend.sender(sender, SelectMessages.aliasDisabled); return; } if (sender instanceof ProxiedPlayer) { ProxiedPlayer player = (ProxiedPlayer) sender; - if (Alias.AdminEnable) { - if (player.hasPermission(Alias.AdminPermission)) { - if (Alias.AdminCommandEnable) { - for (String cmd : Alias.AdminCommands) { - if (Alias.AdminCommandAsConsole) { + if (Alias.serverProtectionEnable) { + if (Alias.serverProtectionMode.equalsIgnoreCase("blacklist") && Alias.serverProtectionList.contains(player.getServer().getInfo().getName())) { + return; + } + if (Alias.serverProtectionMode.equalsIgnoreCase("whitelist") && !Alias.serverProtectionList.contains(player.getServer().getInfo().getName())) { + return; + } + } + + if (Alias.adminEnable) { + if (player.hasPermission(Alias.adminPermission)) { + if (Alias.adminCommandEnable) { + for (String cmd : Alias.adminCommands) { + if (Alias.adminCommandAsConsole) { Bcmd.Console(cmd.replace("[player]", player.getName())); } else { Bcmd.Player(player, cmd.replace("[player]", player.getName())); } } } - if (Alias.AdminMessageEnable) { - for (String msg : Alias.AdminMessages) { + if (Alias.adminMessageEnable) { + for (String msg : Alias.adminMessages) { String text = BReplace.replace(prefix, msg); - String hover = BReplace.replace(prefix, Alias.AdminHover); - if (Alias.AdminTextBuilder) { + String hover = BReplace.replace(prefix, Alias.adminHover); + if (Alias.adminTextBuilder) { TextBuilder textBuilder = new TextBuilder(text); textBuilder.addHover(hover); - if (Alias.AdminClickEvent) { - textBuilder.addClickEvent(ClickEvent.Action.valueOf(Alias.AdminAction), Alias.AdminActionValue); + if (Alias.adminClickEvent) { + textBuilder.addClickEvent(ClickEvent.Action.valueOf(Alias.adminAction), Alias.adminActionValue); } player.sendMessage(textBuilder.build()); } else { @@ -62,31 +71,31 @@ public class RegisterCommands extends Command { return; } } - if (Alias.Perm_necessary) { + if (Alias.permNecessary) { if (!(player.hasPermission("t2code.alias.use." + alias.toLowerCase()) || player.hasPermission("t2code.alias.admin"))) { - Bsend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/" + alias.toLowerCase()) + Bsend.player(player, SelectMessages.noPermissionForCommand.replace("[cmd]", "/" + alias.toLowerCase()) .replace("[perm]", "t2code.alias.use." + alias.toLowerCase())); return; } } - if (Alias.Command_Enable) { - for (String cmd : Alias.Command) { - if (Alias.CommandAsConsole) { + if (Alias.command_Enable) { + for (String cmd : Alias.command) { + if (Alias.commandAsConsole) { Bcmd.Console(cmd.replace("[player]", player.getName())); } else { Bcmd.Player(player, cmd.replace("[player]", player.getName())); } } } - if (Alias.Message_Enable) { - for (String msg : Alias.Messages) { + if (Alias.messageEnable) { + for (String msg : Alias.messages) { String text = BReplace.replace(prefix, msg); - String hover = BReplace.replace(prefix, Alias.Hover); - if (Alias.TextBuilder) { + String hover = BReplace.replace(prefix, Alias.hover); + if (Alias.textBuilder) { TextBuilder textBuilder = new TextBuilder(text); textBuilder.addHover(hover); - if (Alias.ClickEvent) { - textBuilder.addClickEvent(ClickEvent.Action.valueOf(Alias.Action), Alias.ActionValue); + if (Alias.clickEvent) { + textBuilder.addClickEvent(ClickEvent.Action.valueOf(Alias.action), Alias.actionValue); } player.sendMessage(textBuilder.build()); } else { @@ -95,18 +104,18 @@ public class RegisterCommands extends Command { } } } else { - if (Alias.ConsoleEnable) { - if (Alias.ConsoleCommandEnable) { - for (String cmd : Alias.ConsoleCommands) { + if (Alias.consoleEnable) { + if (Alias.consoleCommandEnable) { + for (String cmd : Alias.consoleCommands) { Bcmd.Console(cmd.replace("[player]", sender.getName())); } } - if (Alias.ConsoleMessageEnable) { - for (String msg : Alias.ConsoleMessages) { + if (Alias.consoleMessageEnable) { + for (String msg : Alias.consoleMessages) { Bsend.console(BReplace.replace(prefix, msg)); } } - } else Bsend.sender(sender, SelectMessages.OnlyForPlayer); + } else Bsend.sender(sender, SelectMessages.onlyForPlayer); } return; } diff --git a/src/main/java/net/t2code/alias/Bungee/config/config/CreateExampleAliasConfig.java b/src/main/java/net/t2code/alias/Bungee/config/config/CreateExampleAliasConfig.java index d585c23..5aa9bd4 100644 --- a/src/main/java/net/t2code/alias/Bungee/config/config/CreateExampleAliasConfig.java +++ b/src/main/java/net/t2code/alias/Bungee/config/config/CreateExampleAliasConfig.java @@ -68,6 +68,10 @@ public class CreateExampleAliasConfig { BConfig.set("Alias.Enable", Enable, configuration); BConfig.set("Alias.Permission.Necessary", PermNecessary, configuration); + BConfig.set("Alias.Protection.Server.Enable", false, configuration); + BConfig.set("Alias.Protection.Server.Mode", "blacklist", configuration); + BConfig.set("Alias.Protection.Server.List", Arrays.asList("Server1", "Server2"), configuration); + BConfig.set("Alias.Command.Enable", CommandEnable, configuration); BConfig.set("Alias.Command.CommandAsConsole", CommandAsConsole, configuration); BConfig.set("Alias.Command.Commands", Commands, configuration); @@ -80,7 +84,6 @@ public class CreateExampleAliasConfig { BConfig.set("Alias.Message.TextBuilder.ClickEvent.Action", Action, configuration); BConfig.set("Alias.Message.TextBuilder.ClickEvent.ActionValue", ActionValue, configuration); - BConfig.set("Alias.Admin.Enable", AdminEnable, configuration); BConfig.set("Alias.Admin.Permission", AdminPermission, configuration); diff --git a/src/main/java/net/t2code/alias/Bungee/config/config/SelectAlias.java b/src/main/java/net/t2code/alias/Bungee/config/config/SelectAlias.java index 7b37c96..36fad25 100644 --- a/src/main/java/net/t2code/alias/Bungee/config/config/SelectAlias.java +++ b/src/main/java/net/t2code/alias/Bungee/config/config/SelectAlias.java @@ -5,7 +5,7 @@ import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; import net.t2code.alias.Bungee.Main; import net.t2code.alias.Bungee.system.AliasRegister; -import net.t2code.alias.Bungee.objects.Alias_Objekt; +import net.t2code.alias.Bungee.objects.AliasObjekt; import java.io.File; import java.io.IOException; @@ -24,10 +24,14 @@ public class SelectAlias { if (sub.equals(".yml")) { Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config_gui); - Alias_Objekt alias = new Alias_Objekt( + AliasObjekt alias = new AliasObjekt( configuration.getBoolean("Alias.Enable"), configuration.getBoolean("Alias.Permission.Necessary"), + configuration.getBoolean("Alias.Protection.Server.Enable"), + configuration.getString("Alias.Protection.Server.Mode"), + configuration.getStringList("Alias.Protection.Server.List"), + configuration.getBoolean("Alias.Command.Enable"), configuration.getBoolean("Alias.Command.CommandAsConsole"), configuration.getStringList("Alias.Command.Commands"), diff --git a/src/main/java/net/t2code/alias/Bungee/config/languages/SelectMessages.java b/src/main/java/net/t2code/alias/Bungee/config/languages/SelectMessages.java index aedd8ce..615a256 100644 --- a/src/main/java/net/t2code/alias/Bungee/config/languages/SelectMessages.java +++ b/src/main/java/net/t2code/alias/Bungee/config/languages/SelectMessages.java @@ -5,6 +5,7 @@ import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; import net.t2code.alias.Bungee.Main; import net.t2code.alias.Bungee.config.config.SelectConfig; +import net.t2code.alias.Util; import net.t2code.lib.Bungee.Lib.messages.Bsend; import net.t2code.lib.Bungee.Lib.yamlConfiguration.BConfig; @@ -12,16 +13,17 @@ import java.io.File; import java.io.IOException; public class SelectMessages { - private static String prefix = Main.prefix; + + private static String prefix = Util.getPrefix(); public static String selectMSG; - public static String OnlyForPlayer; - public static String ReloadStart; - public static String ReloadEnd; + public static String onlyForPlayer; + public static String reloadStart; + public static String reloadEnd; - public static String NoPermissionForCommand; - public static String AliasDisabled; + public static String noPermissionForCommand; + public static String aliasDisabled; public static void onSelect(String Prefix)throws IOException { @@ -40,11 +42,11 @@ public class SelectMessages { } else selectMSG = SelectConfig.language; Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(msg); - OnlyForPlayer = BConfig.select(prefix, "Plugin.OnlyForPlayer", configuration); - AliasDisabled = BConfig.select(prefix, "Plugin.AliasDisabled", configuration); - ReloadStart = BConfig.select(prefix, "Plugin.Reload.Start", configuration); - ReloadEnd = BConfig.select(prefix, "Plugin.Reload.End", configuration); - NoPermissionForCommand = BConfig.select(prefix, "Plugin.ForCommand", configuration); + onlyForPlayer = BConfig.select(prefix, "Plugin.OnlyForPlayer", configuration); + aliasDisabled = BConfig.select(prefix, "Plugin.AliasDisabled", configuration); + reloadStart = BConfig.select(prefix, "Plugin.Reload.Start", configuration); + reloadEnd = BConfig.select(prefix, "Plugin.Reload.End", configuration); + noPermissionForCommand = BConfig.select(prefix, "Plugin.ForCommand", configuration); Bsend.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); } diff --git a/src/main/java/net/t2code/alias/Bungee/objects/AliasObjekt.java b/src/main/java/net/t2code/alias/Bungee/objects/AliasObjekt.java new file mode 100644 index 0000000..836ee47 --- /dev/null +++ b/src/main/java/net/t2code/alias/Bungee/objects/AliasObjekt.java @@ -0,0 +1,115 @@ +package net.t2code.alias.Bungee.objects; + +import java.util.List; + +public class AliasObjekt { + public Boolean aliasEnable; + public Boolean permNecessary; + + public Boolean serverProtectionEnable; + public String serverProtectionMode; + public List serverProtectionList; + + public Boolean command_Enable; + public Boolean commandAsConsole; + public List command; + public Boolean messageEnable; + public List messages; + public Boolean textBuilder; + public String hover; + public Boolean clickEvent; + public String action; + public String actionValue; + + public Boolean adminEnable; + public String adminPermission; + public Boolean adminCommandEnable; + public Boolean adminCommandAsConsole; + public List adminCommands; + public Boolean adminMessageEnable; + public List adminMessages; + public Boolean adminTextBuilder; + public String adminHover; + public Boolean adminClickEvent; + public String adminAction; + public String adminActionValue; + public Boolean consoleEnable; + public Boolean consoleCommandEnable; + public List consoleCommands; + public Boolean consoleMessageEnable; + public List consoleMessages; + + public AliasObjekt(Boolean aliasEnable, + Boolean permNecessary, + + Boolean serverProtectionEnable, + String serverProtectionMode, + List serverProtectionList, + + Boolean commandEnable, + Boolean commandAsConsole, + List command, + Boolean message_Enable, + List messages, + Boolean textBuilder, + String hover, + Boolean clickEvent, + String action, + String actionValue, + + Boolean adminEnable, + String adminPermission, + Boolean adminCommandEnable, + Boolean adminCommandAsConsole, + List adminCommands, + Boolean adminMessageEnable, + List adminMessages, + Boolean adminTextBuilder, + String adminHover, + Boolean adminClickEvent, + String adminAction, + String adminActionValue, + + Boolean consoleEnable, + Boolean consoleCommandEnable, + List consoleCommands, + Boolean consoleMessageEnable, + List consoleMessages) { + this.aliasEnable = aliasEnable; + this.permNecessary = permNecessary; + + this.serverProtectionEnable = serverProtectionEnable; + this.serverProtectionMode = serverProtectionMode; + this.serverProtectionList = serverProtectionList; + + this.command_Enable = commandEnable; + this.commandAsConsole = commandAsConsole; + this.command = command; + this.messageEnable = message_Enable; + this.messages = messages; + this.textBuilder = textBuilder; + this.hover = hover; + this.clickEvent = clickEvent; + this.action = action; + this.actionValue = actionValue; + this.adminEnable = adminEnable; + this.adminPermission = adminPermission; + this.adminCommandEnable = adminCommandEnable; + this.adminCommandAsConsole = adminCommandAsConsole; + this.adminCommands = adminCommands; + this.adminMessageEnable = adminMessageEnable; + this.adminMessages = adminMessages; + this.adminTextBuilder = adminTextBuilder; + this.adminHover = adminHover; + this.adminClickEvent = adminClickEvent; + this.adminAction = adminAction; + this.adminActionValue = adminActionValue; + + this.consoleEnable = consoleEnable; + this.consoleCommandEnable = consoleCommandEnable; + this.consoleCommands = consoleCommands; + this.consoleMessageEnable = consoleMessageEnable; + this.consoleMessages = consoleMessages; + + } +} diff --git a/src/main/java/net/t2code/alias/Bungee/objects/Alias_Objekt.java b/src/main/java/net/t2code/alias/Bungee/objects/Alias_Objekt.java deleted file mode 100644 index 2374f1d..0000000 --- a/src/main/java/net/t2code/alias/Bungee/objects/Alias_Objekt.java +++ /dev/null @@ -1,103 +0,0 @@ -package net.t2code.alias.Bungee.objects; - -import java.util.List; - -public class Alias_Objekt { - public Boolean AliasEnable; - public Boolean Command_Enable; - public Boolean Perm_necessary; - - public Boolean CommandAsConsole; - public List Command; - public Boolean Message_Enable; - public List Messages; - public Boolean TextBuilder; - public String Hover; - public Boolean ClickEvent; - public String Action; - public String ActionValue; - - public Boolean AdminEnable; - public String AdminPermission; - public Boolean AdminCommandEnable; - public Boolean AdminCommandAsConsole; - public List AdminCommands; - public Boolean AdminMessageEnable; - public List AdminMessages; - public Boolean AdminTextBuilder; - public String AdminHover; - public Boolean AdminClickEvent; - public String AdminAction; - public String AdminActionValue; - public Boolean ConsoleEnable; - public Boolean ConsoleCommandEnable; - public List ConsoleCommands; - public Boolean ConsoleMessageEnable; - public List ConsoleMessages; - - public Alias_Objekt(Boolean AliasEnable, - Boolean Perm_necessary, - - Boolean Command_Enable, - Boolean CommandAsConsole, - List Command, - Boolean Message_Enable, - List Messages, - Boolean TextBuilder, - String Hover, - Boolean ClickEvent, - String Action, - String ActionValue, - - Boolean AdminEnable, - String AdminPermission, - Boolean AdminCommandEnable, - Boolean AdminCommandAsConsole, - List AdminCommands, - Boolean AdminMessageEnable, - List AdminMessages, - Boolean AdminTextBuilder, - String AdminHover, - Boolean AdminClickEvent, - String AdminAction, - String AdminActionValue, - - Boolean ConsoleEnable, - Boolean ConsoleCommandEnable, - List ConsoleCommands, - Boolean ConsoleMessageEnable, - List ConsoleMessages) { - this.AliasEnable = AliasEnable; - this.Perm_necessary = Perm_necessary; - - this.Command_Enable = Command_Enable; - this.CommandAsConsole = CommandAsConsole; - this.Command = Command; - this.Message_Enable = Message_Enable; - this.Messages = Messages; - this.TextBuilder = TextBuilder; - this.Hover = Hover; - this.ClickEvent = ClickEvent; - this.Action = Action; - this.ActionValue = ActionValue; - this.AdminEnable = AdminEnable; - this.AdminPermission = AdminPermission; - this.AdminCommandEnable = AdminCommandEnable; - this.AdminCommandAsConsole = AdminCommandAsConsole; - this.AdminCommands = AdminCommands; - this.AdminMessageEnable = AdminMessageEnable; - this.AdminMessages = AdminMessages; - this.AdminTextBuilder = AdminTextBuilder; - this.AdminHover = AdminHover; - this.AdminClickEvent = AdminClickEvent; - this.AdminAction = AdminAction; - this.AdminActionValue = AdminActionValue; - - this.ConsoleEnable = ConsoleEnable; - this.ConsoleCommandEnable = ConsoleCommandEnable; - this.ConsoleCommands = ConsoleCommands; - this.ConsoleMessageEnable = ConsoleMessageEnable; - this.ConsoleMessages = ConsoleMessages; - - } -} diff --git a/src/main/java/net/t2code/alias/Bungee/system/AliasRegister.java b/src/main/java/net/t2code/alias/Bungee/system/AliasRegister.java index 255a5dc..5cb1af8 100644 --- a/src/main/java/net/t2code/alias/Bungee/system/AliasRegister.java +++ b/src/main/java/net/t2code/alias/Bungee/system/AliasRegister.java @@ -11,7 +11,7 @@ public class AliasRegister { Plugin plugin = Main.plugin; for (String alias : Main.allAliases) { if (Main.aliasHashMap.get(alias) != null) { - if (Main.aliasHashMap.get(alias).AliasEnable) { + if (Main.aliasHashMap.get(alias).aliasEnable) { Bsend.debug(plugin, "Alias register 1.18_R1"); ProxyServer.getInstance().getPluginManager().registerCommand(Main.plugin, new RegisterCommands(alias)); }