diff --git a/pom.xml b/pom.xml index b6fed5a..c089b47 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code Alias - 1.0.7 + 1.0.8 jar T2C-Alias @@ -69,7 +69,7 @@ net.t2code T2CodeLib - 11.0 + 11.6 net.t2code diff --git a/src/main/java/net/t2code/alias/Spigot/Main.java b/src/main/java/net/t2code/alias/Spigot/Main.java index fb11d9c..1e1f1da 100644 --- a/src/main/java/net/t2code/alias/Spigot/Main.java +++ b/src/main/java/net/t2code/alias/Spigot/Main.java @@ -1,6 +1,6 @@ package net.t2code.alias.Spigot; -import net.t2code.alias.Spigot.objects.Alias_Objekt; +import net.t2code.alias.Spigot.objects.AliasObjekt; import net.t2code.alias.Spigot.system.Load; import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; @@ -24,7 +24,7 @@ public final class Main extends JavaPlugin { public static Main plugin; - public static HashMap aliasHashMap = new HashMap<>(); + public static HashMap aliasHashMap = new HashMap<>(); public static ArrayList allAliases = new ArrayList<>(); @Override diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Alias_CmdExecuter.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/AliasCmdExecuter.java similarity index 91% rename from src/main/java/net/t2code/alias/Spigot/cmdManagement/Alias_CmdExecuter.java rename to src/main/java/net/t2code/alias/Spigot/cmdManagement/AliasCmdExecuter.java index 3f9c239..90982f5 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Alias_CmdExecuter.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/AliasCmdExecuter.java @@ -1,6 +1,5 @@ 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; @@ -13,7 +12,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -public class Alias_CmdExecuter implements CommandExecutor, TabCompleter { +public class AliasCmdExecuter implements CommandExecutor, TabCompleter { String Prefix; @@ -24,7 +23,7 @@ public class Alias_CmdExecuter implements CommandExecutor, TabCompleter { // Command if (sender.hasPermission("t2code.alias.command.info")) { Commands.info(sender); - } else send.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info") + } else send.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info") .replace("[perm]", "t2code.alias.command.info")); } else { switch (args[0].toLowerCase()) { @@ -32,7 +31,7 @@ public class Alias_CmdExecuter implements CommandExecutor, TabCompleter { case "rl": if (sender.hasPermission("t2code.alias.command.reload") || sender.isOp()) { Commands.reload(sender); - } else send.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias reload") + } else send.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias reload") .replace("[perm]", "t2code.alias.command.reload")); break; case "info": @@ -40,7 +39,7 @@ public class Alias_CmdExecuter implements CommandExecutor, TabCompleter { case "version": if (sender.hasPermission("t2code.alias.command.info")) { Commands.info(sender); - } else send.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info") + } else send.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info") .replace("[perm]", "t2code.alias.command.info")); break; diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java index 471f120..0935343 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java @@ -9,9 +9,6 @@ import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import java.util.List; public class Commands { public static void info(CommandSender sender) { @@ -19,12 +16,12 @@ public class Commands { } public static void reload(CommandSender sender) { - if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadStart); + if (sender instanceof Player) sender.sendMessage(SelectMessages.reloadStart); send.console(Util.getPrefix() + "§8-------------------------------"); send.console(Util.getPrefix() + " §6Plugin reload..."); send.console(Util.getPrefix() + "§8-------------------------------"); Load.loadReload(); - if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadEnd); + if (sender instanceof Player) sender.sendMessage(SelectMessages.reloadEnd); send.console(Util.getPrefix() + "§8-------------------------------"); send.console(Util.getPrefix() + " §2Plugin successfully reloaded."); send.console(Util.getPrefix() + "§8-------------------------------"); 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 a6ca8df..da49477 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java @@ -4,7 +4,7 @@ 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.Alias_Objekt; +import net.t2code.alias.Spigot.objects.AliasObjekt; import net.t2code.alias.Spigot.system.*; import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.commands.Cmd; @@ -12,6 +12,7 @@ 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 net.t2code.lib.Spigot.Lib.vault.Vault; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -27,141 +28,174 @@ public class RegisterCommands extends Command { @Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { - Alias_Objekt Alias = Main.aliasHashMap.get(alias); + AliasObjekt alias = Main.aliasHashMap.get(this.alias); - if (!Alias.AliasEnable) { - send.sender(sender, SelectMessages.AliasDisabled); + 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) { - for (String cmd : Alias.AdminCommands) { - if (Alias.AdminBungeeCommand) { - if (SelectConfig.Bungee) { - if (Alias.AdminCommandAsConsole) { - BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), true); - } else BCommand_Sender_Reciver.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())); - } - } - } + if (alias.adminEnable) { + if (player.hasPermission(alias.adminPermission)) { + if (alias.adminCommandEnable) { + adminCommand(alias, player); } - if (Alias.AdminMessageEnable) { - for (String msg : Alias.AdminMessages) { - String text; - String hover; - if (PluginCheck.papi()) { - text = Replace.replace(prefix, player, msg); - hover = Replace.replace(prefix, player, Alias.AdminHover); - } else { - text = Replace.replace(prefix, msg); - 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); - } - } + if (alias.adminMessageEnable) { + adminMessage(alias, player, prefix); } return true; } } - if (Alias.Perm_necessary) { - if (!(player.hasPermission("t2code.alias.use." + alias.toLowerCase()) || player.hasPermission("t2code.alias.admin"))) { - send.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/" + alias.toLowerCase()) - .replace("[perm]", "t2code.alias.use." + alias.toLowerCase())); + 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.Command_Enable) { - for (String cmd : Alias.Command) { - if (Alias.BungeeCommand) { - if (SelectConfig.Bungee) { - if (Alias.CommandAsConsole) { - BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), true); - } else BCommand_Sender_Reciver.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())); - } + if (alias.costEnable) { + if (!(alias.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass")) ){ + if (!Vault.buy(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.Message_Enable) { - for (String msg : Alias.Messages) { - String text; - String hover; - if (PluginCheck.papi()) { - text = Replace.replace(prefix, player, msg); - hover = Replace.replace(prefix,player,Alias.Hover); - } else{ - text = Replace.replace(prefix, msg); - 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); - } - } + if (alias.commandEnable) { + command(alias, player); + } + if (alias.messageEnable) { + message(alias, player, prefix); } } else { - if (Alias.ConsoleEnable) { - if (Alias.ConsoleCommandEnable) { - for (String cmd : Alias.ConsoleCommands) { - if (Alias.ConsoleBungeeCommand) { - if (SelectConfig.Bungee) { - BCommand_Sender_Reciver.sendToBungee(sender, cmd.replace("[player]", sender.getName()), 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("[player]", sender.getName())); - } - - } - } - if (Alias.ConsoleMessageEnable) { - for (String msg : Alias.ConsoleMessages) { - send.console(Replace.replace(prefix, msg)); - } - } - } else send.sender(sender, SelectMessages.OnlyForPlayer); + if (alias.consoleEnable) { + console(alias, sender, prefix); + } else send.sender(sender, SelectMessages.onlyForPlayer); } 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.replace("[player]", sender.getName()), 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("[player]", sender.getName())); + } + + } + } + 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()); + } } 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 4eeb06b..2d88cf8 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,15 +10,10 @@ import java.io.File; import java.io.IOException; public class CreateConfig { - public static Integer ConfigVersion = 1; - private static Boolean UpdateCheckOnJoin = true; - private static String language = "english"; - - private static Boolean Bungee = false; - private static String thisServer = "server"; + public static Integer ConfigVersion = 2; public static void configCreate() { - Long long_ = Long.valueOf(System.currentTimeMillis()); + 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..."); } else send.console(Util.getPrefix() + " §4config.yml are created..."); @@ -29,18 +24,18 @@ public class CreateConfig { yamlConfiguration.set("ConfigVersion", ConfigVersion); - Config.set("Plugin.UpdateCheckOnJoin", UpdateCheckOnJoin, yamlConfiguration); - Config.set("Plugin.language", language, yamlConfiguration); + Config.set("Plugin.language", "english", yamlConfiguration); - Config.set("BungeeCord.Enable", Bungee, yamlConfiguration); - Config.set("BungeeCord.ThisServer", thisServer, yamlConfiguration); + Config.set("BungeeCord.Enable", false, yamlConfiguration); + Config.set("BungeeCord.ThisServer", "server", yamlConfiguration); + Config.set("Buy.Message", true, yamlConfiguration); try { yamlConfiguration.save(config); } catch (IOException e) { e.printStackTrace(); } - send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } } diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java b/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java index 956be7b..6d34e99 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java @@ -9,51 +9,14 @@ import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; import java.util.Arrays; +import java.util.Collections; import java.util.List; public class CreateExampleAliasConfig { - private static Boolean Enable = true; - private static Boolean PermNecessary = true; - - private static Boolean CommandEnable = true; - private static Boolean CommandAsConsole = true; - private static Boolean BungeeCommand = false; - private static List Commands = Arrays.asList("say hi"); - - private static Boolean MessageEnable = false; - private static List Messages = Arrays.asList(); - private static Boolean TextBuilder = false; - private static String Hover = ""; - private static Boolean ClickEvent = false; - private static String Action = ""; - private static String ActionValue = ""; - - private static Boolean AdminEnable = true; - private static String AdminPermission = "t2code.alias.admin"; - - private static Boolean AdminCommandEnable = true; - private static Boolean AdminCommandAsConsole = true; - private static Boolean AdminBungeeCommand = false; - private static List AdminCommands = Arrays.asList("say hi"); - - private static Boolean AdminMessageEnable = false; - private static List AdminMessages = Arrays.asList(); - private static Boolean AdminTextBuilder = false; - private static String AdminHover = ""; - private static Boolean AdminClickEvent = false; - private static String AdminAction = ""; - private static String AdminActionValue = ""; - - private static Boolean ConsoleEnable = false; - private static Boolean ConsoleCommandEnable = false; - private static Boolean ConsoleBungeeCommand = false; - private static List ConsoleCommands = Arrays.asList(); - private static Boolean ConsoleMessageEnable = false; - private static List ConsoleMessages = Arrays.asList(); public static void configCreate() { - Long long_ = Long.valueOf(System.currentTimeMillis()); + 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..."); } else send.console(Util.getPrefix() + " §4config.yml are created..."); @@ -63,50 +26,53 @@ public class CreateExampleAliasConfig { YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - Config.set("Alias.Enable", Enable, yamlConfiguration); - Config.set("Alias.Permission.Necessary", PermNecessary, yamlConfiguration); + Config.set("Alias.Enable", true, yamlConfiguration); + Config.set("Alias.Permission.Necessary", true, yamlConfiguration); - Config.set("Alias.Command.Enable", CommandEnable, yamlConfiguration); - Config.set("Alias.Command.CommandAsConsole", CommandAsConsole, yamlConfiguration); - Config.set("Alias.Command.BungeeCommand", BungeeCommand, yamlConfiguration); - Config.set("Alias.Command.Commands", Commands, yamlConfiguration); + Config.set("Alias.Cost.Enable", false,yamlConfiguration); + Config.set("Alias.Cost.Price", 0.0,yamlConfiguration); + Config.set("Alias.Cost.AllowByPass", true,yamlConfiguration); - Config.set("Alias.Message.Enable", MessageEnable, yamlConfiguration); - Config.set("Alias.Message.Messages", Messages, yamlConfiguration); - Config.set("Alias.Message.TextBuilder.Enable", TextBuilder, yamlConfiguration); - Config.set("Alias.Message.TextBuilder.Hover", Hover, yamlConfiguration); - Config.set("Alias.Message.TextBuilder.ClickEvent.Enable", ClickEvent, yamlConfiguration); - Config.set("Alias.Message.TextBuilder.ClickEvent.Action", Action, yamlConfiguration); - Config.set("Alias.Message.TextBuilder.ClickEvent.ActionValue", ActionValue, yamlConfiguration); + Config.set("Alias.Command.Enable", true, yamlConfiguration); + Config.set("Alias.Command.CommandAsConsole", true, yamlConfiguration); + Config.set("Alias.Command.BungeeCommand", false, yamlConfiguration); + Config.set("Alias.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration); + 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", AdminEnable, yamlConfiguration); - Config.set("Alias.Admin.Permission", AdminPermission, yamlConfiguration); + Config.set("Alias.Admin.Enable", true, yamlConfiguration); + Config.set("Alias.Admin.Permission", "t2code.alias.admin", yamlConfiguration); - Config.set("Alias.Admin.Command.Enable", AdminCommandEnable, yamlConfiguration); - Config.set("Alias.Admin.Command.CommandAsConsole", AdminCommandAsConsole, yamlConfiguration); - Config.set("Alias.Admin.Command.BungeeCommand", AdminBungeeCommand, yamlConfiguration); - Config.set("Alias.Admin.Command.Commands", AdminCommands, yamlConfiguration); + Config.set("Alias.Admin.Command.Enable", true, yamlConfiguration); + Config.set("Alias.Admin.Command.CommandAsConsole", true, yamlConfiguration); + Config.set("Alias.Admin.Command.BungeeCommand", false, yamlConfiguration); + Config.set("Alias.Admin.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration); - Config.set("Alias.Admin.Message.Enable", AdminMessageEnable, yamlConfiguration); - Config.set("Alias.Admin.Message.Messages", AdminMessages, yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.Enable", AdminTextBuilder, yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.Hover", AdminHover, yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.ClickEvent.Enable", AdminClickEvent, yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.ClickEvent.Action", AdminAction, yamlConfiguration); - Config.set("Alias.Admin.Message.TextBuilder.ClickEvent.ActionValue", AdminActionValue, yamlConfiguration); + 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", ConsoleEnable, yamlConfiguration); - Config.set("Alias.Console.Command.Enable", ConsoleCommandEnable, yamlConfiguration); - Config.set("Alias.Console.Command.BungeeCommand", ConsoleBungeeCommand, yamlConfiguration); - Config.set("Alias.Console.Command.Commands", ConsoleCommands, yamlConfiguration); - Config.set("Alias.Console.Message.Enable", ConsoleMessageEnable, yamlConfiguration); - Config.set("Alias.Console.Message.Messages", ConsoleMessages, yamlConfiguration); + Config.set("Alias.Console.Enable", false, yamlConfiguration); + Config.set("Alias.Console.Command.Enable", false, yamlConfiguration); + Config.set("Alias.Console.Command.BungeeCommand", false, yamlConfiguration); + Config.set("Alias.Console.Command.Commands", Collections.emptyList(), yamlConfiguration); + Config.set("Alias.Console.Message.Enable", false, yamlConfiguration); + Config.set("Alias.Console.Message.Messages", Collections.emptyList(), yamlConfiguration); try { yamlConfiguration.save(config); } catch (IOException e) { e.printStackTrace(); } - send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } } 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 index 24ebb63..06f1eac 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/SelectAlias.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/SelectAlias.java @@ -1,8 +1,9 @@ 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.Alias_Objekt; +import net.t2code.alias.Spigot.objects.AliasObjekt; import net.t2code.alias.Util; import org.bukkit.configuration.file.YamlConfiguration; @@ -22,10 +23,14 @@ public class SelectAlias { Main.allAliases.add(config_gui.getName().replace(".yml", "")); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config_gui); - Alias_Objekt alias = new Alias_Objekt( + 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"), 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 794b0ea..1ddfef5 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 @@ -11,6 +11,8 @@ public class SelectConfig { public static String language; public static Boolean Bungee; public static String thisServer; + + public static Boolean buyMessage; public static void onSelect() { File config = new File(Main.getPath(), "config.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); @@ -21,5 +23,7 @@ public class SelectConfig { language = yamlConfiguration.getString("Plugin.language"); Bungee = yamlConfiguration.getBoolean("BungeeCord.Enable"); thisServer = yamlConfiguration.getString("BungeeCord.ThisServer"); + + buyMessage = yamlConfiguration.getBoolean("Buy.Message"); } } 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 82a6111..b00d101 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 @@ -15,7 +15,7 @@ public class LanguagesCreate { public static void langCreate() { send.debug(plugin,"§4Language files are created / updated..."); - Long long_ = Long.valueOf(System.currentTimeMillis()); + long long_ = System.currentTimeMillis(); /** * @@ -32,6 +32,9 @@ public class LanguagesCreate { Config.set("Plugin.Reload.End", MSG.EN_ReloadEnd, yamlConfigurationEN); Config.set("Plugin.ForCommand", MSG.EN_NoPermissionForCommand, yamlConfigurationEN); + Config. set("Cost.Buy", MSG.EN_Buy, yamlConfigurationEN); + Config.set("Cost.NoMoney", MSG.EN_NoMoney, yamlConfigurationEN); + try { yamlConfigurationEN.save(messagesEN); } catch (IOException e) { @@ -55,6 +58,9 @@ public class LanguagesCreate { Config.set("Plugin.Reload.End", MSG.DE_ReloadEnd, yamlConfigurationDE); Config.set("Plugin.ForCommand", MSG.DE_NoPermissionForCommand, yamlConfigurationDE); + Config.set("Cost.Buy", MSG.DE_Buy, yamlConfigurationDE); + Config.set("Cost.NoMoney", MSG.DE_NoMoney, yamlConfigurationDE); + try { yamlConfigurationDE.save(messagesDE); } catch (IOException e) { @@ -63,31 +69,7 @@ public class LanguagesCreate { } - /** - * - * norwegian - * - */ - - - File messagesNO = new File(Main.getPath(), "languages/norwegian_messages.yml"); - YamlConfiguration yamlConfigurationNO = YamlConfiguration.loadConfiguration(messagesNO); - - Config.set("Plugin.OnlyForPlayer", MSG.NO_OnlyForPlayer, yamlConfigurationNO); - Config.set("Plugin.AliasDisabled", MSG.NO_Disabled, yamlConfigurationNO); - Config.set("Plugin.Reload.Start", MSG.NO_ReloadStart, yamlConfigurationNO); - Config.set("Plugin.Reload.End", MSG.NO_ReloadEnd, yamlConfigurationNO); - Config.set("Plugin.ForCommand", MSG.NO_NoPermissionForCommand, yamlConfigurationNO); - - try { - yamlConfigurationNO.save(messagesNO); - } catch (IOException e) { - send.warning(plugin,e.getMessage()); - e.printStackTrace(); - } - - - send.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + send.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } } 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 47e3df4..5e838fc 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 @@ -24,6 +24,10 @@ public class MSG { public static String EN_NoPermissionForCommand = "[prefix] &cFor &b[cmd] &cyou lack the permission &6[perm]&c!"; + 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!"; + + // DE public static String DE_OnlyForPlayer = "[prefix] &cDieser Command ist nur f[ue]r Spieler!"; @@ -33,17 +37,8 @@ public class MSG { public static String DE_ReloadEnd = "[prefix] &2Plugin wurde erfolgreich neu geladen."; public static String DE_NoPermissionForCommand = "[prefix] &cF[ue]r &b[cmd] &cfehlt dir die Permission &6[perm]&c!"; - // FR - - // NO - public static String NO_OnlyForPlayer = "[prefix] &cDenne kommandoen er for spillere kun!"; - - public static String NO_Disabled = "Unknown command. Type ''/help'' for help."; - - public static String NO_ReloadStart = "[prefix] &6Pluginet blir relastet..."; - public static String NO_ReloadEnd = "[prefix] &2Pluginet har blitt lastet inn på nytt."; - - public static String NO_NoPermissionForCommand = "[prefix] &cFor &b[cmd] &cmangler du tillatelsen &6[perm]&c!"; + 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!"; } 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 d1fe41f..2cdace1 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 @@ -4,22 +4,24 @@ import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.config.config.SelectConfig; import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.replace.Replace; import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; public class SelectMessages { - private static String prefix = Util.getPrefix(); - public static String selectMSG; - public static String OnlyForPlayer; - public static String ReloadStart; - public static String ReloadEnd; + public static String onlyForPlayer; + public static String reloadStart; + public static String reloadEnd; - public static String NoPermissionForCommand; - public static String AliasDisabled; + public static String noPermissionForCommand; + public static String aliasDisabled; + + public static String buy; + public static String noMoney; public static void onSelect(String Prefix) { @@ -42,12 +44,18 @@ public class SelectMessages { } else selectMSG = SelectConfig.language; YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(msg); - OnlyForPlayer = Config.select(prefix, "Plugin.OnlyForPlayer", yamlConfiguration); - AliasDisabled = Config.select(prefix, "Plugin.AliasDisabled", yamlConfiguration); - ReloadStart = Config.select(prefix, "Plugin.Reload.Start", yamlConfiguration); - ReloadEnd = Config.select(prefix, "Plugin.Reload.End", yamlConfiguration); - NoPermissionForCommand = Config.select(prefix, "Plugin.ForCommand", yamlConfiguration); + onlyForPlayer = replace(yamlConfiguration.getString("Plugin.OnlyForPlayer")); + aliasDisabled = replace(yamlConfiguration.getString("Plugin.AliasDisabled")); + reloadStart = replace(yamlConfiguration.getString("Plugin.Reload.Start")); + reloadEnd = replace(yamlConfiguration.getString("Plugin.Reload.End")); + noPermissionForCommand = replace(yamlConfiguration.getString("Plugin.ForCommand")); + 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_.longValue()) + "ms"); + } + + private static String replace(String text) { + return Replace.replace(Util.getPrefix(), text); } } diff --git a/src/main/java/net/t2code/alias/Spigot/objects/AliasObjekt.java b/src/main/java/net/t2code/alias/Spigot/objects/AliasObjekt.java new file mode 100644 index 0000000..a6d149f --- /dev/null +++ b/src/main/java/net/t2code/alias/Spigot/objects/AliasObjekt.java @@ -0,0 +1,124 @@ +package net.t2code.alias.Spigot.objects; + +import java.util.List; + +public class AliasObjekt { + public Boolean aliasEnable; + public Boolean commandEnable; + public Boolean permNecessary; + + public Boolean costEnable; + public Double costPrice; + public Boolean costAllowBypass; + + 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; + public Boolean adminCommandEnable; + public Boolean adminCommandAsConsole; + public Boolean adminBungeeCommand; + 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; + public List consoleCommands; + public Boolean consoleMessageEnable; + public List consoleMessages; + + public AliasObjekt(Boolean aliasEnable, + Boolean permNecessary, + + Boolean costEnable, + Double costPrice, + Boolean costAllowBypass, + + Boolean commandEnable, + Boolean commandAsConsole, + Boolean bungeeCommand, + List command, + Boolean messageEnable, + List messages, + Boolean textBuilder, + String hover, + Boolean clickEvent, + String action, + String actionValue, + + Boolean adminEnable, + String adminPermission, + Boolean adminCommandEnable, + Boolean adminCommandAsConsole, + Boolean adminBungeeCommand, + List adminCommands, + Boolean adminMessageEnable, + List adminMessages, + Boolean adminTextBuilder, + String adminHover, + Boolean adminClickEvent, + String adminAction, + String adminActionValue, + + Boolean consoleEnable, + Boolean consoleCommandEnable, + Boolean consoleBungeeCommand, + List consoleCommands, + Boolean consoleMessageEnable, + List consoleMessages) { + this.aliasEnable = aliasEnable; + this.permNecessary = permNecessary; + + 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.textBuilder = textBuilder; + this.hover = hover; + this.clickEvent = clickEvent; + this.action = action; + this.actionValue = actionValue; + this.adminEnable = adminEnable; + this.adminPermission = adminPermission; + this.adminCommandEnable = adminCommandEnable; + this.adminCommandAsConsole = adminCommandAsConsole; + this.adminBungeeCommand = adminBungeeCommand; + this.adminCommands = adminCommands; + this.adminMessageEnable = adminMessageEnable; + this.adminMessages = adminMessages; + this.adminTextBuilder = adminTextBuilder; + this.adminHover = adminHover; + this.adminClickEvent = adminClickEvent; + this.adminAction = adminAction; + this.adminActionValue = adminActionValue; + + this.consoleEnable = consoleEnable; + this.consoleCommandEnable = consoleCommandEnable; + this.consoleBungeeCommand = consoleBungeeCommand; + this.consoleCommands = consoleCommands; + this.consoleMessageEnable = consoleMessageEnable; + this.consoleMessages = consoleMessages; + + } +} diff --git a/src/main/java/net/t2code/alias/Spigot/objects/Alias_Objekt.java b/src/main/java/net/t2code/alias/Spigot/objects/Alias_Objekt.java deleted file mode 100644 index e716996..0000000 --- a/src/main/java/net/t2code/alias/Spigot/objects/Alias_Objekt.java +++ /dev/null @@ -1,112 +0,0 @@ -package net.t2code.alias.Spigot.objects; - -import java.util.List; - -public class Alias_Objekt { - public Boolean AliasEnable; - public Boolean Command_Enable; - public Boolean Perm_necessary; - - public Boolean CommandAsConsole; - public Boolean BungeeCommand; - public List Command; - public Boolean Message_Enable; - public List Messages; - public Boolean TextBuilder; - public String Hover; - public Boolean ClickEvent; - public String Action; - public String ActionValue; - - public Boolean AdminEnable; - public String AdminPermission; - public Boolean AdminCommandEnable; - public Boolean AdminCommandAsConsole; - public Boolean AdminBungeeCommand; - 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; - public List ConsoleCommands; - public Boolean ConsoleMessageEnable; - public List ConsoleMessages; - - public Alias_Objekt(Boolean AliasEnable, - Boolean Perm_necessary, - - Boolean Command_Enable, - Boolean CommandAsConsole, - Boolean BungeeCommand, - List Command, - Boolean Message_Enable, - List Messages, - Boolean TextBuilder, - String Hover, - Boolean ClickEvent, - String Action, - String ActionValue, - - Boolean AdminEnable, - String AdminPermission, - Boolean AdminCommandEnable, - Boolean AdminCommandAsConsole, - Boolean AdminBungeeCommand, - List AdminCommands, - Boolean AdminMessageEnable, - List AdminMessages, - Boolean AdminTextBuilder, - String AdminHover, - Boolean AdminClickEvent, - String AdminAction, - String AdminActionValue, - - Boolean ConsoleEnable, - Boolean ConsoleCommandEnable, - Boolean ConsoleBungeeCommand, - List ConsoleCommands, - Boolean ConsoleMessageEnable, - List ConsoleMessages) { - this.AliasEnable = AliasEnable; - this.Perm_necessary = Perm_necessary; - - this.Command_Enable = Command_Enable; - this.CommandAsConsole = CommandAsConsole; - this.BungeeCommand = BungeeCommand; - this.Command = Command; - this.Message_Enable = Message_Enable; - this.Messages = Messages; - this.TextBuilder = TextBuilder; - this.Hover = Hover; - this.ClickEvent = ClickEvent; - this.Action = Action; - this.ActionValue = ActionValue; - this.AdminEnable = AdminEnable; - this.AdminPermission = AdminPermission; - this.AdminCommandEnable = AdminCommandEnable; - this.AdminCommandAsConsole = AdminCommandAsConsole; - this.AdminBungeeCommand = AdminBungeeCommand; - this.AdminCommands = AdminCommands; - this.AdminMessageEnable = AdminMessageEnable; - this.AdminMessages = AdminMessages; - this.AdminTextBuilder = AdminTextBuilder; - this.AdminHover = AdminHover; - this.AdminClickEvent = AdminClickEvent; - this.AdminAction = AdminAction; - this.AdminActionValue = AdminActionValue; - - this.ConsoleEnable = ConsoleEnable; - this.ConsoleCommandEnable = ConsoleCommandEnable; - this.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 3843d35..62009a1 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java +++ b/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java @@ -4,103 +4,28 @@ import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.cmdManagement.RegisterCommands; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandMap; import org.bukkit.plugin.Plugin; +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 (Main.aliasHashMap.get(alias).AliasEnable) { - if (NMSVersion.v1_8_R1) { - send.debug(plugin, "Alias register 1.8_R1"); - org.bukkit.craftbukkit.v1_8_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_8_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_8_R2) { - send.debug(plugin, "Alias register 1.8_R2"); - org.bukkit.craftbukkit.v1_8_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_8_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_8_R3) { - send.debug(plugin, "Alias register 1.8_R3"); - org.bukkit.craftbukkit.v1_8_R3.CraftServer craftServer = (org.bukkit.craftbukkit.v1_8_R3.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_9_R1) { - send.debug(plugin, "Alias register 1.9_R1"); - org.bukkit.craftbukkit.v1_9_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_9_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_9_R2) { - send.debug(plugin, "Alias register 1.9_R2"); - org.bukkit.craftbukkit.v1_9_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_9_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_10_R1) { - send.debug(plugin, "Alias register 1.10_R1"); - org.bukkit.craftbukkit.v1_10_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_10_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_11_R1) { - send.debug(plugin, "Alias register 1.11_R1"); - org.bukkit.craftbukkit.v1_11_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_11_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_12_R1) { - send.debug(plugin, "Alias register 1.12_R1"); - org.bukkit.craftbukkit.v1_12_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_12_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_13_R1) { - send.debug(plugin, "Alias register 1.13_R1"); - org.bukkit.craftbukkit.v1_13_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_13_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_13_R2) { - send.debug(plugin, "Alias register 1.13_R2"); - org.bukkit.craftbukkit.v1_13_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_13_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_14_R1) { - send.debug(plugin, "Alias register 1.14_R1"); - org.bukkit.craftbukkit.v1_14_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_14_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_15_R1) { - send.debug(plugin, "Alias register 1.15_R1"); - org.bukkit.craftbukkit.v1_15_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_15_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_16_R1) { - send.debug(plugin, "Alias register 1.16_R1"); - org.bukkit.craftbukkit.v1_16_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_16_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_16_R2) { - send.debug(plugin, "Alias register 1.16_R2"); - org.bukkit.craftbukkit.v1_16_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_16_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_16_R3) { - send.debug(plugin, "Alias register 1.16_R3"); - org.bukkit.craftbukkit.v1_16_R3.CraftServer craftServer = (org.bukkit.craftbukkit.v1_16_R3.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_17_R1) { - send.debug(plugin, "Alias register 1.17_R1"); - org.bukkit.craftbukkit.v1_17_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_17_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_18_R1) { - send.debug(plugin, "Alias register 1.18_R1"); - org.bukkit.craftbukkit.v1_18_R1.CraftServer craftServer = (org.bukkit.craftbukkit.v1_18_R1.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); - } - if (NMSVersion.v1_18_R2) { - send.debug(plugin, "Alias register 1.18_R2"); - org.bukkit.craftbukkit.v1_18_R2.CraftServer craftServer = (org.bukkit.craftbukkit.v1_18_R2.CraftServer) plugin.getServer(); - craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); + 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) { + e.printStackTrace(); } } } else send.warning(plugin, " §4AliasHashmap is null! - " + alias); diff --git a/src/main/java/net/t2code/alias/Spigot/system/Alias_RegisterPermissions.java b/src/main/java/net/t2code/alias/Spigot/system/AliasRegisterPermissions.java similarity index 84% rename from src/main/java/net/t2code/alias/Spigot/system/Alias_RegisterPermissions.java rename to src/main/java/net/t2code/alias/Spigot/system/AliasRegisterPermissions.java index b87dcb1..2eb948b 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/Alias_RegisterPermissions.java +++ b/src/main/java/net/t2code/alias/Spigot/system/AliasRegisterPermissions.java @@ -3,9 +3,8 @@ package net.t2code.alias.Spigot.system; import net.t2code.alias.Spigot.Main; import net.t2code.lib.Spigot.Lib.register.Register; import org.bukkit.Bukkit; -import org.bukkit.permissions.Permission; -public class Alias_RegisterPermissions { +public class AliasRegisterPermissions { public static void onPermRegister() { for (String alias : Main.allAliases){ diff --git a/src/main/java/net/t2code/alias/Spigot/system/BCommand_Sender_Reciver.java b/src/main/java/net/t2code/alias/Spigot/system/BCommandSenderReciver.java similarity index 94% rename from src/main/java/net/t2code/alias/Spigot/system/BCommand_Sender_Reciver.java rename to src/main/java/net/t2code/alias/Spigot/system/BCommandSenderReciver.java index 1b62ab5..449d21a 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/BCommand_Sender_Reciver.java +++ b/src/main/java/net/t2code/alias/Spigot/system/BCommandSenderReciver.java @@ -1,7 +1,6 @@ package net.t2code.alias.Spigot.system; import net.t2code.alias.Spigot.Main; -import net.t2code.lib.Spigot.Lib.messages.send; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -10,7 +9,7 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; -public class BCommand_Sender_Reciver { +public class BCommandSenderReciver { public static void sendToBungee(CommandSender sender, String information, Boolean console) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); 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 7e36840..48259db 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/Load.java +++ b/src/main/java/net/t2code/alias/Spigot/system/Load.java @@ -1,7 +1,7 @@ package net.t2code.alias.Spigot.system; import net.t2code.alias.Spigot.Main; -import net.t2code.alias.Spigot.cmdManagement.Alias_CmdExecuter; +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; @@ -22,7 +22,7 @@ public class Load { static Plugin plugin = Main.plugin; 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 Alias_CmdExecuter()); + Main.plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter()); loadReload(); UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord); Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin); @@ -51,6 +51,6 @@ public class Load { Main.plugin.getServer().getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord"); Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "t2codealias:bungee"); } - Alias_RegisterPermissions.onPermRegister(); + AliasRegisterPermissions.onPermRegister(); } } diff --git a/src/main/java/net/t2code/alias/Util.java b/src/main/java/net/t2code/alias/Util.java index 8e47679..0a6fe2f 100644 --- a/src/main/java/net/t2code/alias/Util.java +++ b/src/main/java/net/t2code/alias/Util.java @@ -1,7 +1,7 @@ package net.t2code.alias; public class Util { - private static double requiredT2CodeLibVersion = 11.0; + private static double requiredT2CodeLibVersion = 11.6; private static String Prefix = "§8[§4T2Code§7-§aAlias§8]"; private static Integer SpigotID = 96389; private static Integer BstatsID = 12517; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 377effa..2efc7f8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -22,8 +22,11 @@ permissions: t2code.alias.updatemsg: true t2code.alias.command.reload: true t2code.alias.command.info: true + t2code.alias.buy.bypass: true + t2code.alias.buy.bypass: + default: op t2code.alias.updatemsg: default: op t2code.alias.command.reload: