1.0.8-sn-b2

This commit is contained in:
JaTiTV 2022-03-10 19:21:02 +01:00
parent 857c87ea9b
commit 618748a5f2
11 changed files with 188 additions and 158 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>AliasBungee</artifactId>
<version>1.0.6</version>
<version>1.0.8-Snapshot-B2</version>
<packaging>jar</packaging>
<name>T2C-AliasBungee</name>

View File

@ -2,7 +2,7 @@ package net.t2code.alias.Bungee;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.alias.Bungee.objects.Alias_Objekt;
import net.t2code.alias.Bungee.objects.AliasObjekt;
import net.t2code.alias.Bungee.system.Load;
import net.t2code.alias.Util;
import net.t2code.lib.Bungee.Lib.messages.BT2CodeTemplate;
@ -30,7 +30,7 @@ public final class Main extends Plugin {
public static Main plugin;
public static HashMap<String, Alias_Objekt> aliasHashMap = new HashMap<>();
public static HashMap<String, AliasObjekt> aliasHashMap = new HashMap<>();
public static ArrayList<String> allAliases = new ArrayList<>();
private static Boolean enable= false;

View File

@ -26,7 +26,7 @@ public class Alias_CmdExecuter extends Command implements TabExecutor {
// Command
if (sender.hasPermission("t2code.alias.command.info")) {
Commands.info(sender);
} else Bsend.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info")
} else Bsend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info"));
} else {
switch (args[0].toLowerCase()) {
@ -34,7 +34,7 @@ public class Alias_CmdExecuter extends Command implements TabExecutor {
case "rl":
if (sender.hasPermission("t2code.alias.command.reload")) {
Commands.reload(sender);
} else Bsend.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias reload")
} else Bsend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias reload")
.replace("[perm]", "t2code.alias.command.reload"));
break;
case "info":
@ -42,7 +42,7 @@ public class Alias_CmdExecuter extends Command implements TabExecutor {
case "version":
if (sender.hasPermission("t2code.alias.command.info")) {
Commands.info(sender);
} else Bsend.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info")
} else Bsend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info"));
break;
}

View File

