new config.yml and new register

This commit is contained in:
JaTiTV 2024-07-01 21:21:27 +02:00
parent 5d72e0d48d
commit b7b3fbcb03
13 changed files with 205 additions and 338 deletions

44
pom.xml
View File

@ -7,7 +7,7 @@
<groupId>net.t2code</groupId>
<artifactId>Alias</artifactId>
<version>1.5</version>
<version>1.6_DEV</version>
<!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version-->
@ -40,15 +40,19 @@
<version>3.2.4</version>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
</relocations>
</configuration>
</plugin>
</plugins>
<resources>
@ -65,19 +69,17 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<!-- Mojang authlib -->
<repository>
<id>minecraft-repo</id>
<url>https://libraries.minecraft.net/</url>
<id>paper-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url>
</repository>
<repository>
<id>Builders-Paradise</id>
<url>https://repo.t2code.net/repository/Builders-Paradise/</url>
</repository>
</repositories>
<dependencies>
@ -92,35 +94,21 @@
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.21</version>
<version>3.4.40</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>16.5</version>
<!--classifier>dev-3</classifier-->
<version>16.7</version>
<classifier>dev-1</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>bungee</artifactId>
<version>1615</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>PlugmanGUI</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -7,6 +7,7 @@ import net.t2code.alias.Spigot.system.Load;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@ -36,12 +37,11 @@ public final class Main extends JavaPlugin {
public static ArrayList<String> allSubAliases = new ArrayList<>();
public static ArrayList<String> allForSubAliases = new ArrayList<>();
// private BukkitCommandWrap bukkitCommandWrap = null;
//
// public BukkitCommandWrap getBukkitCommandWrap() {
// return this.bukkitCommandWrap;
// }
// private BukkitCommandWrap bukkitCommandWrap = null;
//
// public BukkitCommandWrap getBukkitCommandWrap() {
// return this.bukkitCommandWrap;
// }
@Override
@ -50,17 +50,28 @@ public final class Main extends JavaPlugin {
plugin = this;
autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion();
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
// try {
// Class.forName("com.mojang.brigadier.CommandDispatcher");
// this.bukkitCommandWrap = new BukkitCommandWrap();
// } catch (ClassNotFoundException | NoClassDefFoundError e) {
// this.bukkitCommandWrap = new BukkitCommandWrap_Useless();
// }
if (!Bukkit.getPluginManager().isPluginEnabled("T2CodeLib")) {
getLogger().severe("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
getLogger().severe("+ T2CodeLib ist nicht im plugins Ordner, +");
getLogger().severe("+ daher wurde es aus der eigenen Library geladen! +");
getLogger().severe("+ Es wird empfohlen die T2CodeLib als eigenes Plugin zu laden, +");
getLogger().severe("+ um keine Komplikationen mit anderen Plugins von T2Code zu bekommen! +");
getLogger().severe("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
new T2CodeLibMain().onEnable();
}
// if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; todo
// try {
// Class.forName("com.mojang.brigadier.CommandDispatcher");
// this.bukkitCommandWrap = new BukkitCommandWrap();
// } catch (ClassNotFoundException | NoClassDefFoundError e) {
// this.bukkitCommandWrap = new BukkitCommandWrap_Useless();
// }
if (T2CmcVersion.isMc1_13()) {
guiCode = "";
} else guiCode = "§6§8§9§r";
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getBstatsID());
new Load(this, Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getBstatsID());
}
@Override

View File

@ -37,7 +37,7 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
.replace("[perm]", "t2c.alias.command.reload"));
break;
case "confirm":
if (Config.buyConfirmDefault.value == Confirm.COMMAND) ExecuteAlias.storage(sender, true);
if (Config.VALUES.buyConfirmDefault.getValue() == Confirm.COMMAND) ExecuteAlias.storage(sender, true);
break;
case "cancel":
ExecuteAlias.storage(sender, false);

View File

@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands {
public static void info(CommandSender sender) {
T2Ctemplate.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
}
@ -19,7 +20,7 @@ public class Commands {
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + " §6Plugin reload...");
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
Load.loadReload();
Load.loadReload(Main.getPlugin());
if (sender instanceof Player) T2Csend.player((Player) sender, Language.reloadEnd.value);
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + " §2Plugin successfully reloaded.");

View File

@ -15,7 +15,7 @@ import net.t2code.t2codelib.SPIGOT.api.eco.T2Ceco;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -77,18 +77,18 @@ public class ExecuteAlias {
if (aliasObject.costEnable && aliasObject.costConfirm) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy." + alias.toLowerCase() + ".bypass"))) {
Cache.aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, false));
switch ((Confirm) Config.buyConfirmDefault.value) {
switch ((Confirm) Config.VALUES.buyConfirmDefault.getValue()) {
case GUI:
ConfirmGUI.open(player, aliasObject.costPrice, alias);
break;
case CHAT:
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
case COMMAND:
default:
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
}
return;
@ -117,7 +117,7 @@ public class ExecuteAlias {
if (!(player.hasPermission("t2code.alias.cooldown.player." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.cooldown.player.all.bypass"))) {
Long cooldown = aliasObject.cooldownPlayerMap.get(player.getUniqueId());
if (cooldown != null) {
Long duration = System.currentTimeMillis() - cooldown;
long duration = System.currentTimeMillis() - cooldown;
if (!(duration > (aliasObject.cooldownPlayer * 1000))) {
T2Csend.player(player, Language.cooldownPlayer.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownPlayer - (int) (duration / 1000))));
return;
@ -132,8 +132,8 @@ public class ExecuteAlias {
T2Csend.player(player, Language.noMoney.value);
return;
}
if ((Boolean) Config.buyMessage.value)
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
if ((Boolean) Config.VALUES.buyMessage.getValue())
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getPath()));
}
}
@ -180,18 +180,18 @@ public class ExecuteAlias {
if (aliasObject.costEnable && aliasObject.costConfirm) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
Cache.aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, true));
switch ((Confirm) Config.buyConfirmDefault.value) {
switch ((Confirm) Config.VALUES.buyConfirmDefault.getValue()) {
case GUI:
ConfirmGUI.open(player, aliasObject.costPrice, alias);
break;
case CHAT:
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
case COMMAND:
default:
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
}
return;
@ -211,7 +211,7 @@ public class ExecuteAlias {
if (aliasObject.cooldownGlobal != 0) {
if (!(player.hasPermission("t2c.alias.sub.cooldown.global." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.sub.cooldown.global.all.bypass"))) {
if (aliasObject.globalCooldownInt != 0) {
Long duration = System.currentTimeMillis() - aliasObject.globalCooldownInt;
long duration = System.currentTimeMillis() - aliasObject.globalCooldownInt;
if (!(duration > (aliasObject.cooldownGlobal * 1000))) {
T2Csend.player(player, Language.cooldownGlobal.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownGlobal - (int) (duration / 1000))));
return;
@ -225,7 +225,7 @@ public class ExecuteAlias {
if (!(player.hasPermission("t2c.alias.sub.cooldown.player." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.sub.cooldown.player.all.bypass"))) {
Long cooldown = aliasObject.cooldownPlayerMap.get(player.getUniqueId());
if (cooldown != null) {
Long duration = System.currentTimeMillis() - cooldown;
long duration = System.currentTimeMillis() - cooldown;
if (!(duration > (aliasObject.cooldownPlayer * 1000))) {
T2Csend.player(player, Language.cooldownPlayer.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownPlayer - (int) (duration / 1000))));
return;
@ -242,8 +242,8 @@ public class ExecuteAlias {
T2Csend.player(player, Language.noMoney.value);
return;
}
if ((Boolean) Config.buyMessage.value)
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
if ((Boolean) Config.VALUES.buyMessage.getValue())
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
}
}
if (aliasObject.commandEnable) {
@ -258,7 +258,7 @@ public class ExecuteAlias {
if (alias.consoleCommandEnable) {
for (String cmd : alias.consoleCommands) {
if (alias.consoleBungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean)T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(sender, cmd, true);
} else {
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
@ -288,7 +288,7 @@ public class ExecuteAlias {
for (String cmd : aliasObject.consoleCommands) {
String replace = cmd.replace("[target]", targetSt).replace("[alias]", alias);
if (aliasObject.consoleBungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(sender, replace, true);
} else {
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
@ -316,7 +316,7 @@ public class ExecuteAlias {
}
for (String cmd : aliasObject.adminCommands) {
if (aliasObject.adminBungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.adminCommandAsConsole);
} else {
@ -343,7 +343,7 @@ public class ExecuteAlias {
}
for (String cmd : aliasObject.adminCommands) {
if (aliasObject.adminBungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.adminCommandAsConsole);
} else {
@ -408,7 +408,7 @@ public class ExecuteAlias {
}
for (String cmd : aliasObject.command) {
if (aliasObject.bungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.commandAsConsole);
} else {
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
@ -434,7 +434,7 @@ public class ExecuteAlias {
}
for (String cmd : alias.command) {
if (alias.bungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole);
} else {

View File

@ -20,8 +20,11 @@ import java.util.logging.Level;
public class SelectAlias {
private static String Prefix = Util.getPrefix();
public static void onSelect() {
public SelectAlias(Main main){
onSelect(main);
}
private void onSelect(Main main) {
Main.aliasHashMap.clear();
Main.allAliases.clear();
@ -119,7 +122,7 @@ public class SelectAlias {
}
}
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
AliasRegister.onRegister();
new AliasRegister(main);
}
private YamlConfiguration loadFile(File file) throws InvalidConfigurationException {

View File

@ -1,44 +1,73 @@
package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.enums.ConfigParam;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.enums.Confirm;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Sound;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
public enum Config {
configVersion("configVersion", Util.getConfigVersion(), ConfigParam.INTEGER),
language("plugin.language", "english", ConfigParam.STRING),
updateCheckOnJoin("plugin.updateCheck.onJoin", true, ConfigParam.BOOLEAN),
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, ConfigParam.BOOLEAN),
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, ConfigParam.INTEGER),
import net.t2code.t2codelib.T2CconfigItem;
buyMessage("buy.message", true, ConfigParam.BOOLEAN),
buyCurrency("buy.currency", "$", ConfigParam.STRING),
buyConfirmDefault("buy.confirm.use", Confirm.COMMAND, ConfigParam.CONFIRMENUM),
buyConfirmGuiFillItemEnabled("buy.confirm.gui.fillItem.enabled", true, ConfigParam.BOOLEAN),
buyConfirmGuiFillItem("buy.confirm.gui.fillItem.material", T2CitemVersion.getBlackStainedGlassPane().getType().toString(), ConfigParam.STRING),
buyConfirmGuiConfirm("buy.confirm.gui.confirm.material", T2CitemVersion.getGreenWool().getType().toString(), ConfigParam.STRING),
buyConfirmGuiCancel("buy.confirm.gui.cancel.material", T2CitemVersion.getRedWool().getType().toString(), ConfigParam.STRING),
subAliasTab("subAlias.tabComplete", true, ConfigParam.BOOLEAN);
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public String path;
public Object value;
public Sound sound;
public ConfigParam configParam;
public class Config {
Config(String path, Object value, ConfigParam cEnum) {
this.path = path;
this.value = value;
this.configParam = cEnum;
public enum VALUES implements T2CconfigItem{
language("plugin.language", "english", "In this option you can set the language of the plugin."),
updateCheckOnJoin("plugin.updateCheck.onJoin", true,"In this option you can set if players with the permission 't2c.alias.updatemsg' will get an update message on join when an update for the plugin is available."),
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true,"In this option you can set whether you want to receive and display beta and snapshot versions in the update check."),
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60,"In this option you can set the time interval in minutes in which updates should be checked."),
buyMessage("buy.message", true,"With this option you can set whether a confirmation should be sent after the payment for an alias for which you have to pay."),
buyCurrency("buy.currency", "$","With this option you set the currency."),
buyConfirmDefault("buy.confirm.use", Confirm.COMMAND,"Here you can choose which confirmation method you want to use. (COMMAND, CHAT, GUI)"),
buyConfirmGuiFillItemDesc("buy.confirm.gui.fillItem", null," ","!! You can change the GUI name and the button texts in the language file !!"," "),
buyConfirmGuiFillItemEnabled("buy.confirm.gui.fillItem.enabled", true,"Here you can set if a fillitem should be used in the Confirm GUI."),
buyConfirmGuiFillItem("buy.confirm.gui.fillItem.material", T2CitemVersion.getBlackStainedGlassPane().getType().toString(),"Here you can set which fillitem should be used in the Confirm GUI."),
buyConfirmGuiConfirm("buy.confirm.gui.confirm.material", T2CitemVersion.getGreenWool().getType().toString(),"Here you can set the material for the confirmation button."),
buyConfirmGuiCancel("buy.confirm.gui.cancel.material", T2CitemVersion.getRedWool().getType().toString(),"Here you can set the material for the cancel button."),
subAliasTab("subAlias.tabComplete", true,"Here you can set if subcommands should be displayed as tabComplete.");
private final String path;
private Object value;
private final List<String> comments;
VALUES(String path, Object value, String... comments) {
this.path = path;
this.value = value;
this.comments = new ArrayList<>(Arrays.asList(comments));
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public List<String> getComments() {
return comments;
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
public static Sound sound() {
if (T2CmcVersion.isMc1_8()) {
return Sound.valueOf("NOTE_PIANO");
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
return Sound.valueOf("BLOCK_NOTE_HARP");
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HARP");
public static void set() {
long long_ = System.currentTimeMillis();
T2CconfigWriter.createConfig(new File(Main.getPath(), "config.yml"), VALUES.values(), Util.getConfigLogo());
T2Csend.console(Util.getPrefix() + " §2The config.yml was loaded successfully §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@ -1,98 +0,0 @@
package net.t2code.alias.Spigot.config.config;
import com.google.common.base.Preconditions;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
public class Convert {
protected static void convert() {
File path = new File(Main.getPath(),"");
File file = new File(Main.getPath(), "config.yml");
if (path.exists() && file.exists()) convertTo4();
}
private static void convertTo4() {
long long1 = System.currentTimeMillis();
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (yamlConfiguration.get(Config.configVersion.path) == null || ((Integer) Config.configVersion.value) < Util.getConfigVersion()) {
yamlConfiguration.set("ConfigVersion", null);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
File dir = new File(Main.getPath() + "/languages");
File newDir = new File(Main.getPath() + "/OldConfig/Version3/languages");
if (!dir.exists()){
return;
}
try {
FileUtils.moveDirectory(dir, newDir);
} catch (IOException e) {
e.printStackTrace();
}
File f = new File(Main.getPath() + "/OldConfig/Version3/languages/");
File[] fileArray = f.listFiles();
for (File file : fileArray) {
long long2 = System.currentTimeMillis();
String sub = file.getName().substring(file.getName().length() - 4);
if (sub.equals(".yml")) {
YamlConfiguration yamlConfigurationOld;
try {
Preconditions.checkArgument(file != null, "File cannot be null");
YamlConfiguration language = new YamlConfiguration();
language.load(file);
yamlConfigurationOld = language;
} catch (FileNotFoundException var3) {
continue;
} catch (IOException var4) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, var4);
continue;
} catch (InvalidConfigurationException var5) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, var5);
continue;
}
File newFile = new File(Main.getPath(), "languages/" + file.getName().replace("_messages.yml", "") + ".yml");
YamlConfiguration yamlConfigurationNew = YamlConfiguration.loadConfiguration(newFile);
yamlConfigurationNew.set("plugin.onlyForPlayer", yamlConfigurationOld.getString("Plugin.OnlyForPlayer"));
yamlConfigurationNew.set("plugin.aliasDisabled", yamlConfigurationOld.getString("Plugin.AliasDisabled"));
yamlConfigurationNew.set("plugin.reload.start", yamlConfigurationOld.getString("Plugin.Reload.Start"));
yamlConfigurationNew.set("plugin.reload.end", yamlConfigurationOld.getString("Plugin.Reload.End"));
yamlConfigurationNew.set("plugin.noPermissionForCommand", yamlConfigurationOld.getString("Plugin.ForCommand"));
yamlConfigurationNew.set("plugin.noSubCommand", yamlConfigurationOld.getString("Plugin.NoSubCommand"));
yamlConfigurationNew.set("cost.buy", yamlConfigurationOld.getString("Cost.Buy"));
yamlConfigurationNew.set("cost.noMoney", yamlConfigurationOld.getString("Cost.NoMoney"));
yamlConfigurationNew.set("cost.confirm.command", yamlConfigurationOld.getString("Cost.BuyConfirm"));
yamlConfigurationNew.set("cost.confirm.cancel", yamlConfigurationOld.getString("Cost.BuyCancel"));
yamlConfigurationNew.set("cost.confirm.notPossible", yamlConfigurationOld.getString("Cost.BuyConfirmNotPossible"));
try {
yamlConfigurationNew.save(newFile);
} catch (IOException e) {
T2Csend.warning(Main.getPlugin(), e.getMessage());
e.printStackTrace();
}
T2Csend.console(Util.getPrefix() + " §2The language file §6(" + newFile.getName() + ") &2was converted to the new config format §7- §e" + (System.currentTimeMillis() - long2) + "ms");
}
}
}
T2Csend.console(Util.getPrefix() + " §2All files were successfully converted. §7- §e" + (System.currentTimeMillis() - long1) + "ms");
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
}
}

View File

@ -18,63 +18,6 @@ import java.util.List;
public class FileSelect {
public static void config() {
Convert.convert();
long long_ = System.currentTimeMillis();
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Config value : Config.values()) {
switch (value.configParam) {
case STRING:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.value);
}
value.value = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
break;
case SOUND:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.sound.toString());
}
try {
value.sound = Sound.valueOf(yamlConfiguration.getString(value.path));
} catch (Exception ex) {
T2Csend.console("§4\n§4\n§4\n" + SelectLibMsg.soundNotFound.replace("[prefix]", Util.getPrefix())
.replace("[sound]", "§8" + value.path + ": §6" + yamlConfiguration.getString(value.path)) + "§4\n§4\n§4\n");
}
break;
case BOOLEAN:
case INTEGER:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.value);
}
value.value = yamlConfiguration.get(value.path);
break;
case CONFIRMENUM:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.value.toString());
}
try {
value.value = Confirm.valueOf(yamlConfiguration.getString(value.path).toUpperCase());
} catch (Exception ex) {
value.value = Confirm.COMMAND;
T2Csend.console(("[prefix] <red>The value in the <gold>config.yml</gold> at the path <gold>[path]</gold> <aqua>([value])</aqua> must be one of these values!</red>" +
" <gray>COMMAND, CHAT, GUI</gray><br>[prefix] <blue>The default option COMMAND is used!</blue>")
.replace("[prefix]", Util.getPrefix()).replace("[path]", value.path).replace("[value]", yamlConfiguration.getString(value.path)));
}
break;
}
}
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
T2Csend.console(Util.getPrefix() + " §2The config.yml was loaded successfully §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
private static ArrayList<String> defaultLanguages = new ArrayList<>(Arrays.asList("german", "english"));
public static void language() {
@ -118,18 +61,18 @@ public class FileSelect {
}
String selectMSG;
File config = new File(Main.getPath(), "languages/" + Config.language.value + ".yml");
File config = new File(Main.getPath(), "languages/" + Config.VALUES.language.getValue() + ".yml");
T2Cdebug.debug(Main.getPlugin(), config.getAbsolutePath());
if (!config.isFile()) {
T2Csend.console(Util.getPrefix());
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Util.getPrefix() + " §4The selected §c" + Config.language.value + " §4language file was not found.");
T2Csend.console(Util.getPrefix() + " §4The selected §c" + Config.VALUES.language.getPath() + " §4language file was not found.");
T2Csend.console(Util.getPrefix() + " §6The default language §eEnglish §6is used!");
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Util.getPrefix());
config = new File(Main.getPath(), "languages/" + "english.yml");
selectMSG = "english";
} else selectMSG = (String) Config.language.value;
} else selectMSG = (String) Config.VALUES.language.getValue();
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Language value : Language.values()) {
switch (value.configParam) {

View File

@ -18,14 +18,14 @@ public class ConfirmGUI {
public static void open(Player player, Double price, String alias) {
Inventory inventory = Bukkit.createInventory((InventoryHolder) null, 9 * 3, (T2Creplace.replace(Util.getPrefix(), player,
Main.getGuiCode() + Language.confirmGuiTitle.value.replace("[price]",price+ " "+Config.buyCurrency.value).replace("[alias]", alias))));
Main.getGuiCode() + Language.confirmGuiTitle.value.replace("[price]",price+ " "+Config.VALUES.buyCurrency.getValue()).replace("[alias]", alias))));
T2CitemBuilder.fillItem((boolean) Config.buyConfirmGuiFillItemEnabled.value, (String) Config.buyConfirmGuiFillItem.value, 3, inventory);
T2CitemBuilder.fillItem((boolean) Config.VALUES.buyConfirmGuiFillItemEnabled.getValue(), (String) Config.VALUES.buyConfirmGuiFillItem.getValue(), 3, inventory);
T2CitemBuilder.setItem(12, 1, (String) Config.buyConfirmGuiConfirm.value, Language.confirmGuiConfirm.value,
(List<String>) T2Creplace.replace(Language.confirmGuiConfirmLore.valueList, "[price]", price + " " + Config.buyCurrency.value), inventory);
T2CitemBuilder.setItem(14, 1, (String) Config.buyConfirmGuiCancel.value, Language.confirmGuiCancel.value,
(List<String>) T2Creplace.replace(Language.confirmGuiCancelLore.valueList, "[price]", price + " " + Config.buyCurrency.value), inventory);
T2CitemBuilder.setItem(12, 1, (String) Config.VALUES.buyConfirmGuiConfirm.getValue(), Language.confirmGuiConfirm.value,
(List<String>) T2Creplace.replace(Language.confirmGuiConfirmLore.valueList, "[price]", price + " " + Config.VALUES.buyCurrency.getValue()), inventory);
T2CitemBuilder.setItem(14, 1, (String) Config.VALUES.buyConfirmGuiCancel.getValue(), Language.confirmGuiCancel.value,
(List<String>) T2Creplace.replace(Language.confirmGuiCancelLore.valueList, "[price]", price + " " + Config.VALUES.buyCurrency.getValue()), inventory);
Cache.openPlayers.add(player.getUniqueId());
player.openInventory(inventory);
}

View File

@ -8,79 +8,47 @@ import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.entity.Player;
import org.bukkit.plugin.SimplePluginManager;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Objects;
public class AliasRegister {
public static void onRegister() {
try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
// onUnRegister(bukkitCommandMap);
for (String alias : Main.allAliases) {
register(alias, commandMap);
// wrap(alias, commandMap);
}
private Main main;
public AliasRegister (Main main){
this.main=main;
loadAliasCommands();
}
if (!(T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12())) {
// Main.getPlugin().getBukkitCommandWrap().sync();
if (Bukkit.getOnlinePlayers().size() >= 1)
for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
}
private void loadAliasCommands() {
CommandMap commandMap = getCommandMap();
} catch (Exception e) {
e.printStackTrace();
if (commandMap == null) {
main. getLogger().severe("CommandMap konnte nicht geladen werden!");
return;
}
for (String alias : Main.allAliases) {
// Registrieren des Befehls
Command dynamicCommand = new RegisterCommands(alias);
commandMap.register(main.getDescription().getName(), dynamicCommand);
T2Csend.console(Util.getPrefix() + " §aAlias §e" + alias + " §aregister");
}
}
//public static void onUnRegister(Field bukkitCommandMap) throws IllegalAccessException {
//
// // if (Main.allAliases != null && !Main.allAliases.isEmpty()) {
// // if (!(Main.getPlugin().getBukkitCommandWrap() instanceof BukkitCommandWrap_Useless)) {
// // for (String alias : Main.allAliases) {
// // T2Csend.debugmsg(Main.getPlugin(),"uload: " + alias);
// // Main.getPlugin().
// // Main.getPlugin().getBukkitCommandWrap().unwrap(alias);
// // }
// // Main.getPlugin().getBukkitCommandWrap().sync();
// // if (Bukkit.getOnlinePlayers().size() >= 1)
// // for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
// // }
// // }
// // commandMap.clearCommands();
//
//
// for (Map.Entry<String, Boolean> entry : Main.loadAliasHashMap.entrySet()) {
// ((SimpleCommandMap) bukkitCommandMap.get(simplePluginManager)).getCommand(entry.getKey()).unregister(bukkitCommandMap.get(Bukkit.getServer()));
//
//
// if (entry.getValue())
// Main.getPlugin().getBukkitCommandWrap().unwrap(entry.getKey());
// }
//
// Main.getPlugin().getBukkitCommandWrap().sync();
// if (Bukkit.getOnlinePlayers().size() >= 1)
// for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
// Main.loadAliasHashMap.clear();
//
//}
private static void register(String alias, CommandMap commandMap) {
if (Main.aliasHashMap.get(alias) != null) {
if (alias.equals(" ")) return;
if (Main.aliasHashMap.get(alias).aliasEnable) {
commandMap.register(alias, new RegisterCommands(alias));
T2Csend.console(Util.getPrefix() + " §aAlias §e" + alias + " §aregister");
Main.loadAliasHashMap.put(alias, true);
} else Main.loadAliasHashMap.put(alias, false);
} else T2Csend.warning(Main.getPlugin(), " §4AliasHashmap is null! - " + alias);
private CommandMap getCommandMap() {
if (main.getServer().getPluginManager() instanceof SimplePluginManager) {
SimplePluginManager manager = (SimplePluginManager) main.getServer().getPluginManager();
try {
Field field = SimplePluginManager.class.getDeclaredField("commandMap");
field.setAccessible(true);
return (CommandMap) field.get(manager);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}

View File

@ -16,7 +16,7 @@ import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
@ -26,12 +26,16 @@ import java.util.List;
public class Load {
private static final Main plugin = Main.getPlugin();
public static void onLoad(String prefix, List<String> autor, String version, String spigot, String discord, int bstatsID) {
public Load (Main main,String prefix, List<String> autor, String version, String spigot, String discord, int bstatsID){
onLoad(main, prefix, autor, version, spigot, discord, bstatsID);
}
private void onLoad(Main main,String prefix, List<String> autor, String version, String spigot, String discord, int bstatsID) {
Long long_ = T2Ctemplate.onLoadHeader(prefix, autor, version, spigot, discord);
plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter());
loadReload();
loadReload(main);
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(),
(Boolean) Config.updateCheckOnJoin.value, (Boolean) Config.updateCheckSeePreReleaseUpdates.value, (Integer) Config.updateCheckTimeInterval.value);
(Boolean) Config.VALUES.updateCheckOnJoin.getValue(), (Boolean) Config.VALUES.updateCheckSeePreReleaseUpdates.getValue(), (Integer) Config.VALUES.updateCheckTimeInterval.getValue());
T2Ctemplate.onLoadFooter(prefix, long_);
T2Cregister.listener(new PluginEvents(), plugin);
@ -41,11 +45,11 @@ public class Load {
private static ChatConfirm chatListener;
private static GuiListener guiListener;
public static void loadReload() {
public static void loadReload(Main main) {
HandlerList.unregisterAll(chatListener);
HandlerList.unregisterAll(guiListener);
boolean newInstall = !new File(Main.getPath(), "config.yml").exists();
FileSelect.config();
Config.set();
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
FileSelect.language();
if (newInstall) {
@ -66,12 +70,13 @@ public class Load {
} catch (Exception e) {
e.printStackTrace();
}
/**
try {
plugin.saveResource("X_configDeclaration_X.yml", true);
} catch (Exception e) {
e.printStackTrace();
}
*/
try {
plugin.saveResource("SubAlias/X_subAliasDeclaration_X.yml", true);
@ -80,17 +85,17 @@ public class Load {
}
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
SelectAlias.onSelect();
new SelectAlias(main);
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
SelectSubAlias.onSelect();
if ((Boolean) Config.subAliasTab.value) {
if ((Boolean) Config.VALUES.subAliasTab.getValue()) {
T2Cregister.listener(new TabEvent(), plugin);
}
chatListener = new ChatConfirm();
if (Config.buyConfirmDefault.value == Confirm.CHAT) T2Cregister.listener(chatListener, plugin);
if (Config.VALUES.buyConfirmDefault.getValue() == Confirm.CHAT) T2Cregister.listener(chatListener, plugin);
guiListener = new GuiListener();
if (Config.buyConfirmDefault.value == Confirm.GUI) T2Cregister.listener(guiListener, plugin);
if (T2CLibConfig.getBungee()) {
if (Config.VALUES.buyConfirmDefault.getValue() == Confirm.GUI) T2Cregister.listener(guiListener, plugin);
if ((boolean)T2CLibConfig.VALUES.proxy.getValue()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
}
AliasRegisterPermissions.onPermRegister();

View File

@ -1,5 +1,7 @@
package net.t2code.alias;
import lombok.Getter;
public class Util {
@ -8,7 +10,7 @@ public class Util {
}
public static String getRequiredT2CodeLibVersion() {
return "15.7";
return "16.7";
}
public static String getPrefix() {
@ -41,7 +43,22 @@ public class Util {
private static String prefix = "§8[§4T2Code§7-§aAlias§8]";
public static Integer getConfigVersion() {
return 4;
}
@Getter
private static final String[] configLogo = new String[]{
"####################################################################################################################",
"## ##",
"## /$$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ ##",
"## |__ $$__//$$__ $$ /$$__ $$ | $$ | $$ ##",
"## | $$ |__/ \\ $$| $$ \\__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ ##",
"## | $$ /$$$$$$/| $$ /$$__ $$ /$$__ $$ /$$__ $$ | $$__ $$ /$$__ $$|_ $$_/ ##",
"## | $$ /$$____/ | $$ | $$ \\ $$| $$ | $$| $$$$$$$$ | $$ \\ $$| $$$$$$$$ | $$ ##",
"## | $$ | $$ | $$ $$| $$ | $$| $$ | $$| $$_____/ | $$ | $$| $$_____/ | $$ /$$ ##",
"## | $$ | $$$$$$$$| $$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$ /$$| $$ | $$| $$$$$$$ | $$$$/ ##",
"## |__/ |________/ \\______/ \\______/ \\_______/ \\_______/|__/|__/ |__/ \\_______/ \\___/ ##",
"## ##",
"## T2CodeLib from JaTiTV / T2Code.net. In case of problems please contact the Discord: https://dc.t2code.net ##",
"## ##",
"####################################################################################################################"
};
}