Compare commits

...

4 Commits

Author SHA1 Message Date
f8b86086db remove textBuilder and other changes 2022-07-05 20:03:22 +02:00
cf300acff1 Create SubAliasObjekt.java 2022-07-05 20:02:18 +02:00
156e5c0585 Create RegisterSubAliasCommands.java 2022-07-05 20:02:13 +02:00
f90ed13bda change config 2022-07-05 20:01:48 +02:00
13 changed files with 687 additions and 185 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>Alias</artifactId>
<version>1.0.11</version>
<version>1.1.0_DEV</version>
<packaging>jar</packaging>
<name>T2C-Alias</name>

View File

@ -1,6 +1,7 @@
package net.t2code.alias.Spigot;
import net.t2code.alias.Spigot.objects.AliasObjekt;
import net.t2code.alias.Spigot.objects.SubAliasObjekt;
import net.t2code.alias.Spigot.system.Load;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
@ -23,7 +24,9 @@ public final class Main extends JavaPlugin {
public static List<String> autor;
public static Main plugin;
public static HashMap<String, AliasObjekt> aliasHashMap = new HashMap<>();
public static HashMap<String, SubAliasObjekt> subAliasHashMap = new HashMap<>();
public static ArrayList<String> allAliases = new ArrayList<>();
public static ArrayList<String> allSubAliases = new ArrayList<>();
@Override
public void onEnable() {

View File

@ -1,23 +1,28 @@
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.objects.SubAliasObjekt;
import net.t2code.alias.Spigot.system.*;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.commands.Cmd;
import net.t2code.lib.Spigot.Lib.commands.Tab;
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.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
public class RegisterCommands extends Command {
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class RegisterCommands extends Command implements TabCompleter {
private String alias;
private String prefix = Util.getPrefix();
@ -34,51 +39,68 @@ public class RegisterCommands extends Command {
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) {
if (sender instanceof Player) {
exPlayer(sender, alias);
} else {
if (alias.consoleEnable) {
console(alias, sender, prefix);
} else send.sender(sender, SelectMessages.onlyForPlayer);
}
} else {
if (alias.consoleEnable) {
console(alias, sender, prefix);
} else send.sender(sender, SelectMessages.onlyForPlayer);
for (String sals : Main.allSubAliases) {
SubAliasObjekt sal = Main.subAliasHashMap.get(sals);
if (args.length == sal.subAliasArg) {
for (String al : sal.subAliasList) {
if (args[sal.subAliasArg].toLowerCase().equals(al)) {
RegisterSubAliasCommands.execute(sender, sal, al);
}
}
}
}
}
return true;
}
private void exPlayer(CommandSender sender, AliasObjekt alias) {
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;
}
}
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;
}
}
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;
}
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);
}
}
private static void adminCommand(AliasObjekt alias, Player player) {
for (String cmd : alias.adminCommands) {
if (alias.adminBungeeCommand) {
@ -107,21 +129,10 @@ public class RegisterCommands extends Command {
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);
}
send.player(player, text);
}
}
@ -153,21 +164,10 @@ public class RegisterCommands extends Command {
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);
}
send.player(player, text);
}
}
@ -196,5 +196,21 @@ public class RegisterCommands extends Command {
private static String replacePlayer(String s, Player player) {
return s.replace("[player]", player.getName());
}
private static HashMap<String, String> arg1 = new HashMap<String, String>();
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
List<String> list = new ArrayList<>();
arg1.clear();
for (String sals : Main.allSubAliases) {
SubAliasObjekt sal = Main.subAliasHashMap.get(sals);
for (String al : sal.subAliasList) {
arg1.put(al, "t2code.alias.use.subalias." + al.toLowerCase());
}
Tab.tab(list, sender, sal.subAliasArg, args, arg1);
}
return list;
}
}

View File

@ -0,0 +1,166 @@
package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.config.config.SelectConfig;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Spigot.objects.SubAliasObjekt;
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;
public class RegisterSubAliasCommands {
private static String prefix = Util.getPrefix();
public static void execute(CommandSender sender, SubAliasObjekt alias, String aliasString) {
if (!alias.subAliasEnable) {
send.sender(sender, SelectMessages.aliasDisabled);
return ;
}
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 ;
}
}
if (alias.permNecessary) {
if (!(player.hasPermission("t2code.alias.use.subalias." + aliasString.toLowerCase()) || player.hasPermission("t2code.alias.admin"))) {
send.player(player, SelectMessages.noPermissionForCommand.replace("[cmd]", "/" +aliasString.toLowerCase())
.replace("[perm]", "t2code.alias.subalias.use." + aliasString.toLowerCase()));
return ;
}
}
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 ;
}
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);
}
} else {
if (alias.consoleEnable) {
console(alias, sender, prefix);
} else send.sender(sender, SelectMessages.onlyForPlayer);
}
}
private static void adminCommand(SubAliasObjekt 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(SubAliasObjekt 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));
} else {
text = Replace.replace(prefix, replacePlayer(msg, player));
}
send.player(player, text);
}
}
private static void command(SubAliasObjekt 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(SubAliasObjekt 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));
} else {
text = Replace.replace(prefix, replacePlayer(msg, player));
}
send.player(player, text);
}
}
private static void console(SubAliasObjekt 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());
}
}

