diff --git a/pom.xml b/pom.xml index ac4f15d..c658675 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code Alias - 1.0.11 + 1.1.0 jar T2C-Alias @@ -69,7 +69,7 @@ net.t2code T2CodeLib - 12.0 + 12.4 net.t2code @@ -82,94 +82,9 @@ 3.0 - net.t2code.minecraft.1_18.r2 + net.t2code.minecraft.1_19.r1 spigot - 1.18r2 - - - net.t2code.minecraft.1_18.r1 - spigot - 1.18r1 - - - net.t2code.minecraft.1_17.r1 - spigot - 1.17r1 - - - net.t2code.minecraft.1_16.r3 - spigot - 1.16r3 - - - net.t2code.minecraft.1_16.r2 - spigot - 1.16r2 - - - net.t2code.minecraft.1_16.r1 - spigot - 1.16r1 - - - net.t2code.minecraft.1_15.r1 - spigot - 1.15r1 - - - net.t2code.minecraft.1_14.r1 - spigot - 1.14r1 - - - net.t2code.minecraft.1_13.r2 - spigot - 1.13r2 - - - net.t2code.minecraft.1_13.r1 - spigot - 1.13r1 - - - net.t2code.minecraft.1_12.r1 - spigot - 1.12r1 - - - net.t2code.minecraft.1_11.r1 - spigot - 1.11r1 - - - net.t2code.minecraft.1_10.r1 - spigot - 1.10r1 - - - net.t2code.minecraft.1_9.r2 - spigot - 1.9r2 - - - net.t2code.minecraft.1_9.r1 - spigot - 1.9r1 - - - net.t2code.minecraft.1_8.r3 - spigot - 1.8r3 - - - net.t2code.minecraft.1_8.r2 - spigot - 1.8r2 - - - net.t2code.minecraft.1_8.r1 - spigot - 1.8r1 + 1.19r1 diff --git a/src/main/java/net/t2code/alias/Spigot/Main.java b/src/main/java/net/t2code/alias/Spigot/Main.java index f0c60c9..3102ee4 100644 --- a/src/main/java/net/t2code/alias/Spigot/Main.java +++ b/src/main/java/net/t2code/alias/Spigot/Main.java @@ -1,6 +1,7 @@ package net.t2code.alias.Spigot; -import net.t2code.alias.Spigot.objects.AliasObjekt; +import net.t2code.alias.Spigot.objects.AliasObject; +import net.t2code.alias.Spigot.objects.SubAliasObject; import net.t2code.alias.Spigot.system.Load; import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; @@ -11,7 +12,6 @@ import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.logging.Level; public final class Main extends JavaPlugin { @@ -19,11 +19,14 @@ public final class Main extends JavaPlugin { return plugin.getDataFolder(); } - public static String version; - public static List autor; - public static Main plugin; - public static HashMap aliasHashMap = new HashMap<>(); + private static String version; + private static List autor; + private static Main plugin; + public static HashMap aliasHashMap = new HashMap<>(); + public static HashMap subAliasHashMap = new HashMap<>(); public static ArrayList allAliases = new ArrayList<>(); + public static ArrayList allSubAliases = new ArrayList<>(); + public static ArrayList allForSubAliases = new ArrayList<>(); @Override public void onEnable() { @@ -44,21 +47,48 @@ public final class Main extends JavaPlugin { T2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); } - public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) { + public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) { if (Bukkit.getPluginManager().getPlugin(pl) == null) { plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); - Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: " + - "§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin."); + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: " + + "§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin."); Main.plugin.getPluginLoader().disablePlugin(Main.plugin); return true; } else { - if (Double.parseDouble(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(pl)).getDescription().getVersion()) < ver) { + String plVer = Bukkit.getPluginManager().getPlugin(pl).getDescription().getVersion(); + if (ver.contains("_")) { + if (!plVer.equals(ver)) { + plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires the version §2" + + ver + " §4of §6" + pl + " §4Please use this version! Please download it here or contact us in Discord: §6https://spigotmc.org/resources/" + + pl + "." + spigotID + " Or contact us in Discord: http://dc.t2code.net"); + Main.plugin.getPluginLoader().disablePlugin(Main.plugin); + return true; + } + return false; + } + String[] split = plVer.split("_"); + if (Double.parseDouble(split[0]) < Double.parseDouble(ver)) { plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); - Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to use this version of " + plugin.getDescription().getName() + "."); + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + + " §4to use this version of " + plugin.getDescription().getName() + "."); Main.plugin.getPluginLoader().disablePlugin(Main.plugin); return true; } return false; } } + + public static Main getPlugin() { + return plugin; + } + + public static String getVersion() { + return version; + } + + public static List getAutor() { + return autor; + } } diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/AliasCmdExecuter.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/AliasCmdExecuter.java index 90982f5..b9ddd88 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/AliasCmdExecuter.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/AliasCmdExecuter.java @@ -1,5 +1,6 @@ package net.t2code.alias.Spigot.cmdManagement; +import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.config.languages.SelectMessages; import net.t2code.lib.Spigot.Lib.messages.send; import org.bukkit.command.Command; @@ -9,6 +10,7 @@ import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java index 0935343..decb4bc 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java @@ -7,12 +7,14 @@ import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commands { public static void info(CommandSender sender) { - T2CodeTemplate.sendInfo(sender, Util.getPrefix(),Util.getSpigot(),Util.getDiscord(),Main.autor,Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion); + T2CodeTemplate.sendInfo(sender, Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.getAutor(), Main.getVersion(), + UpdateAPI.PluginVersionen.get(Main.getPlugin().getName()).publicVersion); } public static void reload(CommandSender sender) { @@ -20,7 +22,7 @@ public class Commands { send.console(Util.getPrefix() + "§8-------------------------------"); send.console(Util.getPrefix() + " §6Plugin reload..."); send.console(Util.getPrefix() + "§8-------------------------------"); - Load.loadReload(); + Main.getPlugin().onEnable(); if (sender instanceof Player) sender.sendMessage(SelectMessages.reloadEnd); send.console(Util.getPrefix() + "§8-------------------------------"); send.console(Util.getPrefix() + " §2Plugin successfully reloaded."); diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/ExecuteAlias.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/ExecuteAlias.java new file mode 100644 index 0000000..fb362bf --- /dev/null +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/ExecuteAlias.java @@ -0,0 +1,362 @@ +package net.t2code.alias.Spigot.cmdManagement; + +import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Spigot.config.config.SelectConfig; +import net.t2code.alias.Spigot.config.languages.SelectMessages; +import net.t2code.alias.Spigot.objects.AliasObject; +import net.t2code.alias.Spigot.objects.SubAliasObject; +import net.t2code.alias.Spigot.system.BCommandSenderReciver; +import net.t2code.alias.Util; +import net.t2code.lib.Spigot.Lib.commands.Cmd; +import net.t2code.lib.Spigot.Lib.eco.Eco; +import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.plugins.PluginCheck; +import net.t2code.lib.Spigot.Lib.replace.Replace; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class ExecuteAlias { + private static final String prefix = Util.getPrefix(); + + protected static void aliasPlayer(CommandSender sender, AliasObject aliasObject, String alias, String[] args) { + Player player = (Player) sender; + + if (aliasObject.adminEnable) { + if (player.hasPermission(aliasObject.adminPermission)) { + if (aliasObject.adminCommandEnable) { + aliasAdminCommand(aliasObject, player, args); + } + if (aliasObject.adminMessageEnable) { + aliasAdminMessage(aliasObject, alias, player, args); + } + return; + } + } + + if (aliasObject.permNecessary) { + if (!(player.hasPermission(aliasObject.permission.replace("", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) { + String npmsg; + if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) { + npmsg = SelectMessages.noPermissionForCommand; + } else npmsg = aliasObject.permissionMSG; + send.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase()) + .replace("[perm]", aliasObject.permission.replace("", alias.toLowerCase())).replace("[alias]", alias)); + return; + } + } + if (aliasObject.costEnable) { + if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) { + if (!Eco.moneyRemove(prefix, player, aliasObject.costPrice)) { + send.player(player, SelectMessages.noMoney); + return; + } + if (SelectConfig.buyMessage) send.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString())); + } + } + if (aliasObject.commandEnable) { + aliasCommand(aliasObject, player, args); + } + if (aliasObject.messageEnable) { + aliasMessage(aliasObject, alias, player, args); + } + } + + protected static void subAliasPlayer(CommandSender sender, SubAliasObject aliasObject, String alias, String[] args) { + if (!aliasObject.subAliasEnable) { + send.sender(sender, SelectMessages.aliasDisabled); + return; + } + + if (sender instanceof Player) { + Player player = (Player) sender; + + if (aliasObject.adminEnable) { + if (player.hasPermission(aliasObject.adminPermission)) { + if (aliasObject.adminCommandEnable) { + subAliasAdminCommand(aliasObject, player, args); + } + if (aliasObject.adminMessageEnable) { + subAliasAdminMessage(aliasObject, alias, player, args); + } + return; + } + } + + if (aliasObject.permNecessary) { + if (!(player.hasPermission(aliasObject.permission.replace("", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) { + String npmsg; + if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) { + npmsg = SelectMessages.noPermissionForCommand; + } else npmsg = aliasObject.permissionMSG; + send.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase()) + .replace("[perm]", aliasObject.permission.replace("", alias.toLowerCase())).replace("[alias]", alias)); + return; + } + } + if (aliasObject.costEnable) { + if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) { + if (!Eco.moneyRemove(prefix, player, aliasObject.costPrice)) { + send.player(player, SelectMessages.noMoney); + return; + } + if (SelectConfig.buyMessage) send.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString())); + } + } + if (aliasObject.commandEnable) { + subAliasCommand(aliasObject, player, args); + } + if (aliasObject.messageEnable) { + subAliasMessage(aliasObject, alias, player, args); + } + } else { + if (aliasObject.consoleEnable) { + subAliasConsole(aliasObject, sender, args); + } else send.sender(sender, SelectMessages.onlyForPlayer); + } + } + + protected static void aliasConsole(AliasObject alias, CommandSender sender, String prefix) { + if (alias.consoleCommandEnable) { + for (String cmd : alias.consoleCommands) { + if (alias.consoleBungeeCommand) { + if (SelectConfig.Bungee) { + BCommandSenderReciver.sendToBungee(sender, cmd, true); + } else { + send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + } + } else { + Cmd.console(cmd); + } + } + } + if (alias.consoleMessageEnable) { + for (String msg : alias.consoleMessages) { + send.console(Replace.replace(prefix, msg)); + } + } + } + + private static void subAliasConsole(SubAliasObject alias, CommandSender sender, String[] args) { + String targetSt = "[target]"; + try { + List results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList()); + targetSt = results.get(0).replace("-p:", ""); + } catch (Exception ignored) { + + } + if (alias.consoleCommandEnable) { + for (String cmd : alias.consoleCommands) { + if (alias.consoleBungeeCommand) { + if (SelectConfig.Bungee) { + BCommandSenderReciver.sendToBungee(sender, cmd.replace("[target]", targetSt), true); + } else { + send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + } + } else { + Cmd.console(cmd.replace("[target]", targetSt)); + } + } + } + if (alias.consoleMessageEnable) { + for (String msg : alias.consoleMessages) { + send.console(Replace.replace(prefix, msg)); + } + } + } + + private static void aliasAdminCommand(AliasObject alias, Player player, String[] args) { + String targetSt = "[target]"; + try { + List results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList()); + targetSt = results.get(0).replace("-p:", ""); + } catch (Exception ignored) { + + } + for (String cmd : alias.adminCommands) { + if (alias.adminBungeeCommand) { + if (SelectConfig.Bungee) { + BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.adminCommandAsConsole); + + } else { + send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + } + } else { + if (alias.adminCommandAsConsole) { + Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt)); + } else { + Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt)); + } + } + } + } + + private static void subAliasAdminCommand(SubAliasObject alias, Player player, String[] args) { + String targetSt = "[target]"; + try { + List results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList()); + targetSt = results.get(0).replace("-p:", ""); + } catch (Exception ignored) { + + } + for (String cmd : alias.adminCommands) { + if (alias.adminBungeeCommand) { + if (SelectConfig.Bungee) { + BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.adminCommandAsConsole); + + } else { + send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + } + } else { + if (alias.adminCommandAsConsole) { + Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt)); + } else { + Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt)); + } + } + } + } + + private static void aliasAdminMessage(AliasObject aliasObject, String alias, Player player, String[] args) { + String targetSt = "[target]"; + try { + List results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList()); + targetSt = results.get(0).replace("-p:", ""); + } catch (Exception ignored) { + + } + for (String msg : aliasObject.adminMessages) { + String text; + if (PluginCheck.papi()) { + text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias); + } else { + text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias); + } + send.player(player, text); + } + } + + private static void subAliasAdminMessage(SubAliasObject subAliasObject, String alias, Player player, String[] args) { + String targetSt = "[target]"; + try { + List results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList()); + targetSt = results.get(0).replace("-p:", ""); + } catch (Exception ignored) { + + } + for (String msg : subAliasObject.adminMessages) { + String text; + if (PluginCheck.papi()) { + text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias); + } else { + text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias); + } + send.player(player, text); + } + } + + private static void aliasCommand(AliasObject alias, Player player, String[] args) { + String targetSt = "[target]"; + try { + List results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList()); + targetSt = results.get(0).replace("-p:", ""); + } catch (Exception ignored) { + + } + for (String cmd : alias.command) { + if (alias.bungeeCommand) { + if (SelectConfig.Bungee) { + BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole); + + } else { + send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + } + } else { + if (alias.commandAsConsole) { + Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt)); + } else { + Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt)); + } + } + } + } + + private static void subAliasCommand(SubAliasObject alias, Player player, String[] args) { + String targetSt = "[target]"; + try { + List results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList()); + targetSt = results.get(0).replace("-p:", ""); + } catch (Exception ignored) { + + } + for (String cmd : alias.command) { + if (alias.bungeeCommand) { + if (SelectConfig.Bungee) { + BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole); + + } else { + send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + } + } else { + if (alias.commandAsConsole) { + Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt)); + } else { + Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt)); + } + } + } + } + + private static void aliasMessage(AliasObject aliasObject, String alias, Player player, String[] args) { + + String targetSt = "[target]"; + try { + List results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList()); + targetSt = results.get(0).replace("-p:", ""); + } catch (Exception ignored) { + + } + + for (String msg : aliasObject.messages) { + String text; + if (PluginCheck.papi()) { + text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias); + } else { + text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias); + } + send.player(player, text); + } + } + + private static void subAliasMessage(SubAliasObject subAliasObject, String alias, Player player, String[] args) { + String targetSt = "[target]"; + try { + List results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList()); + targetSt = results.get(0).replace("-p:", ""); + } catch (Exception ignored) { + + } + for (String msg : subAliasObject.messages) { + String text; + if (PluginCheck.papi()) { + text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias); + } else { + text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias); + } + send.player(player, text); + } + } + + private static String replacePlayer(String s, Player player) { + return s.replace("[player]", player.getName()); + } +} diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java index efbf5b1..65f0b03 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java @@ -1,23 +1,23 @@ package net.t2code.alias.Spigot.cmdManagement; -import net.md_5.bungee.api.chat.ClickEvent; import net.t2code.alias.Spigot.Main; -import net.t2code.alias.Spigot.config.config.SelectConfig; import net.t2code.alias.Spigot.config.languages.SelectMessages; -import net.t2code.alias.Spigot.objects.AliasObjekt; -import net.t2code.alias.Spigot.system.*; +import net.t2code.alias.Spigot.objects.AliasObject; +import net.t2code.alias.Spigot.objects.SubAliasObject; import net.t2code.alias.Util; -import net.t2code.lib.Spigot.Lib.commands.Cmd; -import net.t2code.lib.Spigot.Lib.eco.Eco; -import net.t2code.lib.Spigot.Lib.messages.TextBuilder; import net.t2code.lib.Spigot.Lib.messages.send; -import net.t2code.lib.Spigot.Lib.plugins.PluginCheck; -import net.t2code.lib.Spigot.Lib.replace.Replace; import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; -public class RegisterCommands extends Command { +import java.lang.reflect.Array; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class RegisterCommands extends Command implements TabCompleter { private String alias; private String prefix = Util.getPrefix(); @@ -28,173 +28,48 @@ public class RegisterCommands extends Command { @Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { - AliasObjekt alias = Main.aliasHashMap.get(this.alias); + AliasObject alias = Main.aliasHashMap.get(this.alias); + if (alias == null) { + send.error(Main.getPlugin(), "The alias " + this.alias + " does not exist."); + return false; + } if (!alias.aliasEnable) { send.sender(sender, SelectMessages.aliasDisabled); return true; } - if (sender instanceof Player) { - Player player = (Player) sender; - - if (alias.adminEnable) { - if (player.hasPermission(alias.adminPermission)) { - if (alias.adminCommandEnable) { - adminCommand(alias, player); - } - if (alias.adminMessageEnable) { - adminMessage(alias, player, prefix); - } - return true; - } - } - - if (alias.permNecessary) { - if (!(player.hasPermission("t2code.alias.use." + this.alias.toLowerCase()) || player.hasPermission("t2code.alias.admin"))) { - send.player(player, SelectMessages.noPermissionForCommand.replace("[cmd]", "/" + this.alias.toLowerCase()) - .replace("[perm]", "t2code.alias.use." + this.alias.toLowerCase())); - return true; - } - } - if (alias.costEnable) { - if (!(alias.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass")) ){ - if (!Eco.moneyRemove(prefix, player, alias.costPrice)) { - send.player(player, SelectMessages.noMoney); - return true; - } - if (SelectConfig.buyMessage) send.player(player, SelectMessages.buy.replace("[price]", alias.costPrice.toString())); - } - } - if (alias.commandEnable) { - command(alias, player); - } - if (alias.messageEnable) { - message(alias, player, prefix); + if (args.length == 0 || args.length == 1 && args[0].contains("-p:")) { + if (sender instanceof Player) { + ExecuteAlias.aliasPlayer(sender, alias, this.alias, args); + } else { + if (alias.consoleEnable) { + ExecuteAlias.aliasConsole(alias, sender, prefix); + } else send.sender(sender, SelectMessages.onlyForPlayer); } } else { - if (alias.consoleEnable) { - console(alias, sender, prefix); - } else send.sender(sender, SelectMessages.onlyForPlayer); + if (!Main.allForSubAliases.contains(this.alias)) { + return false; + } + for (String sals : Main.allSubAliases) { + SubAliasObject sal = Main.subAliasHashMap.get(sals); + if (args.length == sal.subAliasArg + 1) { + for (String al : sal.subAliasList) { + if (args[sal.subAliasArg].toLowerCase().equals(al)) { + ExecuteAlias.subAliasPlayer(sender, sal, al, args); + return true; + } + } + } + } + send.sender(sender, "TODO DEV'>Diesen Befehl gibt es nicht"); + //todo } return true; } - private static void adminCommand(AliasObjekt alias, Player player) { - for (String cmd : alias.adminCommands) { - if (alias.adminBungeeCommand) { - if (SelectConfig.Bungee) { - if (alias.adminCommandAsConsole) { - BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), true); - } else BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false); - - } else { - send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); - send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); - } - } else { - if (alias.adminCommandAsConsole) { - Cmd.console(cmd.replace("[player]", player.getName())); - } else { - Cmd.player(player, cmd.replace("[player]", player.getName())); - } - } - } - } - - private static void adminMessage(AliasObjekt alias, Player player, String prefix) { - for (String msg : alias.adminMessages) { - String text; - String hover; - if (PluginCheck.papi()) { - text = Replace.replace(prefix, player, replacePlayer(msg, player)); - hover = Replace.replace(prefix, player, alias.adminHover); - } else { - text = Replace.replace(prefix, replacePlayer(msg, player)); - hover = Replace.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); - } - player.spigot().sendMessage(textBuilder.build()); - } else { - send.player(player, text); - } - } - } - - private static void command(AliasObjekt alias, Player player) { - for (String cmd : alias.command) { - if (alias.bungeeCommand) { - if (SelectConfig.Bungee) { - if (alias.commandAsConsole) { - BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), true); - } else BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false); - - } else { - send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); - send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); - } - } else { - if (alias.commandAsConsole) { - Cmd.console(cmd.replace("[player]", player.getName())); - } else { - Cmd.player(player, cmd.replace("[player]", player.getName())); - } - } - } - } - - private static void message(AliasObjekt alias, Player player, String prefix) { - for (String msg : alias.messages) { - String text; - String hover; - if (PluginCheck.papi()) { - text = Replace.replace(prefix, player, replacePlayer(msg, player)); - hover = Replace.replace(prefix, player, alias.hover); - } else { - text = Replace.replace(prefix, replacePlayer(msg, player)); - hover = Replace.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); - } - player.spigot().sendMessage(textBuilder.build()); - } else { - send.player(player, text); - } - } - } - - private static void console(AliasObjekt alias, CommandSender sender, String prefix) { - if (alias.consoleCommandEnable) { - for (String cmd : alias.consoleCommands) { - if (alias.consoleBungeeCommand) { - if (SelectConfig.Bungee) { - BCommandSenderReciver.sendToBungee(sender, cmd, true); - } else { - send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); - send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); - } - } else { - Cmd.console(cmd); - } - } - } - if (alias.consoleMessageEnable) { - for (String msg : alias.consoleMessages) { - send.console(Replace.replace(prefix, msg)); - } - } - } - - private static String replacePlayer(String s, Player player) { - return s.replace("[player]", player.getName()); + @Override + public List onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) { + return Collections.singletonList("hallodepp"); } } diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/TabEvent.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/TabEvent.java new file mode 100644 index 0000000..1fa238a --- /dev/null +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/TabEvent.java @@ -0,0 +1,49 @@ +package net.t2code.alias.Spigot.cmdManagement; + +import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Spigot.objects.SubAliasObject; +import net.t2code.lib.Spigot.Lib.commands.Tab; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.server.TabCompleteEvent; +import org.bukkit.plugin.Plugin; + +import java.util.*; + +public class TabEvent implements Listener { + private static HashMap arg1 = new HashMap(); + + @EventHandler + public void onTab(TabCompleteEvent e) { + String buffer = e.getBuffer(); + String[] imp = buffer.replace("/", "").split(" "); + List list = new ArrayList<>(Collections.emptyList()); + if (!Main.allAliases.contains(imp[0]) || !Main.allForSubAliases.contains(imp[0])){ + e.setCompletions(list); + return; + } + arg1.clear(); + + for (String sals : Main.allSubAliases) { + SubAliasObject aliasObject = Main.subAliasHashMap.get(sals); + if (!buffer.contains(aliasObject.subAliasFor)) continue; + + String[] im = aliasObject.subAliasFor.split(" "); + String input = buffer.replace("/" + im[0] + " ", ""); + String[] args = input.split(" ", -1); + + for (String al : aliasObject.subAliasList) { + arg1.put(al, aliasObject.permission.replace("", al.toLowerCase())); + } + int arg = aliasObject.subAliasArg; + if (args.length - 1 == arg) { + for (String command : aliasObject.subAliasList) { + if (Tab.hasPermission(e.getSender(), arg1.get(command)) && Tab.passend(command, args[arg])) { + list.add(command); + } + } + } + } + e.setCompletions(list); + } +} diff --git a/src/main/java/net/t2code/alias/Spigot/config/alias/AliasConfigConverter.java b/src/main/java/net/t2code/alias/Spigot/config/alias/AliasConfigConverter.java new file mode 100644 index 0000000..2056e2c --- /dev/null +++ b/src/main/java/net/t2code/alias/Spigot/config/alias/AliasConfigConverter.java @@ -0,0 +1,58 @@ +package net.t2code.alias.Spigot.config.alias; + +import net.t2code.alias.Spigot.Main; +import net.t2code.lib.Spigot.Lib.messages.send; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.Collections; + +public class AliasConfigConverter { + /** + * Converter 1.1 + * + * @param yamlConfiguration + * @param config_gui + */ + + public static void convertAliasList(YamlConfiguration yamlConfiguration, File config_gui) { + yamlConfiguration.set("Alias.AliasList", Collections.singletonList(config_gui.getName().replace(".yml", ""))); + try { + yamlConfiguration.save(config_gui); + } catch (IOException e) { + e.printStackTrace(); + } + + send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + send.error(Main.getPlugin(), ""); + send.warning(Main.getPlugin(), "The " + config_gui.getName() + " file is converted to the new config format."); + send.warning(Main.getPlugin(), "The alias is no longer the filename, this is now adjustable in the file under 'Alias.AliasList'!"); + send.warning(Main.getPlugin(), "This allows a function to have multiple alias commands without creating multiple files!"); + send.error(Main.getPlugin(), ""); + send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + + } + + public static void convertAddPermission(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) { + if (subalias) { + yamlConfiguration.set("SubAlias.Permission.Permission", "t2code.alias.use.subalias."); + } else yamlConfiguration.set("Alias.Permission.Permission", "t2code.alias.use."); + try { + yamlConfiguration.save(config_gui); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static void convertAddPermissionMSG(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) { + if (subalias) { + yamlConfiguration.set("SubAlias.Permission.CustomNoPermissionMSG", ""); + } else yamlConfiguration.set("Alias.Permission.CustomNoPermissionMSG", ""); + try { + yamlConfiguration.save(config_gui); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java b/src/main/java/net/t2code/alias/Spigot/config/alias/CreateExampleAliasConfig.java similarity index 75% rename from src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java rename to src/main/java/net/t2code/alias/Spigot/config/alias/CreateExampleAliasConfig.java index b66f198..8d12614 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java +++ b/src/main/java/net/t2code/alias/Spigot/config/alias/CreateExampleAliasConfig.java @@ -1,4 +1,4 @@ -package net.t2code.alias.Spigot.config.config; +package net.t2code.alias.Spigot.config.alias; import net.t2code.alias.Spigot.Main; import net.t2code.alias.Util; @@ -8,6 +8,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; +import java.util.Arrays; import java.util.Collections; public class CreateExampleAliasConfig { @@ -20,7 +21,11 @@ public class CreateExampleAliasConfig { YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); Config.set("Alias.Enable", true, yamlConfiguration); + Config.set("Alias.AliasList", Arrays.asList("aliasexample1"),yamlConfiguration); + Config.set("Alias.Permission.Necessary", true, yamlConfiguration); + Config.set("Alias.Permission.Permission", "t2code.alias.use.", yamlConfiguration); + Config.set("Alias.Permission.CustomNoPermissionMSG", "", yamlConfiguration); Config.set("Alias.Cost.Enable", false,yamlConfiguration); Config.set("Alias.Cost.Price", 0.0,yamlConfiguration); @@ -33,11 +38,6 @@ public class CreateExampleAliasConfig { Config.set("Alias.Message.Enable", false, yamlConfiguration); Config.set("Alias.Message.Messages", Collections.emptyList(), yamlConfiguration); - Config.set("Alias.Message.TextBuilder.Enable", false, yamlConfiguration); - Config.set("Alias.Message.TextBuilder.Hover", "", yamlConfiguration); - Config.set("Alias.Message.TextBuilder.ClickEvent.Enable", false, yamlConfiguration); - Config.set("Alias.Message.TextBuilder.ClickEvent.Action", "", yamlConfiguration); - Config.set("Alias.Message.TextBuilder.ClickEvent.ActionValue", "", yamlConfiguration); Config.set("Alias.Admin.Enable", true, yamlConfiguration); Config.set("Alias.Admin.Permission", "t2code.alias.admin", yamlConfiguration); @@ -49,11 +49,6 @@ public class CreateExampleAliasConfig { Config.set("Alias.Admin.Message.Enable", false, yamlConfiguration); Config.set("Alias.Admin.Message.Messages", Collections.emptyList(), yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.Enable", false, yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.Hover", "", yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.ClickEvent.Enable", false, yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.ClickEvent.Action", "", yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.ClickEvent.ActionValue", "", yamlConfiguration); Config.set("Alias.Console.Enable", false, yamlConfiguration); Config.set("Alias.Console.Command.Enable", false, yamlConfiguration); diff --git a/src/main/java/net/t2code/alias/Spigot/config/alias/SelectAlias.java b/src/main/java/net/t2code/alias/Spigot/config/alias/SelectAlias.java new file mode 100644 index 0000000..0ecaa61 --- /dev/null +++ b/src/main/java/net/t2code/alias/Spigot/config/alias/SelectAlias.java @@ -0,0 +1,111 @@ +package net.t2code.alias.Spigot.config.alias; + +import com.google.common.base.Preconditions; +import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Spigot.config.config.SelectConfig; +import net.t2code.alias.Spigot.system.AliasRegister; +import net.t2code.alias.Spigot.objects.AliasObject; +import net.t2code.alias.Util; +import net.t2code.lib.Spigot.Lib.messages.send; +import org.bukkit.Bukkit; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; +import java.util.logging.Level; + +public class SelectAlias { + private static String Prefix = Util.getPrefix(); + + public static void onSelect() { + + Main.aliasHashMap.clear(); + Main.allAliases.clear(); + File f = new File(Main.getPath() + "/Alias/"); + File[] fileArray = f.listFiles(); + for (File config_gui : fileArray) { + if (config_gui.getName().equals("X_aliasDeclaration_X.yml")) continue; + + String sub = config_gui.getName().substring(config_gui.getName().length() - 4); + if (sub.equals(".yml")) { + YamlConfiguration yamlConfiguration; + try { + Preconditions.checkArgument(config_gui != null, "File cannot be null"); + YamlConfiguration config = new YamlConfiguration(); + config.load(config_gui); + yamlConfiguration = config; + } catch (FileNotFoundException var3) { + continue; + } catch (IOException var4) { + Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + config_gui, var4); + continue; + } catch (InvalidConfigurationException var5) { + Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + config_gui, var5); + continue; + } + Boolean aliasEnable = yamlConfiguration.getBoolean("Alias.Enable"); + List aliasList; + if (yamlConfiguration.get("Alias.AliasList") == null) { + AliasConfigConverter.convertAliasList(yamlConfiguration, config_gui); + } + aliasList = yamlConfiguration.getStringList("Alias.AliasList"); + Boolean permNecessary = yamlConfiguration.getBoolean("Alias.Permission.Necessary"); + if (yamlConfiguration.get("Alias.Permission.Permission") == null) { + AliasConfigConverter.convertAddPermission(yamlConfiguration, config_gui, false); + } + String permission = yamlConfiguration.getString("Alias.Permission.Permission"); + if (yamlConfiguration.get("Alias.Permission.CustomNoPermissionMSG") == null) { + AliasConfigConverter.convertAddPermissionMSG(yamlConfiguration, config_gui, false); + } + String permissionMSG = yamlConfiguration.getString("Alias.Permission.CustomNoPermissionMSG"); + + Boolean costEnable = yamlConfiguration.getBoolean("Alias.Cost.Enable"); + Double costPrice = yamlConfiguration.getDouble("Alias.Cost.Price"); + Boolean costAllowBypass = yamlConfiguration.getBoolean("Alias.Cost.AllowByPass"); + + Boolean commandEnable = yamlConfiguration.getBoolean("Alias.Command.Enable"); + Boolean commandAsConsole = yamlConfiguration.getBoolean("Alias.Command.CommandAsConsole"); + Boolean bungeeCommand = yamlConfiguration.getBoolean("Alias.Command.BungeeCommand"); + List command = yamlConfiguration.getStringList("Alias.Command.Commands"); + + Boolean messageEnable = yamlConfiguration.getBoolean("Alias.Message.Enable"); + List messages = yamlConfiguration.getStringList("Alias.Message.Messages"); + + Boolean adminEnable = yamlConfiguration.getBoolean("Alias.Admin.Enable"); + String adminPermission = yamlConfiguration.getString("Alias.Admin.Permission"); + + Boolean adminCommandEnable = yamlConfiguration.getBoolean("Alias.Admin.Command.Enable"); + Boolean adminCommandAsConsole = yamlConfiguration.getBoolean("Alias.Admin.Command.CommandAsConsole"); + Boolean adminBungeeCommand = yamlConfiguration.getBoolean("Alias.Admin.Command.BungeeCommand"); + List adminCommands = yamlConfiguration.getStringList("Alias.Admin.Command.Commands"); + + Boolean adminMessageEnable = yamlConfiguration.getBoolean("Alias.Admin.Message.Enable"); + List adminMessages = yamlConfiguration.getStringList("Alias.Admin.Message.Messages"); + + Boolean consoleEnable = yamlConfiguration.getBoolean("Alias.Console.Enable"); + Boolean consoleCommandEnable = yamlConfiguration.getBoolean("Alias.Console.Command.Enable"); + Boolean consoleBungeeCommand = yamlConfiguration.getBoolean("Alias.Console.Command.BungeeCommand"); + List consoleCommands = yamlConfiguration.getStringList("Alias.Console.Command.Commands"); + Boolean consoleMessageEnable = yamlConfiguration.getBoolean("Alias.Console.Message.Enable"); + List consoleMessages = yamlConfiguration.getStringList("Alias.Console.Message.Messages"); + + Main.allAliases.addAll(aliasList); + AliasObject alias = new AliasObject(aliasEnable, aliasList, permNecessary, permission, permissionMSG, costEnable, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand, + command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands, + adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages); + for (String al : aliasList) { + Main.aliasHashMap.put(al, alias); + } + } + send.console(Prefix + " §aAlias file §e" + config_gui.getName() + " §awas loaded"); + } + AliasRegister.onRegister(); + } + + private YamlConfiguration loadFile(File file) throws InvalidConfigurationException { + return YamlConfiguration.loadConfiguration(file); + } +} diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/CreateConfig.java b/src/main/java/net/t2code/alias/Spigot/config/config/CreateConfig.java index 7df2ead..c8f0c07 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/CreateConfig.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/CreateConfig.java @@ -10,25 +10,24 @@ import java.io.File; import java.io.IOException; public class CreateConfig { - public static Integer ConfigVersion = 2; + public static void configCreate() { long long_ = System.currentTimeMillis(); if (new File(Main.getPath(), "config.yml").exists()) { - if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated..."); + if (Main.getPlugin().getConfig().getBoolean("Plugin.Debug")) send.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated..."); } else send.console(Util.getPrefix() + " §4config.yml are created..."); File config = new File(Main.getPath(), "config.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - yamlConfiguration.set("ConfigVersion", ConfigVersion); - Config.set("Plugin.language", "english", yamlConfiguration); Config.set("BungeeCord.Enable", false, yamlConfiguration); Config.set("BungeeCord.ThisServer", "server", yamlConfiguration); Config.set("Buy.Message", true, yamlConfiguration); + Config.set("SubAlias.TabComplete", true, yamlConfiguration); try { yamlConfiguration.save(config); diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/SelectAlias.java b/src/main/java/net/t2code/alias/Spigot/config/config/SelectAlias.java deleted file mode 100644 index c731365..0000000 --- a/src/main/java/net/t2code/alias/Spigot/config/config/SelectAlias.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.t2code.alias.Spigot.config.config; - -import net.minecraft.world.level.levelgen.DensityFunctions; -import net.t2code.alias.Spigot.Main; -import net.t2code.alias.Spigot.system.AliasRegister; -import net.t2code.alias.Spigot.objects.AliasObjekt; -import net.t2code.alias.Util; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; - -public class SelectAlias { - private static String Prefix = Util.getPrefix(); - public static void onSelect() { - - Main.aliasHashMap.clear(); - Main.allAliases.clear(); - File f = new File(Main.getPath() + "/Alias/"); - File[] fileArray = f.listFiles(); - for (File config_gui : fileArray) { - if (config_gui.getName().equals("X_aliasDeclaration_X.yml")) continue; - String sub = config_gui.getName().substring(config_gui.getName().length() - 4); - if (sub.equals(".yml")) { - Main.allAliases.add(config_gui.getName().replace(".yml", "")); - YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config_gui); - - AliasObjekt alias = new AliasObjekt( - yamlConfiguration.getBoolean("Alias.Enable"), - yamlConfiguration.getBoolean("Alias.Permission.Necessary"), - - yamlConfiguration.getBoolean("Alias.Cost.Enable"), - yamlConfiguration.getDouble("Alias.Cost.Price"), - yamlConfiguration.getBoolean("Alias.Cost.AllowByPass"), - - yamlConfiguration.getBoolean("Alias.Command.Enable"), - yamlConfiguration.getBoolean("Alias.Command.CommandAsConsole"), - yamlConfiguration.getBoolean("Alias.Command.BungeeCommand"), - yamlConfiguration.getStringList("Alias.Command.Commands"), - - yamlConfiguration.getBoolean("Alias.Message.Enable"), - yamlConfiguration.getStringList("Alias.Message.Messages"), - yamlConfiguration.getBoolean("Alias.Message.TextBuilder.Enable"), - yamlConfiguration.getString("Alias.Message.TextBuilder.Hover"), - yamlConfiguration.getBoolean("Alias.Message.TextBuilder.ClickEvent.Enable"), - yamlConfiguration.getString("Alias.Message.TextBuilder.ClickEvent.Action"), - yamlConfiguration.getString("Alias.Message.TextBuilder.ClickEvent.ActionValue"), - - yamlConfiguration.getBoolean("Alias.Admin.Enable"), - yamlConfiguration.getString("Alias.Admin.Permission"), - - yamlConfiguration.getBoolean("Alias.Admin.Command.Enable"), - yamlConfiguration.getBoolean("Alias.Admin.Command.CommandAsConsole"), - yamlConfiguration.getBoolean("Alias.Admin.Command.BungeeCommand"), - yamlConfiguration.getStringList("Alias.Admin.Command.Commands"), - - yamlConfiguration.getBoolean("Alias.Admin.Message.Enable"), - yamlConfiguration.getStringList("Alias.Admin.Message.Messages"), - yamlConfiguration.getBoolean("Alias.Admin.Message.TextBuilder.Enable"), - yamlConfiguration.getString("Alias.Admin.Message.TextBuilder.Hover"), - yamlConfiguration.getBoolean("Alias.Admin.Message.TextBuilder.ClickEvent.Enable"), - yamlConfiguration.getString("Alias.Admin.Message.TextBuilder.ClickEvent.Action"), - yamlConfiguration.getString("Alias.Admin.Message.TextBuilder.ClickEvent.ActionValue"), - - yamlConfiguration.getBoolean("Alias.Console.Enable"), - yamlConfiguration.getBoolean("Alias.Console.Command.Enable"), - yamlConfiguration.getBoolean("Alias.Console.Command.BungeeCommand"), - yamlConfiguration.getStringList("Alias.Console.Command.Commands"), - yamlConfiguration.getBoolean("Alias.Console.Message.Enable"), - yamlConfiguration.getStringList("Alias.Console.Message.Messages")); - Main.aliasHashMap.put(config_gui.getName().replace(".yml", ""), alias); - AliasRegister.onRegister(); - } - } - } -} diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/SelectConfig.java b/src/main/java/net/t2code/alias/Spigot/config/config/SelectConfig.java index 1ddfef5..9acdbc6 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/SelectConfig.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/SelectConfig.java @@ -4,20 +4,24 @@ import net.t2code.alias.Spigot.Main; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; +import java.io.IOException; public class SelectConfig { - public static Integer ConfigVersion; + private static Integer ConfigVersion = 3; + public static Integer isConfigVersion; public static Boolean UpdateCheckOnJoin; public static String language; public static Boolean Bungee; public static String thisServer; public static Boolean buyMessage; + public static Boolean subAliasTab; + public static void onSelect() { File config = new File(Main.getPath(), "config.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - ConfigVersion =yamlConfiguration.getInt("ConfigVersion"); + isConfigVersion = yamlConfiguration.getInt("ConfigVersion"); UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin"); language = yamlConfiguration.getString("Plugin.language"); @@ -25,5 +29,16 @@ public class SelectConfig { thisServer = yamlConfiguration.getString("BungeeCord.ThisServer"); buyMessage = yamlConfiguration.getBoolean("Buy.Message"); + subAliasTab = yamlConfiguration.getBoolean("SubAlias.TabComplete"); + } + public static void setConfigVersion() { + File config = new File(Main.getPath(), "config.yml"); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + yamlConfiguration.set("ConfigVersion", ConfigVersion); + try { + yamlConfiguration.save(config); + } catch (IOException e) { + e.printStackTrace(); + } } } diff --git a/src/main/java/net/t2code/alias/Spigot/config/languages/LanguagesCreate.java b/src/main/java/net/t2code/alias/Spigot/config/languages/LanguagesCreate.java index b00d101..2a17351 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/languages/LanguagesCreate.java +++ b/src/main/java/net/t2code/alias/Spigot/config/languages/LanguagesCreate.java @@ -11,10 +11,9 @@ import java.io.File; import java.io.IOException; public class LanguagesCreate { - private static Plugin plugin = Main.plugin; public static void langCreate() { - send.debug(plugin,"§4Language files are created / updated..."); + send.debug(Main.getPlugin(),"§4Language files are created / updated..."); long long_ = System.currentTimeMillis(); /** @@ -38,7 +37,7 @@ public class LanguagesCreate { try { yamlConfigurationEN.save(messagesEN); } catch (IOException e) { - send.warning(plugin,e.getMessage()); + send.warning(Main.getPlugin(),e.getMessage()); e.printStackTrace(); } @@ -64,7 +63,7 @@ public class LanguagesCreate { try { yamlConfigurationDE.save(messagesDE); } catch (IOException e) { - send.warning(plugin,e.getMessage()); + send.warning(Main.getPlugin(),e.getMessage()); e.printStackTrace(); } diff --git a/src/main/java/net/t2code/alias/Spigot/config/languages/MSG.java b/src/main/java/net/t2code/alias/Spigot/config/languages/MSG.java index 5e838fc..4f53d5d 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/languages/MSG.java +++ b/src/main/java/net/t2code/alias/Spigot/config/languages/MSG.java @@ -15,30 +15,30 @@ public class MSG { // EN - public static String EN_OnlyForPlayer = "[prefix] &cThis command is for players only!"; + public static String EN_OnlyForPlayer = "[prefix] This command is for players only!"; public static String EN_Disabled = "Unknown command. Type ''/help'' for help."; - public static String EN_ReloadStart = "[prefix] &6Plugin is reloaded..."; - public static String EN_ReloadEnd = "[prefix] &2Plugin was successfully reloaded."; + public static String EN_ReloadStart = "[prefix] Plugin is reloaded..."; + public static String EN_ReloadEnd = "[prefix] Plugin was successfully reloaded."; - public static String EN_NoPermissionForCommand = "[prefix] &cFor &b[cmd] &cyou lack the permission &6[perm]&c!"; + public static String EN_NoPermissionForCommand = "[prefix] For [cmd] you lack the permission [perm]!"; - public static String EN_Buy = "[prefix] &2You have paid &6[price] &2for this command.&2."; - public static String EN_NoMoney = "[prefix] &cYou don't have enough money for this command!"; + public static String EN_Buy = "[prefix] You have paid [price] for this command."; + public static String EN_NoMoney = "[prefix] You don't have enough money for this command!"; // DE - public static String DE_OnlyForPlayer = "[prefix] &cDieser Command ist nur f[ue]r Spieler!"; + public static String DE_OnlyForPlayer = "[prefix] Dieser Command ist nur f[ue]r Spieler!"; public static String DE_Disabled = "Unknown command. Type ''/help'' for help."; - public static String DE_ReloadStart = "[prefix] &6Plugin wird neu geladen..."; - public static String DE_ReloadEnd = "[prefix] &2Plugin wurde erfolgreich neu geladen."; + public static String DE_ReloadStart = "[prefix] Plugin wird neu geladen..."; + public static String DE_ReloadEnd = "[prefix] Plugin wurde erfolgreich neu geladen."; - public static String DE_NoPermissionForCommand = "[prefix] &cF[ue]r &b[cmd] &cfehlt dir die Permission &6[perm]&c!"; + public static String DE_NoPermissionForCommand = "[prefix] F[ue]r [cmd] fehlt dir die Permission [perm]!"; - public static String DE_Buy = "[prefix] &2Du hast f[ue]r diesen Command &6[price] &2bezahlt."; - public static String DE_NoMoney = "[prefix] &cDu hast nicht gen[ue]gend Geld für diesen Command!"; + public static String DE_Buy = "[prefix] Du hast f[ue]r diesen Command [price] bezahlt."; + public static String DE_NoMoney = "[prefix] Du hast nicht gen[ue]gend Geld für diesen Command!"; } diff --git a/src/main/java/net/t2code/alias/Spigot/config/languages/SelectMessages.java b/src/main/java/net/t2code/alias/Spigot/config/languages/SelectMessages.java index 2cdace1..837a7da 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/languages/SelectMessages.java +++ b/src/main/java/net/t2code/alias/Spigot/config/languages/SelectMessages.java @@ -26,8 +26,8 @@ public class SelectMessages { public static void onSelect(String Prefix) { - send.debug(Main.plugin, "§4Select language..."); - Long long_ = Long.valueOf(System.currentTimeMillis()); + send.debug(Main.getPlugin(), "§4Select language..."); + long long_ = System.currentTimeMillis(); File msg; @@ -44,6 +44,9 @@ public class SelectMessages { } else selectMSG = SelectConfig.language; YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(msg); + if (yamlConfiguration.get("Plugin.Prefix") != null) { + Util.setPrefix(replace(yamlConfiguration.getString("Plugin.Prefix"))); + } onlyForPlayer = replace(yamlConfiguration.getString("Plugin.OnlyForPlayer")); aliasDisabled = replace(yamlConfiguration.getString("Plugin.AliasDisabled")); reloadStart = replace(yamlConfiguration.getString("Plugin.Reload.Start")); @@ -52,7 +55,7 @@ public class SelectMessages { buy = replace(yamlConfiguration.getString("Cost.Buy")); noMoney = replace(yamlConfiguration.getString("Cost.NoMoney")); - send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } private static String replace(String text) { diff --git a/src/main/java/net/t2code/alias/Spigot/config/subAlias/CreateExampleSubAliasConfig.java b/src/main/java/net/t2code/alias/Spigot/config/subAlias/CreateExampleSubAliasConfig.java new file mode 100644 index 0000000..563932d --- /dev/null +++ b/src/main/java/net/t2code/alias/Spigot/config/subAlias/CreateExampleSubAliasConfig.java @@ -0,0 +1,67 @@ +package net.t2code.alias.Spigot.config.subAlias; + +import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Util; +import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; + +public class CreateExampleSubAliasConfig { + + public static void configCreate() { + long long_ = System.currentTimeMillis(); + send.console(Util.getPrefix() + " §4SubAlias/aliasexample.yml are created..."); + + File config = new File(Main.getPath(), "SubAlias/aliasexample.yml"); + YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); + + Config.set("SubAlias.Enable", true, yamlConfiguration); + Config.set("SubAlias.SubAliasList", Arrays.asList("test"),yamlConfiguration); + Config.set("SubAlias.SubAliasFor", "aliasexample1",yamlConfiguration); + + Config.set("SubAlias.Permission.Necessary", true, yamlConfiguration); + Config.set("SubAlias.Permission.Permission", "t2code.alias.use.subalias.", yamlConfiguration); + Config.set("SubAlias.Permission.CustomNoPermissionMSG", "", yamlConfiguration); + + Config.set("SubAlias.Cost.Enable", false,yamlConfiguration); + Config.set("SubAlias.Cost.Price", 0.0,yamlConfiguration); + Config.set("SubAlias.Cost.AllowByPass", true,yamlConfiguration); + + Config.set("SubAlias.Command.Enable", true, yamlConfiguration); + Config.set("SubAlias.Command.CommandAsConsole", true, yamlConfiguration); + Config.set("SubAlias.Command.BungeeCommand", false, yamlConfiguration); + Config.set("SubAlias.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration); + + Config.set("SubAlias.Message.Enable", false, yamlConfiguration); + Config.set("SubAlias.Message.Messages", Collections.emptyList(), yamlConfiguration); + + Config.set("SubAlias.Admin.Enable", true, yamlConfiguration); + Config.set("SubAlias.Admin.Permission", "t2code.alias.admin", yamlConfiguration); + + Config.set("SubAlias.Admin.Command.Enable", true, yamlConfiguration); + Config.set("SubAlias.Admin.Command.CommandAsConsole", true, yamlConfiguration); + Config.set("SubAlias.Admin.Command.BungeeCommand", false, yamlConfiguration); + Config.set("SubAlias.Admin.Command.Commands", Collections.singletonList("say subalias hi"), yamlConfiguration); + + Config.set("SubAlias.Admin.Message.Enable", false, yamlConfiguration); + Config.set("SubAlias.Admin.Message.Messages", Collections.emptyList(), yamlConfiguration); + + Config.set("SubAlias.Console.Enable", false, yamlConfiguration); + Config.set("SubAlias.Console.Command.Enable", false, yamlConfiguration); + Config.set("SubAlias.Console.Command.BungeeCommand", false, yamlConfiguration); + Config.set("SubAlias.Console.Command.Commands", Collections.emptyList(), yamlConfiguration); + Config.set("SubAlias.Console.Message.Enable", false, yamlConfiguration); + Config.set("SubAlias.Console.Message.Messages", Collections.emptyList(), yamlConfiguration); + try { + yamlConfiguration.save(config); + } catch (IOException e) { + e.printStackTrace(); + } + send.console(Util.getPrefix() + " §2Alias/aliasexample.yml were successfully created." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + } +} diff --git a/src/main/java/net/t2code/alias/Spigot/config/subAlias/SelectSubAlias.java b/src/main/java/net/t2code/alias/Spigot/config/subAlias/SelectSubAlias.java new file mode 100644 index 0000000..23ab045 --- /dev/null +++ b/src/main/java/net/t2code/alias/Spigot/config/subAlias/SelectSubAlias.java @@ -0,0 +1,111 @@ +package net.t2code.alias.Spigot.config.subAlias; + +import com.google.common.base.Preconditions; +import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Spigot.config.alias.AliasConfigConverter; +import net.t2code.alias.Spigot.objects.SubAliasObject; +import net.t2code.alias.Util; +import net.t2code.lib.Spigot.Lib.messages.send; +import org.bukkit.Bukkit; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; +import java.util.logging.Level; + +public class SelectSubAlias { + private static String Prefix = Util.getPrefix(); + + public static void onSelect() { + + Main.subAliasHashMap.clear(); + Main.allSubAliases.clear(); + File f = new File(Main.getPath() + "/SubAlias/"); + File[] fileArray = f.listFiles(); + for (File config_gui : fileArray) { + if (config_gui.getName().equals("X_subAliasDeclaration_X.yml")) continue; + String sub = config_gui.getName().substring(config_gui.getName().length() - 4); + if (sub.equals(".yml")) { + YamlConfiguration yamlConfiguration; + try { + Preconditions.checkArgument(config_gui != null, "File cannot be null"); + YamlConfiguration config = new YamlConfiguration(); + config.load(config_gui); + yamlConfiguration = config; + } catch (FileNotFoundException var3) { + continue; + } catch (IOException var4) { + Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + config_gui, var4); + continue; + } catch (InvalidConfigurationException var5) { + Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + config_gui, var5); + continue; + } + Boolean aliasEnable = yamlConfiguration.getBoolean("SubAlias.Enable"); + List subAliasList = yamlConfiguration.getStringList("SubAlias.SubAliasList"); + String subAliasFor = yamlConfiguration.getString("SubAlias.SubAliasFor"); + int subAliasArg = 0; + if (subAliasFor != null) { + String[] imp = subAliasFor.split(" "); + if (!Main.allAliases.contains(imp[0])) { + send.error(Main.getPlugin(), "Den Alias " + imp[0] + " in der Datei " + config_gui.getName() + " existiert nicht!"); + } + String[] args = subAliasFor.split(" "); + subAliasArg = args.length - 1; + } + Boolean permNecessary = yamlConfiguration.getBoolean("SubAlias.Permission.Necessary"); + if (yamlConfiguration.get("SubAlias.Permission.Permission") == null) { + AliasConfigConverter.convertAddPermission(yamlConfiguration, config_gui, true); + } + String permission = yamlConfiguration.getString("SubAlias.Permission.Permission"); + if (yamlConfiguration.get("SubAlias.Permission.CustomNoPermissionMSG") == null) { + AliasConfigConverter.convertAddPermissionMSG(yamlConfiguration, config_gui, true); + } + String permissionMSG = yamlConfiguration.getString("SubAlias.Permission.CustomNoPermissionMSG"); + + Boolean costEnable = yamlConfiguration.getBoolean("SubAlias.Cost.Enable"); + Double costPrice = yamlConfiguration.getDouble("SubAlias.Cost.Price"); + Boolean costAllowBypass = yamlConfiguration.getBoolean("SubAlias.Cost.AllowByPass"); + + Boolean commandEnable = yamlConfiguration.getBoolean("SubAlias.Command.Enable"); + Boolean commandAsConsole = yamlConfiguration.getBoolean("SubAlias.Command.CommandAsConsole"); + Boolean bungeeCommand = yamlConfiguration.getBoolean("SubAlias.Command.BungeeCommand"); + List command = yamlConfiguration.getStringList("SubAlias.Command.Commands"); + + Boolean messageEnable = yamlConfiguration.getBoolean("SubAlias.Message.Enable"); + List messages = yamlConfiguration.getStringList("SubAlias.Message.Messages"); + + Boolean adminEnable = yamlConfiguration.getBoolean("SubAlias.Admin.Enable"); + String adminPermission = yamlConfiguration.getString("SubAlias.Admin.Permission"); + + Boolean adminCommandEnable = yamlConfiguration.getBoolean("SubAlias.Admin.Command.Enable"); + Boolean adminCommandAsConsole = yamlConfiguration.getBoolean("SubAlias.Admin.Command.CommandAsConsole"); + Boolean adminBungeeCommand = yamlConfiguration.getBoolean("SubAlias.Admin.Command.BungeeCommand"); + List adminCommands = yamlConfiguration.getStringList("SubAlias.Admin.Command.Commands"); + + Boolean adminMessageEnable = yamlConfiguration.getBoolean("SubAlias.Admin.Message.Enable"); + List adminMessages = yamlConfiguration.getStringList("SubAlias.Admin.Message.Messages"); + + Boolean consoleEnable = yamlConfiguration.getBoolean("SubAlias.Console.Enable"); + Boolean consoleCommandEnable = yamlConfiguration.getBoolean("SubAlias.Console.Command.Enable"); + Boolean consoleBungeeCommand = yamlConfiguration.getBoolean("SubAlias.Console.Command.BungeeCommand"); + List consoleCommands = yamlConfiguration.getStringList("SubAlias.Console.Command.Commands"); + Boolean consoleMessageEnable = yamlConfiguration.getBoolean("SubAlias.Console.Message.Enable"); + List consoleMessages = yamlConfiguration.getStringList("SubAlias.Console.Message.Messages"); + + SubAliasObject subAlias = new SubAliasObject(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, permission, permissionMSG, costEnable, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand, + command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands, + adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages); + for (String sal : subAliasList) { + Main.subAliasHashMap.put(sal, subAlias); + } + Main.allSubAliases.addAll(subAliasList); + Main.allForSubAliases.add(subAliasFor); + send.console(Prefix + " §aSubAlias file §e" + config_gui.getName() + " §awas loaded"); + } + } + } +} diff --git a/src/main/java/net/t2code/alias/Spigot/objects/AliasObjekt.java b/src/main/java/net/t2code/alias/Spigot/objects/AliasObject.java similarity index 73% rename from src/main/java/net/t2code/alias/Spigot/objects/AliasObjekt.java rename to src/main/java/net/t2code/alias/Spigot/objects/AliasObject.java index a6d149f..6ab3eab 100644 --- a/src/main/java/net/t2code/alias/Spigot/objects/AliasObjekt.java +++ b/src/main/java/net/t2code/alias/Spigot/objects/AliasObject.java @@ -2,25 +2,25 @@ package net.t2code.alias.Spigot.objects; import java.util.List; -public class AliasObjekt { +public class AliasObject { public Boolean aliasEnable; - public Boolean commandEnable; + public List aliasList; + public Boolean permNecessary; + public String permission; + public String permissionMSG; public Boolean costEnable; public Double costPrice; public Boolean costAllowBypass; + public Boolean commandEnable; public Boolean commandAsConsole; public Boolean bungeeCommand; 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; @@ -30,11 +30,6 @@ public class AliasObjekt { 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 Boolean consoleBungeeCommand; @@ -42,8 +37,11 @@ public class AliasObjekt { public Boolean consoleMessageEnable; public List consoleMessages; - public AliasObjekt(Boolean aliasEnable, + public AliasObject(Boolean aliasEnable, + List aliasList, Boolean permNecessary, + String permission, + String permissionMSG, Boolean costEnable, Double costPrice, @@ -55,11 +53,6 @@ public class AliasObjekt { List command, Boolean messageEnable, List messages, - Boolean textBuilder, - String hover, - Boolean clickEvent, - String action, - String actionValue, Boolean adminEnable, String adminPermission, @@ -69,11 +62,6 @@ public class AliasObjekt { List adminCommands, Boolean adminMessageEnable, List adminMessages, - Boolean adminTextBuilder, - String adminHover, - Boolean adminClickEvent, - String adminAction, - String adminActionValue, Boolean consoleEnable, Boolean consoleCommandEnable, @@ -82,7 +70,10 @@ public class AliasObjekt { Boolean consoleMessageEnable, List consoleMessages) { this.aliasEnable = aliasEnable; + this.aliasList = aliasList; this.permNecessary = permNecessary; + this.permission = permission; + this.permissionMSG = permissionMSG; this.costEnable = costEnable; this.costPrice = costPrice; @@ -94,11 +85,6 @@ public class AliasObjekt { this.command = command; this.messageEnable = messageEnable; 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; @@ -107,11 +93,7 @@ public class AliasObjekt { 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; diff --git a/src/main/java/net/t2code/alias/Spigot/objects/SubAliasObject.java b/src/main/java/net/t2code/alias/Spigot/objects/SubAliasObject.java new file mode 100644 index 0000000..777bfa0 --- /dev/null +++ b/src/main/java/net/t2code/alias/Spigot/objects/SubAliasObject.java @@ -0,0 +1,112 @@ +package net.t2code.alias.Spigot.objects; + +import java.util.List; + +public class SubAliasObject { + public Boolean subAliasEnable; + public List subAliasList; + public Integer subAliasArg; + public String subAliasFor; + + public Boolean permNecessary; + public String permission; + public String permissionMSG; + + public Boolean costEnable; + public Double costPrice; + public Boolean costAllowBypass; + + public Boolean commandEnable; + public Boolean commandAsConsole; + public Boolean bungeeCommand; + public List command; + public Boolean messageEnable; + public List messages; + + + public Boolean adminEnable; + public String adminPermission; + public Boolean adminCommandEnable; + public Boolean adminCommandAsConsole; + public Boolean adminBungeeCommand; + public List adminCommands; + public Boolean adminMessageEnable; + public List adminMessages; + public Boolean consoleEnable; + public Boolean consoleCommandEnable; + public Boolean consoleBungeeCommand; + public List consoleCommands; + public Boolean consoleMessageEnable; + public List consoleMessages; + + public SubAliasObject(Boolean subAliasEnable, + List subAliasList, + String subAliasFor, + Integer subAliasArg, + Boolean permNecessary, + String permission, + String permissionMSG, + + Boolean costEnable, + Double costPrice, + Boolean costAllowBypass, + + Boolean commandEnable, + Boolean commandAsConsole, + Boolean bungeeCommand, + List command, + Boolean messageEnable, + List messages, + + Boolean adminEnable, + String adminPermission, + Boolean adminCommandEnable, + Boolean adminCommandAsConsole, + Boolean adminBungeeCommand, + List adminCommands, + Boolean adminMessageEnable, + List adminMessages, + + Boolean consoleEnable, + Boolean consoleCommandEnable, + Boolean consoleBungeeCommand, + List consoleCommands, + Boolean consoleMessageEnable, + List consoleMessages) { + this.subAliasEnable = subAliasEnable; + this.subAliasList = subAliasList; + this.subAliasFor = subAliasFor; + this.subAliasArg = subAliasArg; + this.permNecessary = permNecessary; + this.permission = permission; + this.permissionMSG = permissionMSG; + + this.costEnable = costEnable; + this.costPrice = costPrice; + this.costAllowBypass = costAllowBypass; + + this.commandEnable = commandEnable; + this.commandAsConsole = commandAsConsole; + this.bungeeCommand = bungeeCommand; + this.command = command; + this.messageEnable = messageEnable; + this.messages = messages; + this.adminEnable = adminEnable; + this.adminPermission = adminPermission; + this.adminCommandEnable = adminCommandEnable; + this.adminCommandAsConsole = adminCommandAsConsole; + this.adminBungeeCommand = adminBungeeCommand; + this.adminCommands = adminCommands; + this.adminMessageEnable = adminMessageEnable; + this.adminMessages = adminMessages; + + + this.consoleEnable = consoleEnable; + this.consoleCommandEnable = consoleCommandEnable; + this.consoleBungeeCommand = consoleBungeeCommand; + this.consoleCommands = consoleCommands; + this.consoleMessageEnable = consoleMessageEnable; + this.consoleMessages = consoleMessages; + + } +} diff --git a/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java b/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java index 62009a1..6356bdf 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java +++ b/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java @@ -1,6 +1,7 @@ package net.t2code.alias.Spigot.system; import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Spigot.cmdManagement.AliasCmdExecuter; import net.t2code.alias.Spigot.cmdManagement.RegisterCommands; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion; @@ -12,23 +13,20 @@ import java.lang.reflect.Field; public class AliasRegister { public static void onRegister() { - Plugin plugin = Main.plugin; for (String alias : Main.allAliases) { if (Main.aliasHashMap.get(alias) != null) { if (alias.equals(" ")) continue; if (Main.aliasHashMap.get(alias).aliasEnable) { try { final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap"); - bukkitCommandMap.setAccessible(true); CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer()); - commandMap.register(alias, new RegisterCommands(alias)); - } catch(Exception e) { + } catch (Exception e) { e.printStackTrace(); } } - } else send.warning(plugin, " §4AliasHashmap is null! - " + alias); + } else send.warning(Main.getPlugin(), " §4AliasHashmap is null! - " + alias); } } } diff --git a/src/main/java/net/t2code/alias/Spigot/system/AliasRegisterPermissions.java b/src/main/java/net/t2code/alias/Spigot/system/AliasRegisterPermissions.java index 2eb948b..b80ad84 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/AliasRegisterPermissions.java +++ b/src/main/java/net/t2code/alias/Spigot/system/AliasRegisterPermissions.java @@ -9,7 +9,7 @@ public class AliasRegisterPermissions { public static void onPermRegister() { for (String alias : Main.allAliases){ if (Bukkit.getPluginManager().getPermission("t2code.alias.use." + alias.toLowerCase()) == null) { - Register.permission("t2code.alias.use." + alias.toLowerCase(), Main.plugin); + Register.permission("t2code.alias.use." + alias.toLowerCase(), Main.getPlugin()); } } } diff --git a/src/main/java/net/t2code/alias/Spigot/system/BCommandSenderReciver.java b/src/main/java/net/t2code/alias/Spigot/system/BCommandSenderReciver.java index 449d21a..e05f0c2 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/BCommandSenderReciver.java +++ b/src/main/java/net/t2code/alias/Spigot/system/BCommandSenderReciver.java @@ -30,10 +30,10 @@ public class BCommandSenderReciver { } if (sender instanceof Player) { Player player = (Player) sender; - player.sendPluginMessage(Main.plugin, "t2codealias:bungee", stream.toByteArray()); + player.sendPluginMessage(Main.getPlugin(), "t2codealias:bungee", stream.toByteArray()); }else { for(Player player : Bukkit.getOnlinePlayers()){ - player.sendPluginMessage(Main.plugin, "t2codealias:bungee", stream.toByteArray()); + player.sendPluginMessage(Main.getPlugin(), "t2codealias:bungee", stream.toByteArray()); return; } } diff --git a/src/main/java/net/t2code/alias/Spigot/system/JoinEvent.java b/src/main/java/net/t2code/alias/Spigot/system/JoinEvent.java index 38bd916..8fb3926 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/JoinEvent.java +++ b/src/main/java/net/t2code/alias/Spigot/system/JoinEvent.java @@ -17,19 +17,6 @@ public class JoinEvent implements Listener { @EventHandler public void onJoinEvent(PlayerLoginEvent event) { - Player player = event.getPlayer(); - new BukkitRunnable() { - @Override - public void run() { - String publicVersion = UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion; - if (player.hasPermission("alias.updatemsg") || player.isOp()) { - if (!Main.version.equals(publicVersion)) { - if (SelectLibConfig.UpdateCheckOnJoin) { - UpdateAPI.sendUpdateMsg(Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.version, publicVersion, player); - } - } - } - } - }.runTaskLater(Main.plugin, 200L); + UpdateAPI.join(Main.getPlugin(),Util.getPrefix(), "t2code.alias.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord()); } } \ No newline at end of file diff --git a/src/main/java/net/t2code/alias/Spigot/system/Load.java b/src/main/java/net/t2code/alias/Spigot/system/Load.java index 642954e..c9e2ada 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/Load.java +++ b/src/main/java/net/t2code/alias/Spigot/system/Load.java @@ -2,14 +2,18 @@ package net.t2code.alias.Spigot.system; import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.cmdManagement.AliasCmdExecuter; -import net.t2code.alias.Spigot.config.config.CreateConfig; -import net.t2code.alias.Spigot.config.config.CreateExampleAliasConfig; -import net.t2code.alias.Spigot.config.config.SelectAlias; -import net.t2code.alias.Spigot.config.config.SelectConfig; +import net.t2code.alias.Spigot.cmdManagement.TabEvent; +import net.t2code.alias.Spigot.config.alias.CreateExampleAliasConfig; +import net.t2code.alias.Spigot.config.alias.SelectAlias; +import net.t2code.alias.Spigot.config.config.*; import net.t2code.alias.Spigot.config.languages.LanguagesCreate; import net.t2code.alias.Spigot.config.languages.SelectMessages; +import net.t2code.alias.Spigot.config.subAlias.CreateExampleSubAliasConfig; +import net.t2code.alias.Spigot.config.subAlias.SelectSubAlias; import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; +import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.register.Register; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; @@ -19,15 +23,16 @@ import java.io.File; import java.util.List; public class Load { - static Plugin plugin = Main.plugin; + private static Main plugin = Main.getPlugin(); + public static void onLoad(String prefix, List autor, String version, String spigot, int spigotID, String discord, int bstatsID) { Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord); - Main.plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter()); + plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter()); loadReload(); UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord); Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin); - T2CodeTemplate.onLoadFooter(prefix, long_,version); + T2CodeTemplate.onLoadFooter(prefix, long_, version); Metrics.Bstats(plugin, bstatsID); } @@ -38,9 +43,19 @@ public class Load { } catch (Exception e) { e.printStackTrace(); } + try { + CreateExampleSubAliasConfig.configCreate(); + } catch (Exception e) { + e.printStackTrace(); + } } try { - plugin.saveResource("Alias/X_aliasDeclaration_X.yml",true); + plugin.saveResource("Alias/X_aliasDeclaration_X.yml", true); + } catch (Exception e) { + e.printStackTrace(); + } + try { + plugin.saveResource("SubAlias/X_subAliasDeclaration_X.yml", true); } catch (Exception e) { e.printStackTrace(); } @@ -48,11 +63,18 @@ public class Load { LanguagesCreate.langCreate(); SelectConfig.onSelect(); SelectMessages.onSelect(Util.getPrefix()); + T2CodeTemplate.onLoadSeparateStroke(Util.getPrefix()); SelectAlias.onSelect(); + T2CodeTemplate.onLoadSeparateStroke(Util.getPrefix()); + SelectSubAlias.onSelect(); + SelectConfig.setConfigVersion(); + if (SelectConfig.subAliasTab) { + Register.listener(new TabEvent(), plugin); + } if (SelectConfig.Bungee) { - Main.plugin.getServer().getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord"); - Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "t2codealias:bungee"); + plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord"); + Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2codealias:bungee"); } AliasRegisterPermissions.onPermRegister(); } diff --git a/src/main/java/net/t2code/alias/Util.java b/src/main/java/net/t2code/alias/Util.java index 0a6fe2f..6a533fe 100644 --- a/src/main/java/net/t2code/alias/Util.java +++ b/src/main/java/net/t2code/alias/Util.java @@ -1,14 +1,14 @@ package net.t2code.alias; public class Util { - private static double requiredT2CodeLibVersion = 11.6; + private static String requiredT2CodeLibVersion = "12.5"; private static String Prefix = "§8[§4T2Code§7-§aAlias§8]"; private static Integer SpigotID = 96389; private static Integer BstatsID = 12517; private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID; private static String Discord = "http://dc.t2code.net"; - public static double getRequiredT2CodeLibVersion() { + public static String getRequiredT2CodeLibVersion() { return requiredT2CodeLibVersion; } @@ -31,4 +31,8 @@ public class Util { public static String getDiscord() { return Discord; } + + public static void setPrefix(String prefix) { + Prefix = prefix; + } } diff --git a/src/main/resources/Alias/X_aliasDeclaration_X.yml b/src/main/resources/Alias/X_aliasDeclaration_X.yml index 1ab94e1..c11bb9f 100644 --- a/src/main/resources/Alias/X_aliasDeclaration_X.yml +++ b/src/main/resources/Alias/X_aliasDeclaration_X.yml @@ -1,16 +1,26 @@ #################################################################### -## To create another alias, simply copy the file ## -## and name it what you want the aliascommand to be. ## -## The alias command is always the filename without .yml!!! ## +## The alias command is no longer the filename! ## +## Multiple alias commands can now be specified in one file, ## +## so there is no need to create multiple files! ## +## This option is under 'Alias.AliasList' ## #################################################################### Alias: # Here you can disable the alias Enable: true + # Specify here what the Alias commands should be for this function + AliasList: + - aliasexample1 + - aliasexample2 Permission: # Here you can say if a permission is needed to use the alias# - # Permission: t2code.alias.use. Necessary: true + # Here you can set the permission for the alias. + # The placeholder is the alias name. + # If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias. + Permission: 't2code.alias.use.' + # Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank. + CustomNoPermissionMSG: "" Cost: # Here you can say if you have to pay for the alias Enable: false @@ -29,36 +39,33 @@ Alias: BungeeCommand: false # Here you can specify one or more commands to be executed. # Placeholder: [player] = The player who executes the alias - Commands: [] + Commands: [ ] Message: # Here you can specify whether the player should receive a message. Enable: false # Specify here the message that the player should get. # Multiple lines can be used and placeholders are supported! # Placeholder: [player] = The player who executes the alias - Messages: [] - # With the TextBuilder it is possible to create messages with hover and clickable messages with actions. - # !!! There is currently a poll on our Discord asking if this option should be removed !!! - # To the poll: https://ptb.discord.com/channels/780682397950672897/915625982910672896/984228029297471529 - TextBuilder: - # Here you can activate the TextBuilder. - Enable: false - # Set the hover here - Hover: '' - ClickEvent: - # Here you can give the message a function when clicked on - Enable: false - # Specify here what should happen - # OPEN_URL - Opens a URL under the path specified in ActionValue. - # OPEN_FILE - Opens a file under the path specified by ActionValue. - # RUN_COMMAND - Runs the command specified by ActionValue. - # SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box. - # CHANGE_PAGE - Changes to the page number in a book specified by ActionValue. - # COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard. - Action: '' - # Here you set the value of the action. - # For example, the URL for the link to be opened or the command to be executed. - ActionValue: '' + # + # You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes + # You can use the hover module from T2Code: + # You can add a hover and/or clickable feature to all messages sent to players. + # Use /*/ to separate the message. + # Use [nl] to set a line break in a message or hover. + # Hover message: /*/ + # Message with hover and click function: /*//*//*/ + # Message only with click function: /*//*//*/ + # Action: + # - OPEN_URL - Opens a URL under the path specified in ActionValue. + # - OPEN_FILE - Opens a file under the path specified by ActionValue. + # - RUN_COMMAND - Runs the command specified by ActionValue. + # - SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box. + # - CHANGE_PAGE - Changes to the page number in a book specified by ActionValue. + # - COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard. + # You can also use MiniMessage: + # Wiki: https://docs.adventure.kyori.net/minimessage/format.html + # WebUI: https://webui.adventure.kyori.net + Messages: [ ] # Here you can specify that players with the permission () have a different function than other players. # For example, you can say that players should come to a certain point and players with the admin function only to the server to the position where they were before. @@ -81,36 +88,33 @@ Alias: BungeeCommand: false # Here you can specify one or more commands to be executed. # Placeholder: [player] = The player who executes the alias - Commands: [] + Commands: [ ] Message: # Here you can specify whether the player should receive a message. Enable: false # Specify here the message that the player should get. # Multiple lines can be used and placeholders are supported! # Placeholder: [player] = The player who executes the alias + # + # You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes + # You can use the hover module from T2Code: + # You can add a hover and/or clickable feature to all messages sent to players. + # Use /*/ to separate the message. + # Use [nl] to set a line break in a message or hover. + # Hover message: /*/ + # Message with hover and click function: /*//*//*/ + # Message only with click function: /*//*//*/ + # Action: + # - OPEN_URL - Opens a URL under the path specified in ActionValue. + # - OPEN_FILE - Opens a file under the path specified by ActionValue. + # - RUN_COMMAND - Runs the command specified by ActionValue. + # - SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box. + # - CHANGE_PAGE - Changes to the page number in a book specified by ActionValue. + # - COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard. + # You can also use MiniMessage: + # Wiki: https://docs.adventure.kyori.net/minimessage/format.html + # WebUI: https://webui.adventure.kyori.net Messages: [ ] - # With the TextBuilder it is possible to create messages with hover and clickable messages with actions. - # !!! There is currently a poll on our Discord asking if this option should be removed !!! - # To the poll: https://ptb.discord.com/channels/780682397950672897/915625982910672896/984228029297471529 - TextBuilder: - # Here you can activate the TextBuilder. - Enable: false - # Set the hover here - Hover: '' - ClickEvent: - # Here you can give the message a function when clicked on - Enable: false - # Specify here what should happen - # OPEN_URL - Opens a URL under the path specified in ActionValue. - # OPEN_FILE - Opens a file under the path specified by ActionValue. - # RUN_COMMAND - Runs the command specified by ActionValue. - # SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box. - # CHANGE_PAGE - Changes to the page number in a book specified by ActionValue. - # COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard. - Action: '' - # Here you set the value of the action. - # For example, the URL for the link to be opened or the command to be executed. - ActionValue: '' Console: # Here you can define if the alias is also usable in the console and what it should do from there. @@ -127,4 +131,4 @@ Alias: # Here you can specify whether the player should receive a message. Enable: false # Specify here the message that the player should get. - Messages: [ ] + Messages: [ ] \ No newline at end of file diff --git a/src/main/resources/SubAlias/X_subAliasDeclaration_X.yml b/src/main/resources/SubAlias/X_subAliasDeclaration_X.yml new file mode 100644 index 0000000..3f64cc9 --- /dev/null +++ b/src/main/resources/SubAlias/X_subAliasDeclaration_X.yml @@ -0,0 +1,134 @@ +# + +SubAlias: + # Here you can disable the alias + Enable: true + # Specify here what the SubAlias commands should be for this function + SubAliasList: + - subalias1 + # Enter here the alias command where the subalias should follow. + # For example: + # - aliasexample1 -> aliasexample1 + # - aliasexample2 test -> aliasexample2 test + SubAliasFor: + - aliasexample1 + Permission: + # Here you can say if a permission is needed to use the alias# + Necessary: true + # Here you can set the permission for the alias. + # The placeholder is the alias name. + # If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias. + Permission: 't2code.alias.use.subalias.' + # Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank. + CustomNoPermissionMSG: "" + Cost: + # Here you can say if you have to pay for the alias + Enable: false + # Here you set the price + Price: 0.0 + # Here you define if the bypass is activated or if you have to pay despite the bypass (t2code.alias.buy.bypass). + AllowByPass: true + Command: + # Here you can tell the alias to execute one or more commands + Enable: false + # Here you can specify whether the command should be executed from the console of the server + CommandAsConsole: false + # Here you can define if the command should be executed on the bungee. + # For this option, BungeeCord must be set to true in config.yml and the plugin must also work on the proxy as a bridge. + # (If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled). + BungeeCommand: false + # Here you can specify one or more commands to be executed. + # Placeholder: [player] = The player who executes the alias + Commands: [] + Message: + # Here you can specify whether the player should receive a message. + Enable: false + # Specify here the message that the player should get. + # Multiple lines can be used and placeholders are supported! + # Placeholder: [player] = The player who executes the alias + # + # You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes + # You can use the hover module from T2Code: + # You can add a hover and/or clickable feature to all messages sent to players. + # Use /*/ to separate the message. + # Use [nl] to set a line break in a message or hover. + # Hover message: /*/ + # Message with hover and click function: /*//*//*/ + # Message only with click function: /*//*//*/ + # Action: + # - OPEN_URL - Opens a URL under the path specified in ActionValue. + # - OPEN_FILE - Opens a file under the path specified by ActionValue. + # - RUN_COMMAND - Runs the command specified by ActionValue. + # - SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box. + # - CHANGE_PAGE - Changes to the page number in a book specified by ActionValue. + # - COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard. + # You can also use MiniMessage: + # Wiki: https://docs.adventure.kyori.net/minimessage/format.html + # WebUI: https://webui.adventure.kyori.net + Messages: [] + + # Here you can specify that players with the permission () have a different function than other players. + # For example, you can say that players should come to a certain point and players with the admin function only to the server to the position where they were before. + # Example: + # Player: /warp CityBuild + # Player with Admin Perm: /server CityBuild + Admin: + # Here you can enable or disable the admin function + Enable: true + # Here you set the permission for the admin function + Permission: t2code.alias.admin + Command: + # Here you can tell the alias to execute one or more commands + Enable: false + # Here you can specify whether the command should be executed from the console of the server + CommandAsConsole: false + # Here you can define if the command should be executed on the bungee. + # For this option, BungeeCord must be set to true in config.yml and the plugin must also work on the proxy as a bridge. + # (If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled). + BungeeCommand: false + # Here you can specify one or more commands to be executed. + # Placeholder: [player] = The player who executes the alias + Commands: [] + Message: + # Here you can specify whether the player should receive a message. + Enable: false + # Specify here the message that the player should get. + # Multiple lines can be used and placeholders are supported! + # Placeholder: [player] = The player who executes the alias + # + # You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes + # You can use the hover module from T2Code: + # You can add a hover and/or clickable feature to all messages sent to players. + # Use /*/ to separate the message. + # Use [nl] to set a line break in a message or hover. + # Hover message: /*/ + # Message with hover and click function: /*//*//*/ + # Message only with click function: /*//*//*/ + # Action: + # - OPEN_URL - Opens a URL under the path specified in ActionValue. + # - OPEN_FILE - Opens a file under the path specified by ActionValue. + # - RUN_COMMAND - Runs the command specified by ActionValue. + # - SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box. + # - CHANGE_PAGE - Changes to the page number in a book specified by ActionValue. + # - COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard. + # You can also use MiniMessage: + # Wiki: https://docs.adventure.kyori.net/minimessage/format.html + # WebUI: https://webui.adventure.kyori.net + Messages: [ ] + + Console: + # Here you can define if the alias is also usable in the console and what it should do from there. + Enable: false + Command: + # Here you can tell the alias to execute one or more commands + Enable: false + # Here you can specify whether the command should be executed by the Bungee console. + # For this option, BungeeCord must be set to true in config.yml and the plugin must also work on the proxy as a bridge. + BungeeCommand: false + # Here you can specify one or more commands to be executed. + Commands: [ ] + Message: + # Here you can specify whether the player should receive a message. + Enable: false + # Specify here the message that the player should get. + Messages: [ ] \ No newline at end of file