change config

This commit is contained in:
JaTiTV 2022-07-05 20:01:48 +02:00
parent 61f8a713f3
commit f90ed13bda
7 changed files with 306 additions and 84 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

@ -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

@ -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: [ ]