View File

@ -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,6 +21,8 @@ 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.Cost.Enable", false,yamlConfiguration);

View File

@ -0,0 +1,75 @@
package net.t2code.alias.Spigot.config.config;
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", Arrays.asList("aliasexample1"),yamlConfiguration);
Config.set("SubAlias.Permission.Necessary", true, 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.Message.TextBuilder.Enable", false, yamlConfiguration);
Config.set("SubAlias.Message.TextBuilder.Hover", "", yamlConfiguration);
Config.set("SubAlias.Message.TextBuilder.ClickEvent.Enable", false, yamlConfiguration);
Config.set("SubAlias.Message.TextBuilder.ClickEvent.Action", "", yamlConfiguration);
Config.set("SubAlias.Message.TextBuilder.ClickEvent.ActionValue", "", 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 hi"), yamlConfiguration);
Config.set("SubAlias.Admin.Message.Enable", false, yamlConfiguration);
Config.set("SubAlias.Admin.Message.Messages", Collections.emptyList(), yamlConfiguration);
Config.set("SubAlias.Admin.Message.TextBuilder.Enable", false, yamlConfiguration);
Config.set("SubAlias.Admin.Message.TextBuilder.Hover", "", yamlConfiguration);
Config.set("SubAlias.Admin.Message.TextBuilder.ClickEvent.Enable", false, yamlConfiguration);
Config.set("SubAlias.Admin.Message.TextBuilder.ClickEvent.Action", "", yamlConfiguration);
Config.set("SubAlias.Admin.Message.TextBuilder.ClickEvent.ActionValue", "", 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");
}
}

View File

@ -5,12 +5,18 @@ 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 net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class SelectAlias {
private static String Prefix = Util.getPrefix();
public static void onSelect() {
Main.aliasHashMap.clear();
@ -21,55 +27,57 @@ public class SelectAlias {
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"),
Boolean aliasEnable = yamlConfiguration.getBoolean("Alias.Enable");
List<String> aliasList;
if (yamlConfiguration.get("Alias.AliasList") != null) {
aliasList = yamlConfiguration.getStringList("Alias.AliasList");
} else aliasList = Collections.singletonList(config_gui.getName().toLowerCase());
yamlConfiguration.getBoolean("Alias.Cost.Enable"),
yamlConfiguration.getDouble("Alias.Cost.Price"),
yamlConfiguration.getBoolean("Alias.Cost.AllowByPass"),
Boolean permNecessary = yamlConfiguration.getBoolean("Alias.Permission.Necessary");
yamlConfiguration.getBoolean("Alias.Command.Enable"),
yamlConfiguration.getBoolean("Alias.Command.CommandAsConsole"),
yamlConfiguration.getBoolean("Alias.Command.BungeeCommand"),
yamlConfiguration.getStringList("Alias.Command.Commands"),
Boolean costEnable = yamlConfiguration.getBoolean("Alias.Cost.Enable");
Double costPrice = yamlConfiguration.getDouble("Alias.Cost.Price");
Boolean costAllowBypass = yamlConfiguration.getBoolean("Alias.Cost.AllowByPass");
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"),
Boolean commandEnable = yamlConfiguration.getBoolean("Alias.Command.Enable");
Boolean commandAsConsole = yamlConfiguration.getBoolean("Alias.Command.CommandAsConsole");
Boolean bungeeCommand = yamlConfiguration.getBoolean("Alias.Command.BungeeCommand");
List<String> command = yamlConfiguration.getStringList("Alias.Command.Commands");
yamlConfiguration.getBoolean("Alias.Admin.Enable"),
yamlConfiguration.getString("Alias.Admin.Permission"),
Boolean messageEnable = yamlConfiguration.getBoolean("Alias.Message.Enable");
List<String> messages = yamlConfiguration.getStringList("Alias.Message.Messages");
yamlConfiguration.getBoolean("Alias.Admin.Command.Enable"),
yamlConfiguration.getBoolean("Alias.Admin.Command.CommandAsConsole"),
yamlConfiguration.getBoolean("Alias.Admin.Command.BungeeCommand"),
yamlConfiguration.getStringList("Alias.Admin.Command.Commands"),
Boolean adminEnable = yamlConfiguration.getBoolean("Alias.Admin.Enable");
String adminPermission = yamlConfiguration.getString("Alias.Admin.Permission");
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"),
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<String> adminCommands = yamlConfiguration.getStringList("Alias.Admin.Command.Commands");
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();
Boolean adminMessageEnable = yamlConfiguration.getBoolean("Alias.Admin.Message.Enable");
List<String> 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<String> consoleCommands = yamlConfiguration.getStringList("Alias.Console.Command.Commands");
Boolean consoleMessageEnable = yamlConfiguration.getBoolean("Alias.Console.Message.Enable");
List<String> consoleMessages = yamlConfiguration.getStringList("Alias.Console.Message.Messages");
Main.allAliases.addAll(aliasList);
AliasObjekt alias = new AliasObjekt(aliasEnable, aliasList, permNecessary, 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);
}
}
}
AliasRegister.onRegister();
}
}