@ -25,12 +25,12 @@ public class Commands {
}
public static void reload(CommandSender sender) {
if (sender instanceof ProxiedPlayer) sender.sendMessage(SelectMessages.ReloadStart);
if (sender instanceof ProxiedPlayer) sender.sendMessage(SelectMessages.reloadStart);
Bsend.console(Main.prefix + "§8-------------------------------");
Bsend.console(Main.prefix + " §6Plugin reload...");
Bsend.console(Main.prefix + "§8-------------------------------");
Load.loadReload();
if (sender instanceof ProxiedPlayer) sender.sendMessage(SelectMessages.ReloadEnd);
if (sender instanceof ProxiedPlayer) sender.sendMessage(SelectMessages.reloadEnd);
Bsend.console(Main.prefix + "§8-------------------------------");
Bsend.console(Main.prefix + " §2Plugin successfully reloaded.");
Bsend.console(Main.prefix + "§8-------------------------------");

View File

@ -6,7 +6,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.t2code.alias.Bungee.Main;
import net.t2code.alias.Bungee.config.languages.SelectMessages;
import net.t2code.alias.Bungee.objects.Alias_Objekt;
import net.t2code.alias.Bungee.objects.AliasObjekt;
import net.t2code.lib.Bungee.Lib.commands.Bcmd;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import net.t2code.lib.Bungee.Lib.replace.BReplace;
@ -23,35 +23,44 @@ public class RegisterCommands extends Command {
@Override
public void execute(CommandSender sender, String[] args) {
Alias_Objekt Alias = Main.aliasHashMap.get(alias);
AliasObjekt Alias = Main.aliasHashMap.get(alias);
if (!Alias.AliasEnable) {
Bsend.sender(sender, SelectMessages.AliasDisabled);
if (!Alias.aliasEnable) {
Bsend.sender(sender, SelectMessages.aliasDisabled);
return;
}
if (sender instanceof ProxiedPlayer) {
ProxiedPlayer player = (ProxiedPlayer) sender;
if (Alias.AdminEnable) {
if (player.hasPermission(Alias.AdminPermission)) {
if (Alias.AdminCommandEnable) {
for (String cmd : Alias.AdminCommands) {
if (Alias.AdminCommandAsConsole) {
if (Alias.serverProtectionEnable) {
if (Alias.serverProtectionMode.equalsIgnoreCase("blacklist") && Alias.serverProtectionList.contains(player.getServer().getInfo().getName())) {
return;
}
if (Alias.serverProtectionMode.equalsIgnoreCase("whitelist") && !Alias.serverProtectionList.contains(player.getServer().getInfo().getName())) {
return;
}
}
if (Alias.adminEnable) {
if (player.hasPermission(Alias.adminPermission)) {
if (Alias.adminCommandEnable) {
for (String cmd : Alias.adminCommands) {
if (Alias.adminCommandAsConsole) {
Bcmd.Console(cmd.replace("[player]", player.getName()));
} else {
Bcmd.Player(player, cmd.replace("[player]", player.getName()));
}
}
}
if (Alias.AdminMessageEnable) {
for (String msg : Alias.AdminMessages) {
if (Alias.adminMessageEnable) {
for (String msg : Alias.adminMessages) {
String text = BReplace.replace(prefix, msg);
String hover = BReplace.replace(prefix, Alias.AdminHover);
if (Alias.AdminTextBuilder) {
String hover = BReplace.replace(prefix, Alias.adminHover);
if (Alias.adminTextBuilder) {
TextBuilder textBuilder = new TextBuilder(text);
textBuilder.addHover(hover);
if (Alias.AdminClickEvent) {
textBuilder.addClickEvent(ClickEvent.Action.valueOf(Alias.AdminAction), Alias.AdminActionValue);
if (Alias.adminClickEvent) {
textBuilder.addClickEvent(ClickEvent.Action.valueOf(Alias.adminAction), Alias.adminActionValue);
}
player.sendMessage(textBuilder.build());
} else {
@ -62,31 +71,31 @@ public class RegisterCommands extends Command {
return;
}
}
if (Alias.Perm_necessary) {
if (Alias.permNecessary) {
if (!(player.hasPermission("t2code.alias.use." + alias.toLowerCase()) || player.hasPermission("t2code.alias.admin"))) {
Bsend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/" + alias.toLowerCase())
Bsend.player(player, SelectMessages.noPermissionForCommand.replace("[cmd]", "/" + alias.toLowerCase())
.replace("[perm]", "t2code.alias.use." + alias.toLowerCase()));
return;
}
}
if (Alias.Command_Enable) {
for (String cmd : Alias.Command) {
if (Alias.CommandAsConsole) {
if (Alias.command_Enable) {
for (String cmd : Alias.command) {
if (Alias.commandAsConsole) {
Bcmd.Console(cmd.replace("[player]", player.getName()));
} else {
Bcmd.Player(player, cmd.replace("[player]", player.getName()));
}
}
}
if (Alias.Message_Enable) {
for (String msg : Alias.Messages) {
if (Alias.messageEnable) {
for (String msg : Alias.messages) {
String text = BReplace.replace(prefix, msg);
String hover = BReplace.replace(prefix, Alias.Hover);
if (Alias.TextBuilder) {
String hover = BReplace.replace(prefix, Alias.hover);
if (Alias.textBuilder) {
TextBuilder textBuilder = new TextBuilder(text);
textBuilder.addHover(hover);
if (Alias.ClickEvent) {
textBuilder.addClickEvent(ClickEvent.Action.valueOf(Alias.Action), Alias.ActionValue);
if (Alias.clickEvent) {
textBuilder.addClickEvent(ClickEvent.Action.valueOf(Alias.action), Alias.actionValue);
}
player.sendMessage(textBuilder.build());
} else {
@ -95,18 +104,18 @@ public class RegisterCommands extends Command {
}
}
} else {
if (Alias.ConsoleEnable) {
if (Alias.ConsoleCommandEnable) {
for (String cmd : Alias.ConsoleCommands) {
if (Alias.consoleEnable) {
if (Alias.consoleCommandEnable) {
for (String cmd : Alias.consoleCommands) {
Bcmd.Console(cmd.replace("[player]", sender.getName()));
}
}
if (Alias.ConsoleMessageEnable) {
for (String msg : Alias.ConsoleMessages) {
if (Alias.consoleMessageEnable) {
for (String msg : Alias.consoleMessages) {
Bsend.console(BReplace.replace(prefix, msg));
}
}
} else Bsend.sender(sender, SelectMessages.OnlyForPlayer);
} else Bsend.sender(sender, SelectMessages.onlyForPlayer);
}
return;
}

View File

@ -68,6 +68,10 @@ public class CreateExampleAliasConfig {
BConfig.set("Alias.Enable", Enable, configuration);
BConfig.set("Alias.Permission.Necessary", PermNecessary, configuration);
BConfig.set("Alias.Protection.Server.Enable", false, configuration);
BConfig.set("Alias.Protection.Server.Mode", "blacklist", configuration);
BConfig.set("Alias.Protection.Server.List", Arrays.asList("Server1", "Server2"), configuration);
BConfig.set("Alias.Command.Enable", CommandEnable, configuration);
BConfig.set("Alias.Command.CommandAsConsole", CommandAsConsole, configuration);
BConfig.set("Alias.Command.Commands", Commands, configuration);
@ -80,7 +84,6 @@ public class CreateExampleAliasConfig {
BConfig.set("Alias.Message.TextBuilder.ClickEvent.Action", Action, configuration);
BConfig.set("Alias.Message.TextBuilder.ClickEvent.ActionValue", ActionValue, configuration);
BConfig.set("Alias.Admin.Enable", AdminEnable, configuration);
BConfig.set("Alias.Admin.Permission", AdminPermission, configuration);

View File

@ -5,7 +5,7 @@ import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import net.t2code.alias.Bungee.Main;
import net.t2code.alias.Bungee.system.AliasRegister;
import net.t2code.alias.Bungee.objects.Alias_Objekt;
import net.t2code.alias.Bungee.objects.AliasObjekt;
import java.io.File;
import java.io.IOException;
@ -24,10 +24,14 @@ public class SelectAlias {
if (sub.equals(".yml")) {
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config_gui);
Alias_Objekt alias = new Alias_Objekt(
AliasObjekt alias = new AliasObjekt(
configuration.getBoolean("Alias.Enable"),
configuration.getBoolean("Alias.Permission.Necessary"),
configuration.getBoolean("Alias.Protection.Server.Enable"),
configuration.getString("Alias.Protection.Server.Mode"),
configuration.getStringList("Alias.Protection.Server.List"),
configuration.getBoolean("Alias.Command.Enable"),
configuration.getBoolean("Alias.Command.CommandAsConsole"),
configuration.getStringList("Alias.Command.Commands"),

View File

@ -5,6 +5,7 @@ import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import net.t2code.alias.Bungee.Main;
import net.t2code.alias.Bungee.config.config.SelectConfig;
import net.t2code.alias.Util;
import net.t2code.lib.Bungee.Lib.messages.Bsend;
import net.t2code.lib.Bungee.Lib.yamlConfiguration.BConfig;
@ -12,16 +13,17 @@ import java.io.File;
import java.io.IOException;
public class SelectMessages {
private static String prefix = Main.prefix;
private static String prefix = Util.getPrefix();
public static String selectMSG;
public static String OnlyForPlayer;
public static String ReloadStart;
public static String ReloadEnd;
public static String onlyForPlayer;
public static String reloadStart;
public static String reloadEnd;
public static String NoPermissionForCommand;
public static String AliasDisabled;
public static String noPermissionForCommand;
public static String aliasDisabled;
public static void onSelect(String Prefix)throws IOException {
@ -40,11 +42,11 @@ public class SelectMessages {
} else selectMSG = SelectConfig.language;
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(msg);
OnlyForPlayer = BConfig.select(prefix, "Plugin.OnlyForPlayer", configuration);
AliasDisabled = BConfig.select(prefix, "Plugin.AliasDisabled", configuration);
ReloadStart = BConfig.select(prefix, "Plugin.Reload.Start", configuration);
ReloadEnd = BConfig.select(prefix, "Plugin.Reload.End", configuration);
NoPermissionForCommand = BConfig.select(prefix, "Plugin.ForCommand", configuration);
onlyForPlayer = BConfig.select(prefix, "Plugin.OnlyForPlayer", configuration);
aliasDisabled = BConfig.select(prefix, "Plugin.AliasDisabled", configuration);
reloadStart = BConfig.select(prefix, "Plugin.Reload.Start", configuration);
reloadEnd = BConfig.select(prefix, "Plugin.Reload.End", configuration);
noPermissionForCommand = BConfig.select(prefix, "Plugin.ForCommand", configuration);
Bsend.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
}

View File

@ -0,0 +1,115 @@
package net.t2code.alias.Bungee.objects;
import java.util.List;
public class AliasObjekt {
public Boolean aliasEnable;
public Boolean permNecessary;
public Boolean serverProtectionEnable;
public String serverProtectionMode;
public List<String> serverProtectionList;
public Boolean command_Enable;
public Boolean commandAsConsole;
public List<String> command;
public Boolean messageEnable;
public List<String> messages;
public Boolean textBuilder;
public String hover;
public Boolean clickEvent;
public String action;
public String actionValue;
public Boolean adminEnable;
public String adminPermission;
public Boolean adminCommandEnable;
public Boolean adminCommandAsConsole;
public List<String> adminCommands;
public Boolean adminMessageEnable;
public List<String> adminMessages;
public Boolean adminTextBuilder;
public String adminHover;
public Boolean adminClickEvent;
public String adminAction;
public String adminActionValue;
public Boolean consoleEnable;
public Boolean consoleCommandEnable;
public List<String> consoleCommands;
public Boolean consoleMessageEnable;
public List<String> consoleMessages;
public AliasObjekt(Boolean aliasEnable,
Boolean permNecessary,
Boolean serverProtectionEnable,
String serverProtectionMode,
List<String> serverProtectionList,
Boolean commandEnable,
Boolean commandAsConsole,
List<String> command,
Boolean message_Enable,
List<String> messages,
Boolean textBuilder,
String hover,
Boolean clickEvent,
String action,
String actionValue,
Boolean adminEnable,
String adminPermission,
Boolean adminCommandEnable,
Boolean adminCommandAsConsole,
List<String> adminCommands,
Boolean adminMessageEnable,
List<String> adminMessages,
Boolean adminTextBuilder,
String adminHover,
Boolean adminClickEvent,
String adminAction,
String adminActionValue,
Boolean consoleEnable,
Boolean consoleCommandEnable,
List<String> consoleCommands,
Boolean consoleMessageEnable,
List<String> consoleMessages) {
this.aliasEnable = aliasEnable;
this.permNecessary = permNecessary;
this.serverProtectionEnable = serverProtectionEnable;
this.serverProtectionMode = serverProtectionMode;
this.serverProtectionList = serverProtectionList;
this.command_Enable = commandEnable;
this.commandAsConsole = commandAsConsole;
this.command = command;
this.messageEnable = message_Enable;
this.messages = messages;
this.textBuilder = textBuilder;
this.hover = hover;
this.clickEvent = clickEvent;
this.action = action;
this.actionValue = actionValue;
this.adminEnable = adminEnable;
this.adminPermission = adminPermission;
this.adminCommandEnable = adminCommandEnable;
this.adminCommandAsConsole = adminCommandAsConsole;
this.adminCommands = adminCommands;
this.adminMessageEnable = adminMessageEnable;
this.adminMessages = adminMessages;
this.adminTextBuilder = adminTextBuilder;
this.adminHover = adminHover;
this.adminClickEvent = adminClickEvent;
this.adminAction = adminAction;
this.adminActionValue = adminActionValue;
this.consoleEnable = consoleEnable;
this.consoleCommandEnable = consoleCommandEnable;
this.consoleCommands = consoleCommands;
this.consoleMessageEnable = consoleMessageEnable;
this.consoleMessages = consoleMessages;
}
}

View File

@ -1,103 +0,0 @@
package net.t2code.alias.Bungee.objects;
import java.util.List;
public class Alias_Objekt {
public Boolean AliasEnable;
public Boolean Command_Enable;
public Boolean Perm_necessary;
public Boolean CommandAsConsole;
public List<String> Command;
public Boolean Message_Enable;
public List<String> Messages;
public Boolean TextBuilder;
public String Hover;
public Boolean ClickEvent;
public String Action;
public String ActionValue;
public Boolean AdminEnable;
public String AdminPermission;
public Boolean AdminCommandEnable;
public Boolean AdminCommandAsConsole;
public List<String> AdminCommands;
public Boolean AdminMessageEnable;
public List<String> AdminMessages;
public Boolean AdminTextBuilder;
public String AdminHover;
public Boolean AdminClickEvent;
public String AdminAction;
public String AdminActionValue;
public Boolean ConsoleEnable;
public Boolean ConsoleCommandEnable;
public List<String> ConsoleCommands;
public Boolean ConsoleMessageEnable;
public List<String> ConsoleMessages;
public Alias_Objekt(Boolean AliasEnable,
Boolean Perm_necessary,
Boolean Command_Enable,
Boolean CommandAsConsole,
List Command,
Boolean Message_Enable,
List Messages,
Boolean TextBuilder,
String Hover,
Boolean ClickEvent,
String Action,
String ActionValue,
Boolean AdminEnable,
String AdminPermission,
Boolean AdminCommandEnable,
Boolean AdminCommandAsConsole,
List AdminCommands,
Boolean AdminMessageEnable,
List AdminMessages,
Boolean AdminTextBuilder,
String AdminHover,
Boolean AdminClickEvent,
String AdminAction,
String AdminActionValue,
Boolean ConsoleEnable,
Boolean ConsoleCommandEnable,
List<String> ConsoleCommands,
Boolean ConsoleMessageEnable,
List<String> ConsoleMessages) {
this.AliasEnable = AliasEnable;
this.Perm_necessary = Perm_necessary;
this.Command_Enable = Command_Enable;
this.CommandAsConsole = CommandAsConsole;
this.Command = Command;
this.Message_Enable = Message_Enable;
this.Messages = Messages;
this.TextBuilder = TextBuilder;
this.Hover = Hover;
this.ClickEvent = ClickEvent;
this.Action = Action;
this.ActionValue = ActionValue;
this.AdminEnable = AdminEnable;
this.AdminPermission = AdminPermission;
this.AdminCommandEnable = AdminCommandEnable;
this.AdminCommandAsConsole = AdminCommandAsConsole;
this.AdminCommands = AdminCommands;
this.AdminMessageEnable = AdminMessageEnable;
this.AdminMessages = AdminMessages;
this.AdminTextBuilder = AdminTextBuilder;
this.AdminHover = AdminHover;
this.AdminClickEvent = AdminClickEvent;
this.AdminAction = AdminAction;
this.AdminActionValue = AdminActionValue;
this.ConsoleEnable = ConsoleEnable;
this.ConsoleCommandEnable = ConsoleCommandEnable;
this.ConsoleCommands = ConsoleCommands;
this.ConsoleMessageEnable = ConsoleMessageEnable;
this.ConsoleMessages = ConsoleMessages;
}
}

View File

@ -11,7 +11,7 @@ public class AliasRegister {
Plugin plugin = Main.plugin;
for (String alias : Main.allAliases) {
if (Main.aliasHashMap.get(alias) != null) {
if (Main.aliasHashMap.get(alias).AliasEnable) {
if (Main.aliasHashMap.get(alias).aliasEnable) {
Bsend.debug(plugin, "Alias register 1.18_R1");
ProxyServer.getInstance().getPluginManager().registerCommand(Main.plugin, new RegisterCommands(alias));
}