View File

@ -0,0 +1,77 @@
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.objects.SubAliasObjekt;
import net.t2code.alias.Spigot.system.AliasRegister;
import net.t2code.alias.Spigot.objects.AliasObjekt;
import net.t2code.alias.Util;
import net.t2code.lib.Spigot.Lib.messages.send;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.List;
public class SelectSubAlias {
private static String Prefix = Util.getPrefix();
public static void onSelect() {
Main.aliasHashMap.clear();
Main.allAliases.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 = YamlConfiguration.loadConfiguration(config_gui);
Boolean aliasEnable = yamlConfiguration.getBoolean("SubAlias.Enable");
List<String> subAliasList = yamlConfiguration.getStringList("SubAlias.SubAliasList");
String subAliasFor = yamlConfiguration.getString("SubAlias.SubAliasFor");
Integer subAliasArg = yamlConfiguration.getInt("SubAlias.SubAliasArg");
Boolean permNecessary = yamlConfiguration.getBoolean("SubAlias.Permission.Necessary");
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<String> command = yamlConfiguration.getStringList("SubAlias.Command.Commands");
Boolean messageEnable = yamlConfiguration.getBoolean("SubAlias.Message.Enable");
List<String> 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<String> adminCommands = yamlConfiguration.getStringList("SubAlias.Admin.Command.Commands");
Boolean adminMessageEnable = yamlConfiguration.getBoolean("SubAlias.Admin.Message.Enable");
List<String> 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<String> consoleCommands = yamlConfiguration.getStringList("SubAlias.Console.Command.Commands");
Boolean consoleMessageEnable = yamlConfiguration.getBoolean("SubAlias.Console.Message.Enable");
List<String> consoleMessages = yamlConfiguration.getStringList("SubAlias.Console.Message.Messages");
SubAliasObjekt subAlias = new SubAliasObjekt(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, 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);
}
}
}
}

View File

@ -4,23 +4,21 @@ import java.util.List;
public class AliasObjekt {
public Boolean aliasEnable;
public Boolean commandEnable;
public List<String> aliasList;
public Boolean permNecessary;
public Boolean costEnable;
public Double costPrice;
public Boolean costAllowBypass;
public Boolean commandEnable;
public Boolean commandAsConsole;
public Boolean bungeeCommand;
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;
@ -30,11 +28,6 @@ public class AliasObjekt {
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 Boolean consoleBungeeCommand;
@ -43,6 +36,7 @@ public class AliasObjekt {
public List<String> consoleMessages;
public AliasObjekt(Boolean aliasEnable,
List<String> aliasList,
Boolean permNecessary,
Boolean costEnable,
@ -55,11 +49,6 @@ public class AliasObjekt {
List<String> command,
Boolean messageEnable,
List<String> messages,
Boolean textBuilder,
String hover,
Boolean clickEvent,
String action,
String actionValue,
Boolean adminEnable,
String adminPermission,
@ -69,11 +58,6 @@ public class AliasObjekt {
List<String> adminCommands,
Boolean adminMessageEnable,
List<String> adminMessages,
Boolean adminTextBuilder,
String adminHover,
Boolean adminClickEvent,
String adminAction,
String adminActionValue,
Boolean consoleEnable,
Boolean consoleCommandEnable,
@ -82,6 +66,7 @@ public class AliasObjekt {
Boolean consoleMessageEnable,
List<String> consoleMessages) {
this.aliasEnable = aliasEnable;
this.aliasList=aliasList;
this.permNecessary = permNecessary;
this.costEnable = costEnable;
@ -94,11 +79,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 +87,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;

View File

@ -0,0 +1,106 @@
package net.t2code.alias.Spigot.objects;
import java.util.List;
public class SubAliasObjekt {
public Boolean subAliasEnable;
public List<String> subAliasList;
public Integer subAliasArg;
public String subAliasFor;
public Boolean permNecessary;
public Boolean costEnable;
public Double costPrice;
public Boolean costAllowBypass;
public Boolean commandEnable;
public Boolean commandAsConsole;
public Boolean bungeeCommand;
public List<String> command;
public Boolean messageEnable;
public List<String> messages;
public Boolean adminEnable;
public String adminPermission;
public Boolean adminCommandEnable;
public Boolean adminCommandAsConsole;
public Boolean adminBungeeCommand;
public List<String> adminCommands;
public Boolean adminMessageEnable;
public List<String> adminMessages;
public Boolean consoleEnable;
public Boolean consoleCommandEnable;
public Boolean consoleBungeeCommand;
public List<String> consoleCommands;
public Boolean consoleMessageEnable;
public List<String> consoleMessages;
public SubAliasObjekt(Boolean subAliasEnable,
List<String> subAliasList,
String subAliasFor,
Integer subAliasArg,
Boolean permNecessary,
Boolean costEnable,
Double costPrice,
Boolean costAllowBypass,
Boolean commandEnable,
Boolean commandAsConsole,
Boolean bungeeCommand,
List<String> command,
Boolean messageEnable,
List<String> messages,
Boolean adminEnable,
String adminPermission,
Boolean adminCommandEnable,
Boolean adminCommandAsConsole,
Boolean adminBungeeCommand,
List<String> adminCommands,
Boolean adminMessageEnable,
List<String> adminMessages,
Boolean consoleEnable,
Boolean consoleCommandEnable,
Boolean consoleBungeeCommand,
List<String> consoleCommands,
Boolean consoleMessageEnable,
List<String> consoleMessages) {
this.subAliasEnable = subAliasEnable;
this.subAliasList = subAliasList;
this.subAliasFor = subAliasFor;
this.subAliasArg = subAliasArg;
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.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;
}
}

View File

@ -2,14 +2,12 @@ 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.config.config.*;
import net.t2code.alias.Spigot.config.languages.LanguagesCreate;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
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.plugin.Plugin;
@ -37,24 +35,39 @@ public class Load {
CreateExampleAliasConfig.configCreate();
} catch (Exception e) {
e.printStackTrace();
}try {
CreateExampleSubAliasConfig.configCreate();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
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();
}
CreateConfig.configCreate();
LanguagesCreate.langCreate();
SelectConfig.onSelect();
SelectMessages.onSelect(Util.getPrefix());
SelectAlias.onSelect();
SelectSubAlias.onSelect();
if (SelectConfig.Bungee) {
Main.plugin.getServer().getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord");
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "t2codealias:bungee");
}
AliasRegisterPermissions.onPermRegister();
send.debugmsg(plugin,Main.aliasHashMap.toString());
send.debugmsg(plugin,Main.allAliases.toString());
send.debugmsg(plugin,Main.subAliasHashMap.toString());
send.debugmsg(plugin,Main.allSubAliases.toString());
}
}

View File

@ -7,6 +7,14 @@
Alias:
# Here you can disable the alias
Enable: true
# >>>>>> New 1.1 <<<<<< <<<<<<<<<<<<<<<<<<<<<
AliasList:
- alias1
- alias2
Permission:
# Here you can say if a permission is needed to use the alias#
# Permission: t2code.alias.use.<aliasname>
@ -37,28 +45,6 @@ Alias:
# 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: ''
# 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.
@ -89,28 +75,6 @@ Alias:
# 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: ''
Console:
# Here you can define if the alias is also usable in the console and what it should do from there.

View File

@ -0,0 +1,95 @@
####################################################################
## 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!!! ##
####################################################################
SubAlias:
# Here you can disable the alias
Enable: true
# >>>>>> New 1.1 <<<<<< <<<<<<<<<<<<<<<<<<<<<
SubAliasList:
- subalias1
SubAliasFor:
- alias1
Permission:
# Here you can say if a permission is needed to use the alias#
# Permission: t2code.subalias.use.<aliasname>
Necessary: true
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
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
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: [ ]