1.2.3_beta-1

This commit is contained in:
JaTiTV 2023-07-08 21:30:45 +02:00
parent b5f3737fbd
commit fd0db6939a
27 changed files with 633 additions and 438 deletions

11
pom.xml
View File

@ -7,7 +7,7 @@
<groupId>net.t2code</groupId>
<artifactId>Alias</artifactId>
<version>1.2.2</version>
<version>1.2.3_beta-1</version>
<packaging>jar</packaging>
<name>T2C-Alias</name>
@ -71,7 +71,8 @@
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>15.4</version>
<version>15.6</version>
<classifier>dev-3</classifier>
<scope>provided</scope>
</dependency>
<dependency>
@ -92,5 +93,11 @@
<version>1.13r1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,12 @@
package net.t2code.alias.Spigot;
import net.t2code.alias.Spigot.objects.AliasStorageObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
public class Cache {
public static ArrayList<UUID> openPlayers = new ArrayList<UUID>();
public static HashMap<UUID, AliasStorageObject> aliasStorage = new HashMap<>();
}

View File

@ -1,5 +1,6 @@
package net.t2code.alias.Spigot;
import lombok.Getter;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.Spigot.system.BukkitCommandWrap;
@ -7,6 +8,7 @@ import net.t2code.alias.Spigot.system.BukkitCommandWrap_Useless;
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 org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@ -21,9 +23,14 @@ public final class Main extends JavaPlugin {
return plugin.getDataFolder();
}
@Getter
private static String version;
@Getter
private static List<String> autor;
@Getter
private static Main plugin;
@Getter
private static String guiCode;
public static HashMap<String, AliasObject> aliasHashMap = new HashMap<>();
public static HashMap<String, Boolean> loadAliasHashMap = new HashMap<>();
public static HashMap<String, SubAliasObject> subAliasHashMap = new HashMap<>();
@ -31,6 +38,14 @@ 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;
}
@Override
public void onEnable() {
// Plugin startup logic
@ -44,6 +59,9 @@ public final class Main extends JavaPlugin {
} 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());
}
@ -88,22 +106,4 @@ public final class Main extends JavaPlugin {
return false;
}
}
public static Main getPlugin() {
return plugin;
}
public static String getVersion() {
return version;
}
public static List<String> getAutor() {
return autor;
}
private BukkitCommandWrap bukkitCommandWrap = null;
public BukkitCommandWrap getBukkitCommandWrap() {
return this.bukkitCommandWrap;
}
}

View File

@ -1,6 +1,8 @@
package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Spigot.config.config.Config;
import net.t2code.alias.Spigot.config.config.Language;
import net.t2code.alias.Spigot.enums.Confirm;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -23,7 +25,7 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
// Command
if (sender.hasPermission("t2code.alias.command.info")) {
Commands.info(sender);
} else T2Csend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info"));
} else {
switch (args[0].toLowerCase()) {
@ -31,11 +33,11 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
case "rl":
if (sender.hasPermission("t2code.alias.command.reload") || sender.isOp()) {
Commands.reload(sender);
} else T2Csend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias reload")
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias reload")
.replace("[perm]", "t2code.alias.command.reload"));
break;
case "confirm":
ExecuteAlias.storage(sender, true);
if (Config.buyConfirmDefault.value == Confirm.COMMAND) ExecuteAlias.storage(sender, true);
break;
case "cancel":
ExecuteAlias.storage(sender, false);
@ -45,7 +47,7 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
case "version":
if (sender.hasPermission("t2code.alias.command.info")) {
Commands.info(sender);
} else T2Csend.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info"));
break;

View File

@ -1,7 +1,7 @@
package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Spigot.config.config.Language;
import net.t2code.alias.Spigot.system.Load;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
@ -15,12 +15,12 @@ public class Commands {
}
public static void reload(CommandSender sender) {
if (sender instanceof Player) T2Csend.player((Player) sender, SelectMessages.reloadStart);
if (sender instanceof Player) T2Csend.player((Player) sender, Language.reloadStart.value);
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + " §6Plugin reload...");
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
Load.loadReload();
if (sender instanceof Player) T2Csend.player((Player) sender, SelectMessages.reloadEnd);
if (sender instanceof Player) T2Csend.player((Player) sender, Language.reloadEnd.value);
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
T2Csend.console(Util.getPrefix() + "§8-------------------------------");

View File

@ -1,7 +1,10 @@
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.Cache;
import net.t2code.alias.Spigot.config.config.Config;
import net.t2code.alias.Spigot.config.config.Language;
import net.t2code.alias.Spigot.confirm.gui.ConfirmGUI;
import net.t2code.alias.Spigot.enums.Confirm;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.AliasStorageObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
@ -17,30 +20,26 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
public class ExecuteAlias {
public static HashMap<UUID, AliasStorageObject> aliasStorage = new HashMap<>();
private static final String prefix = Util.getPrefix();
protected static void storage(CommandSender sender, boolean confirm) {
public static void storage(CommandSender sender, boolean confirm) {
Player player = (Player) sender;
if (!aliasStorage.containsKey(player.getUniqueId())) {
T2Csend.player(player, SelectMessages.buyConfirmNotPossible);
if (!Cache.aliasStorage.containsKey(player.getUniqueId())) {
T2Csend.player(player, Language.confirmNotPossible.value);
return;
}
AliasStorageObject object = aliasStorage.get(player.getUniqueId());
aliasStorage.remove(player.getUniqueId());
AliasStorageObject object = Cache.aliasStorage.get(player.getUniqueId());
Cache.aliasStorage.remove(player.getUniqueId());
if (!confirm) {
T2Csend.player(player, SelectMessages.buyCancel);
T2Csend.player(player, Language.confirmCancel.value);
return;
}
@ -68,7 +67,7 @@ public class ExecuteAlias {
if (!(player.hasPermission(aliasObject.permission.replace("<alias>", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) {
String npmsg;
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
npmsg = SelectMessages.noPermissionForCommand;
npmsg = Language.noPermission.value;
} else npmsg = aliasObject.permissionMSG;
T2Csend.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
.replace("[perm]", aliasObject.permission.replace("<alias>", alias.toLowerCase())).replace("[alias]", alias));
@ -77,8 +76,21 @@ public class ExecuteAlias {
}
if (aliasObject.costEnable && aliasObject.costConfirm) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
T2Csend.player(player, SelectMessages.buyConfirm.replace("[price]", aliasObject.costPrice.toString() + " " + SelectConfig.getBuyCurrency()));
aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, false));
Cache.aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, false));
switch ((Confirm) Config.buyConfirmDefault.value) {
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));
break;
case COMMAND:
default:
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
break;
}
return;
}
}
@ -90,11 +102,11 @@ public class ExecuteAlias {
if (aliasObject.costEnable) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
if (!T2Ceco.moneyRemove(prefix, player, aliasObject.costPrice)) {
T2Csend.player(player, SelectMessages.noMoney);
T2Csend.player(player, Language.noMoney.value);
return;
}
if (SelectConfig.getBuyMessage())
T2Csend.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString() + " " + SelectConfig.getBuyCurrency()));
if ((Boolean) Config.buyMessage.value)
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
}
}
if (aliasObject.commandEnable) {
@ -107,7 +119,7 @@ public class ExecuteAlias {
protected static void subAliasPlayer(CommandSender sender, SubAliasObject aliasObject, String alias, String[] args) {
if (!aliasObject.subAliasEnable) {
T2Csend.sender(sender, SelectMessages.aliasDisabled);
T2Csend.sender(sender, Language.aliasDisabled.value);
return;
}
@ -130,7 +142,7 @@ public class ExecuteAlias {
if (!(player.hasPermission(aliasObject.permission.replace("<alias>", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) {
String npmsg;
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
npmsg = SelectMessages.noPermissionForCommand;
npmsg = Language.noPermission.value;
} else npmsg = aliasObject.permissionMSG;
T2Csend.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
.replace("[perm]", aliasObject.permission.replace("<alias>", alias.toLowerCase())).replace("[alias]", alias));
@ -139,8 +151,21 @@ public class ExecuteAlias {
}
if (aliasObject.costEnable && aliasObject.costConfirm) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
T2Csend.player(player, SelectMessages.buyConfirm.replace("[price]", aliasObject.costPrice.toString() + " " + SelectConfig.getBuyCurrency()));
aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, true));
Cache.aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, true));
switch ((Confirm) Config.buyConfirmDefault.value) {
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));
break;
case COMMAND:
default:
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
break;
}
return;
}
}
@ -149,7 +174,7 @@ public class ExecuteAlias {
} else {
if (aliasObject.consoleEnable) {
subAliasConsole(aliasObject, alias, sender, args);
} else T2Csend.sender(sender, SelectMessages.onlyForPlayer);
} else T2Csend.sender(sender, Language.onlyForPlayer.value);
}
}
@ -157,11 +182,11 @@ public class ExecuteAlias {
if (aliasObject.costEnable) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
if (!T2Ceco.moneyRemove(prefix, player, aliasObject.costPrice)) {
T2Csend.player(player, SelectMessages.noMoney);
T2Csend.player(player, Language.noMoney.value);
return;
}
if (SelectConfig.getBuyMessage())
T2Csend.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString() + " " + SelectConfig.getBuyCurrency()));
if ((Boolean) Config.buyMessage.value)
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
}
}
if (aliasObject.commandEnable) {

View File

@ -1,20 +1,15 @@
package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.languages.SelectMessages;
import net.t2code.alias.Spigot.config.config.Language;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class RegisterCommands extends Command {
private String alias;
private String prefix = Util.getPrefix();
@ -33,7 +28,7 @@ public class RegisterCommands extends Command {
return false;
}
if (!alias.aliasEnable) {
T2Csend.sender(sender, SelectMessages.aliasDisabled);
T2Csend.sender(sender, Language.aliasDisabled.value);
return true;
}
if (args.length == 0 || args.length == 1 && args[0].contains("-p:")) {
@ -42,7 +37,7 @@ public class RegisterCommands extends Command {
} else {
if (alias.consoleEnable) {
ExecuteAlias.aliasConsole(alias, sender, prefix);
} else T2Csend.sender(sender, SelectMessages.onlyForPlayer);
} else T2Csend.sender(sender, Language.onlyForPlayer.value);
}
} else {
if (!Main.allForSubAliases.contains(this.alias)) {
@ -59,7 +54,7 @@ public class RegisterCommands extends Command {
}
}
}
T2Csend.sender(sender, SelectMessages.noSubCommand);
T2Csend.sender(sender, Language.noSubCommand.value);
}
return true;
}

View File

@ -0,0 +1,45 @@
package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.enums.ConfigParam;
import net.t2code.alias.Spigot.enums.Confirm;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemBuilder;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Sound;
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),
buyMessage("buy.message", true, ConfigParam.BOOLEAN),
buyCurrency("buy.currency", "$", ConfigParam.STRING),
buyConfirmDefault("buy.confirm.default", 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);
public String path;
public Object value;
public Sound sound;
public ConfigParam configParam;
Config(String path, Object value, ConfigParam cEnum) {
this.path = path;
this.value = value;
this.configParam = cEnum;
}
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");
}
}

View File

@ -0,0 +1,99 @@
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 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() {
convertTo4();
}
private static void convertTo4() {
// File dir = new File(Main.getPath(), "languages");
// File newDir = new File(Main.getPath() + "/languages/old/configVersion3");
//
// try {
// FileUtils.moveDirectory(dir, newDir);
// } catch (IOException e) {
// e.printStackTrace();
// }
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() && new File(Main.getPath(), "config.yml").exists()) {
System.out.println("convert");
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");
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) {
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();
}
}
}
} else System.out.println("not convert");
}
}

View File

@ -1,67 +0,0 @@
package net.t2code.alias.Spigot.config.config;
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.yaml.T2Cconfig;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class CreateConfig {
public static void configCreate() {
long long_ = System.currentTimeMillis();
if (new File(Main.getPath(), "config.yml").exists()) {
if (Main.getPlugin().getConfig().getBoolean("Plugin.Debug")) T2Csend.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else T2Csend.console(Util.getPrefix() + " §4config.yml are created...");
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
T2Cconfig.set("plugin.language", "english", yamlConfiguration);
T2Cconfig.set("plugin.updateCheck.onJoin", true, yamlConfiguration);
T2Cconfig.set("plugin.updateCheck.seePreReleaseUpdates", true, yamlConfiguration);
T2Cconfig.set("plugin.updateCheck.timeInterval", 60, yamlConfiguration);
T2Cconfig.set("buy.message", true, yamlConfiguration);
T2Cconfig.set("buy.currency", "$", yamlConfiguration);
T2Cconfig.set("subAlias.tabComplete", true, yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
T2Csend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
private static void convert() {
File configOld = new File(Main.getPath(), "config.yml");
configOld.renameTo(new File(Main.getPath(), "configV3.yml"));
configOld = new File(Main.getPath(), "configV3.yml");
YamlConfiguration yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld);
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
T2Cconfig.set("plugin.language", yamlConfigurationOld.getString("Plugin.language"), yamlConfiguration);
T2Cconfig.set("plugin.updateCheck.onJoin", yamlConfigurationOld.getBoolean("Plugin.updateCheck.onJoin"), yamlConfiguration);
T2Cconfig.set("plugin.updateCheck.seePreReleaseUpdates", yamlConfigurationOld.getBoolean("Plugin.updateCheck.seePreReleaseUpdates"), yamlConfiguration);
T2Cconfig.set("plugin.updateCheck.timeInterval", yamlConfigurationOld.getInt("Plugin.updateCheck.timeInterval"), yamlConfiguration);
T2Cconfig.set("buy.message", yamlConfigurationOld.getBoolean("Buy.Message"), yamlConfiguration);
T2Cconfig.set("subAlias.tabComplete", yamlConfigurationOld.getBoolean("SubAlias.TabComplete"), yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
configCreate();
}
}

View File

@ -0,0 +1,147 @@
package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.enums.Confirm;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FileSelect {
public static void config() {
Convert.convert();
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();
}
}
private static ArrayList<String> defaultLanguages = new ArrayList<>(Arrays.asList("german", "english"));
public static void language() {
long long_ = System.currentTimeMillis();
for (String language : defaultLanguages) {
File config = new File(Main.getPath(), "languages/" + language + ".yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Language value : Language.values()) {
if (!yamlConfiguration.contains(value.path)) {
switch (value.configParam) {
case STRING:
switch (language) {
case "german":
yamlConfiguration.set(value.path, value.german);
break;
case "english":
yamlConfiguration.set(value.path, value.english);
break;
}
break;
case LIST:
switch (language) {
case "german":
yamlConfiguration.set(value.path, value.germanList);
break;
case "english":
yamlConfiguration.set(value.path, value.englishList);
break;
}
break;
}
}
}
T2Cdebug.debug(Main.getPlugin(), "save: " + language);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
String selectMSG;
File config = new File(Main.getPath(), "languages/" + Config.language.value + ".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() + " §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;
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Language value : Language.values()) {
switch (value.configParam) {
case STRING:
T2Cdebug.debug(Main.getPlugin(), "Select: File: " + config.getName() + " Path: " + value.path);
value.value = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
break;
case LIST:
T2Cdebug.debug(Main.getPlugin(), "Select: File: " + config.getName() + " Path: " + value.path);
value.valueList = T2Creplace.replace(Util.getPrefix(), (List<String>) yamlConfiguration.getList(value.path));
break;
}
}
T2Csend.console(Util.getPrefix() + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@ -0,0 +1,71 @@
package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.enums.ConfigParam;
import java.util.Arrays;
import java.util.List;
public enum Language {
onlyForPlayer("plugin.onlyForPlayer", null, "[prefix] <red>Dieser Command ist nur f[ue]r Spieler!</red>",
"[prefix] <red>This command is for players only!</red>", ConfigParam.STRING),
aliasDisabled("plugin.aliasDisabled", null, "Unknown command. Type ''/help'' for help.",
"Unknown command. Type ''/help'' for help.", ConfigParam.STRING),
reloadStart("plugin.reload.start", null, "[prefix] <gold>Plugin wird neu geladen...</gold>",
"[prefix] <gold>Plugin is reloaded...</gold>", ConfigParam.STRING),
reloadEnd("plugin.reload.end", null, "[prefix] <dark_green>Plugin wurde erfolgreich neu geladen.</dark_green>",
"[prefix] <dark_green>Plugin was successfully reloaded.</dark_green>", ConfigParam.STRING),
noPermission("plugin.noPermissionForCommand", null, "[prefix] <red>F[ue]r <aqua>[cmd]</aqua> fehlt dir die Permission <gold>[perm]</gold>!</red>",
"[prefix] <red>For <aqua>[cmd]</aqua> you lack the permission <gold>[perm]</gold>!</red>", ConfigParam.STRING),
noSubCommand("plugin.noSubCommand", null, "[prefix] <red>Diesen Befehl gibt es nicht!</red>",
"[prefix] <red>This command does not exist!</red>", ConfigParam.STRING),
buy("cost.buy", null, "[prefix] <dark_green>Du hast f[ue]r diesen Command <gold>[price]</gold> bezahlt.</dark_green>",
"[prefix] <dark_green>You have paid <gold>[price]</gold> for this command.</dark_green>", ConfigParam.STRING),
noMoney("cost.noMoney", null, "[prefix] <red>Du hast nicht gen[ue]gend Geld für diesen Command!</red>", "[prefix] <red>You don't have enough money for this command!</red>", ConfigParam.STRING),
confirmCommand("cost.confirm.command", null, "[prefix] <gold>Für diesen Befehl musst du [price] bezahlen!</gold><br>[prefix] <green><click:run_command:'/t2c-a confirm'><hover:show_text:'<gray>Klicke zum bestätigen</gray>'>Bestätigen</hover></click></green> <gray>-</gray> <red><click:run_command:'/t2c-a cancel'><hover:show_text:'<gray>Klicke zum abbrechen</gray>'>Abbrechen</hover></click></red>",
"[prefix] <gold>For this command you have to pay [price]!</gold><br>[prefix] <green><click:run_command:'/t2c-a confirm'><hover:show_text:'<gray>Click to confirm</gray>'>Confirm</hover></click></green> <gray>-</gray> <red><click:run_command:'/t2c-a cancel'><hover:show_text:'<gray>click to cancel</gray>'>Cancel</hover></click></red>", ConfigParam.STRING),
confirmChat("cost.confirm.chat", null, "[prefix] <gold>Für diesen Befehl musst du [price] bezahlen!</gold><br>[prefix] <green><click:run_command:'t2code-alias-confirm'><hover:show_text:'<gray>Klicke zum bestätigen</gray>'>Bestätigen</hover></click></green> <gray>-</gray> <red><click:run_command:'t2code-alias-cancel'><hover:show_text:'<gray>Klicke zum abbrechen</gray>'>Abbrechen</hover></click></red>",
"[prefix] <gold>For this command you have to pay [price]!</gold><br>[prefix] <green><click:run_command:'t2code-alias-confirm'><hover:show_text:'<gray>Click to confirm</gray>'>Confirm</hover></click></green> <gray>-</gray> <red><click:run_command:'t2code-alias-cancel'><hover:show_text:'<gray>click to cancel</gray>'>Cancel</hover></click></red>", ConfigParam.STRING),
confirmGuiTitle("cost.confirm.gui.title", null, "&2Bestätige den Zahlvorgang für: &6/[alias]", "Confirm the payment process for: &6/[alias]", ConfigParam.STRING),
confirmGuiConfirm("cost.confirm.gui.confirm.displayName", null, "&2Bestätigen", "&2Confirm", ConfigParam.STRING),
confirmGuiConfirmLore("cost.confirm.gui.confirm.lore", null, Arrays.asList("&aDieser Befehl kostet", "&6[price]"),
Arrays.asList("&aThis command costs","&6[price]"), ConfigParam.LIST),
confirmGuiCancel("cost.confirm.gui.cancel.displayName", null, "&cAbbrechen", "&cCancel", ConfigParam.STRING),
confirmGuiCancelLore("cost.confirm.gui.cancel.lore", null, Arrays.asList(""), Arrays.asList(""), ConfigParam.LIST),
confirmCancel("cost.confirm.cancel", null, "[prefix] <gold>Der befehl wurde abgebrochen und du musst nichts bezahlen!</gold>",
"[prefix] <gold>The command was canceled and you do not have to pay anything!</gold>", ConfigParam.STRING),
confirmNotPossible("cost.confirm.notPossible", null, "[prefix] <gold>Bestätigen nicht möglich, du hast keinen bezahlungspflichtigen befehl ausgeführt.</gold>",
"[prefix] <gold>Confirmation not possible, you have not executed a payable command.</gold>", ConfigParam.STRING);
public String path;
public String value;
public List<String> valueList;
public String german;
public List<String> germanList;
public String english;
public List<String> englishList;
public ConfigParam configParam;
Language(String path, String value, String german, String english, ConfigParam cEnum) {
this.path = path;
this.value = value;
this.german = german;
this.english = english;
this.configParam = cEnum;
}
Language(String path, List<String> valueList, List<String> german, List<String> english, ConfigParam cEnum) {
this.path = path;
this.valueList = valueList;
this.germanList = german;
this.englishList = english;
this.configParam = cEnum;
}
}

View File

@ -1,85 +0,0 @@
package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.Main;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class SelectConfig {
private static Integer ConfigVersion = 3;
private static Integer isConfigVersion;
private static Boolean updateCheckOnJoin;
private static Boolean updateCheckSeePreReleaseUpdates;
private static Integer updateCheckTimeInterval;
private static String language;
private static Boolean buyMessage;
private static String buyCurrency;
private static Boolean subAliasTab;
public static void onSelect() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
isConfigVersion = yamlConfiguration.getInt("ConfigVersion");
updateCheckOnJoin = yamlConfiguration.getBoolean("plugin.updateCheck.onJoin");
updateCheckSeePreReleaseUpdates = yamlConfiguration.getBoolean("plugin.updateCheck.seePreReleaseUpdates");
updateCheckTimeInterval = yamlConfiguration.getInt("plugin.updateCheck.timeInterval");
language = yamlConfiguration.getString("plugin.language");
buyMessage = yamlConfiguration.getBoolean("buy.message");
buyCurrency = yamlConfiguration.getString("buy.currency");
subAliasTab = yamlConfiguration.getBoolean("subAlias.tabComplete");
}
public static void setConfigVersion() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
yamlConfiguration.set("ConfigVersion", ConfigVersion);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
public static Integer getConfigVersion() {
return ConfigVersion;
}
public static Integer getIsConfigVersion() {
return isConfigVersion;
}
public static Boolean getUpdateCheckOnJoin() {
return updateCheckOnJoin;
}
public static Boolean getUpdateCheckSeePreReleaseUpdates() {
return updateCheckSeePreReleaseUpdates;
}
public static Integer getUpdateCheckTimeInterval() {
return updateCheckTimeInterval;
}
public static String getLanguage() {
return language;
}
public static Boolean getBuyMessage() {
return buyMessage;
}
public static String getBuyCurrency() {
return buyCurrency;
}
public static Boolean getSubAliasTab() {
return subAliasTab;
}
}

View File

@ -1,81 +0,0 @@
package net.t2code.alias.Spigot.config.languages;
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.yaml.T2Cconfig;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class LanguagesCreate {
public static void langCreate() {
T2Csend.debug(Main.getPlugin(),"§4Language files are created / updated...");
long long_ = System.currentTimeMillis();
/**
*
* ENGLISH
*
*/
File messagesEN = new File(Main.getPath(), "languages/english_messages.yml");
YamlConfiguration yamlConfigurationEN = YamlConfiguration.loadConfiguration(messagesEN);
T2Cconfig.set("Plugin.OnlyForPlayer", MSG.EN_OnlyForPlayer, yamlConfigurationEN);
T2Cconfig.set("Plugin.AliasDisabled", MSG.EN_Disabled, yamlConfigurationEN);
T2Cconfig.set("Plugin.Reload.Start", MSG.EN_ReloadStart, yamlConfigurationEN);
T2Cconfig.set("Plugin.Reload.End", MSG.EN_ReloadEnd, yamlConfigurationEN);
T2Cconfig.set("Plugin.ForCommand", MSG.EN_NoPermissionForCommand, yamlConfigurationEN);
T2Cconfig.set("Plugin.NoSubCommand", MSG.EN_NoSubCommand, yamlConfigurationEN);
T2Cconfig. set("Cost.Buy", MSG.EN_Buy, yamlConfigurationEN);
T2Cconfig. set("Cost.BuyConfirm", MSG.EN_BuyConfirm, yamlConfigurationEN);
T2Cconfig. set("Cost.BuyCancel", MSG.EN_BuyCancel, yamlConfigurationEN);
T2Cconfig. set("Cost.BuyConfirmNotPossible", MSG.EN_BuyConfirmNotPossible, yamlConfigurationEN);
T2Cconfig.set("Cost.NoMoney", MSG.EN_NoMoney, yamlConfigurationEN);
try {
yamlConfigurationEN.save(messagesEN);
} catch (IOException e) {
T2Csend.warning(Main.getPlugin(),e.getMessage());
e.printStackTrace();
}
/**
*
* GERMAN
*
*/
File messagesDE = new File(Main.getPath(), "languages/german_messages.yml");
YamlConfiguration yamlConfigurationDE = YamlConfiguration.loadConfiguration(messagesDE);
T2Cconfig.set("Plugin.OnlyForPlayer", MSG.DE_OnlyForPlayer, yamlConfigurationDE);
T2Cconfig.set("Plugin.AliasDisabled", MSG.DE_Disabled, yamlConfigurationDE);
T2Cconfig.set("Plugin.Reload.Start", MSG.DE_ReloadStart, yamlConfigurationDE);
T2Cconfig.set("Plugin.Reload.End", MSG.DE_ReloadEnd, yamlConfigurationDE);
T2Cconfig.set("Plugin.ForCommand", MSG.DE_NoPermissionForCommand, yamlConfigurationDE);
T2Cconfig.set("Plugin.NoSubCommand", MSG.DE_NoSubCommand, yamlConfigurationDE);
T2Cconfig.set("Cost.Buy", MSG.DE_Buy, yamlConfigurationDE);
T2Cconfig.set("Cost.BuyConfirm", MSG.DE_BuyConfirm, yamlConfigurationDE);
T2Cconfig.set("Cost.BuyCancel", MSG.DE_BuyCancel, yamlConfigurationDE);
T2Cconfig.set("Cost.BuyConfirmNotPossible", MSG.DE_BuyConfirmNotPossible, yamlConfigurationDE);
T2Cconfig.set("Cost.NoMoney", MSG.DE_NoMoney, yamlConfigurationDE);
try {
yamlConfigurationDE.save(messagesDE);
} catch (IOException e) {
T2Csend.warning(Main.getPlugin(),e.getMessage());
e.printStackTrace();
}
T2Csend.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@ -1,55 +0,0 @@
// This claas was created by JaTiTV
// -----------------------------
// _____ _____ _ _ _____
// / ____/ ____| | | |_ _|
// | | | | __| | | | | |
// | | | | |_ | | | | | |
// | |___| |__| | |__| |_| |_
// \_____\_____|\____/|_____|
// -----------------------------
package net.t2code.alias.Spigot.config.languages;
public class MSG {
// EN
public static String EN_OnlyForPlayer = "[prefix] <red>This command is for players only!</red>";
public static String EN_Disabled = "Unknown command. Type ''/help'' for help.";
public static String EN_ReloadStart = "[prefix] <gold>Plugin is reloaded...</gold>";
public static String EN_ReloadEnd = "[prefix] <dark_green>Plugin was successfully reloaded.</dark_green>";
public static String EN_NoPermissionForCommand = "[prefix] <red>For <aqua>[cmd]</aqua> you lack the permission <gold>[perm]</gold>!</red>";
public static String EN_Buy = "[prefix] <dark_green>You have paid <gold>[price]</gold> for this command.</dark_green>";
public static String EN_BuyConfirm = "[prefix] <gold>For this command you have to pay [price]!</gold><br>[prefix] <green><click:run_command:'/t2c-a confirm'>" +
"<hover:show_text:'<gray>Click to confirm</gray>'>Confirm</hover></click></green> <gray>-</gray> <red><click:run_command:'/t2c-a cancel'><hover:show_text:'<gray>click to cancel</gray>'>Cancel</hover></click></red>";
public static String EN_BuyCancel = "[prefix] <gold>The command was canceled and you do not have to pay anything!</gold>";
public static String EN_BuyConfirmNotPossible = "[prefix] <gold>Confirmation not possible, you have not executed a payable command.</gold>";
public static String EN_NoMoney = "[prefix] <red>You don't have enough money for this command!</red>";
public static String EN_NoSubCommand = "[prefix] <red>This command does not exist!</red>";
// DE
public static String DE_OnlyForPlayer = "[prefix] <red>Dieser Command ist nur f[ue]r Spieler!</red>";
public static String DE_Disabled = "Unknown command. Type ''/help'' for help.";
public static String DE_ReloadStart = "[prefix] <gold>Plugin wird neu geladen...</gold>";
public static String DE_ReloadEnd = "[prefix] <dark_green>Plugin wurde erfolgreich neu geladen.</dark_green>";
public static String DE_NoPermissionForCommand = "[prefix] <red>F[ue]r <aqua>[cmd]</aqua> fehlt dir die Permission <gold>[perm]</gold>!</red>";
public static String DE_Buy = "[prefix] <dark_green>Du hast f[ue]r diesen Command <gold>[price]</gold> bezahlt.</dark_green>";
public static String DE_BuyConfirm = "[prefix] <gold>Für diesen Befehl musst du [price] bezahlen!</gold><br>[prefix] <green><click:run_command:'/t2c-a confirm'>" +
"<hover:show_text:'<gray>Klicke zum bestätigen</gray>'>Bestätigen</hover></click></green> <gray>-</gray> <red><click:run_command:'/t2c-a cancel'><hover:show_text:'<gray>Klicke zum abbrechen</gray>'>Abbrechen</hover></click></red>";
public static String DE_BuyCancel = "[prefix] <gold>Der befehl wurde abgebrochen und du musst nichts bezahlen!</gold>";
public static String DE_BuyConfirmNotPossible = "[prefix] <gold>Bestätigen nicht möglich, du hast keinen bezahlungspflichtigen befehl ausgeführt.</gold>";
public static String DE_NoMoney = "[prefix] <red>Du hast nicht gen[ue]gend Geld für diesen Command!</red>";
public static String DE_NoSubCommand = "[prefix] <red>Diesen Befehl gibt es nicht!</red>";
}

View File

@ -1,71 +0,0 @@
package net.t2code.alias.Spigot.config.languages;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.config.SelectConfig;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class SelectMessages {
public static String selectMSG;
public static String onlyForPlayer;
public static String reloadStart;
public static String reloadEnd;
public static String noPermissionForCommand;
public static String noSubCommand;
public static String aliasDisabled;
public static String buy;
public static String buyConfirm;
public static String buyCancel;
public static String buyConfirmNotPossible;
public static String noMoney;
public static void onSelect(String Prefix) {
T2Csend.debug(Main.getPlugin(), "§4Select language...");
long long_ = System.currentTimeMillis();
File msg;
msg = new File(Main.getPath(), "languages/" + SelectConfig.getLanguage() + "_messages.yml");
if (!msg.isFile()) {
T2Csend.console(Prefix);
T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Prefix + " §4The selected §c" + SelectConfig.getLanguage() + " §4language file was not found.");
T2Csend.console(Prefix + " §6The default language §eEnglish §6is used!");
T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Prefix);
msg = new File(Main.getPath(), "languages/" + "english_messages.yml");
selectMSG = "english";
} else selectMSG = SelectConfig.getLanguage();
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(msg);
if (yamlConfiguration.get("Plugin.Prefix") != null) {
Util.setPrefix(replace(yamlConfiguration.getString("Plugin.Prefix")));
}
onlyForPlayer = replace(yamlConfiguration.getString("Plugin.OnlyForPlayer"));
aliasDisabled = replace(yamlConfiguration.getString("Plugin.AliasDisabled"));
reloadStart = replace(yamlConfiguration.getString("Plugin.Reload.Start"));
reloadEnd = replace(yamlConfiguration.getString("Plugin.Reload.End"));
noPermissionForCommand = replace(yamlConfiguration.getString("Plugin.ForCommand"));
noSubCommand = replace(yamlConfiguration.getString("Plugin.NoSubCommand"));
buy = replace(yamlConfiguration.getString("Cost.Buy"));
buyConfirm = replace(yamlConfiguration.getString("Cost.BuyConfirm"));
buyCancel = replace(yamlConfiguration.getString("Cost.BuyCancel"));
buyConfirmNotPossible = replace(yamlConfiguration.getString("Cost.BuyConfirmNotPossible"));
noMoney = replace(yamlConfiguration.getString("Cost.NoMoney"));
T2Csend.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
private static String replace(String text) {
return T2Creplace.replace(Util.getPrefix(), text);
}
}

View File

@ -0,0 +1,42 @@
package net.t2code.alias.Spigot.confirm;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.cmdManagement.ExecuteAlias;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatConfirm implements Listener {
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
String[] args = e.getMessage().split(" ");
if (args.length == 0) {
return;
}
Player player = e.getPlayer();
switch (args[0].toLowerCase()) {
case "t2code-alias-confirm":
e.setCancelled(true);
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
@Override
public void run() {
ExecuteAlias.storage(player, true);
}
});
break;
case "t2code-alias-cancel":
e.setCancelled(true);
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
@Override
public void run() {
ExecuteAlias.storage(player, false);
}
});
break;
}
}
}

View File

@ -0,0 +1,32 @@
package net.t2code.alias.Spigot.confirm.gui;
import net.t2code.alias.Spigot.Cache;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.config.Config;
import net.t2code.alias.Spigot.config.config.Language;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemBuilder;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import java.util.List;
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))));
T2CitemBuilder.fillItem((boolean) Config.buyConfirmGuiFillItemEnabled.value, (String) Config.buyConfirmGuiFillItem.value, 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);
Cache.openPlayers.add(player.getUniqueId());
player.openInventory(inventory);
}
}

View File

@ -0,0 +1,40 @@
package net.t2code.alias.Spigot.confirm.gui;
import net.t2code.alias.Spigot.Cache;
import net.t2code.alias.Spigot.cmdManagement.ExecuteAlias;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
public class GuiListener implements Listener {
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
Player player = (Player) e.getWhoClicked();
if (e.getInventory() == null) return;
if (e.getCurrentItem() == null) return;
if (!Cache.openPlayers.contains(player.getUniqueId())) return;
e.setCancelled(true);
if (e.getClickedInventory() != e.getWhoClicked().getOpenInventory().getTopInventory()) return;
switch (e.getSlot()) {
case 12:
ExecuteAlias.storage(player, true);
break;
case 14:
ExecuteAlias.storage(player, false);
break;
default:
return;
}
Cache.openPlayers.remove(player.getUniqueId());
player.closeInventory();
}
@EventHandler
public void onInventoryCloseEvent(InventoryCloseEvent e) {
Player player = (Player) e.getPlayer();
Cache.openPlayers.remove(player.getUniqueId());
}
}

View File

@ -0,0 +1,10 @@
package net.t2code.alias.Spigot.enums;
public enum ConfigParam {
STRING,
INTEGER,
LIST,
BOOLEAN,
CONFIRMENUM,
SOUND
}

View File

@ -0,0 +1,7 @@
package net.t2code.alias.Spigot.enums;
public enum Confirm {
COMMAND,
CHAT,
GUI
}

View File

@ -5,18 +5,20 @@ import net.t2code.alias.Spigot.cmdManagement.AliasCmdExecuter;
import net.t2code.alias.Spigot.cmdManagement.TabEvent;
import net.t2code.alias.Spigot.config.alias.CreateExampleAliasConfig;
import net.t2code.alias.Spigot.config.alias.SelectAlias;
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.Spigot.config.config.Config;
import net.t2code.alias.Spigot.config.config.FileSelect;
import net.t2code.alias.Spigot.config.subAlias.CreateExampleSubAliasConfig;
import net.t2code.alias.Spigot.config.subAlias.SelectSubAlias;
import net.t2code.alias.Spigot.listener.PluginEvents;
import net.t2code.alias.Spigot.confirm.ChatConfirm;
import net.t2code.alias.Spigot.confirm.gui.GuiListener;
import net.t2code.alias.Spigot.enums.Confirm;
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 org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import java.io.File;
import java.util.List;
@ -29,14 +31,19 @@ public class Load {
plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter());
loadReload();
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(),
SelectConfig.getUpdateCheckOnJoin(), SelectConfig.getUpdateCheckSeePreReleaseUpdates(), SelectConfig.getUpdateCheckTimeInterval());
(Boolean) Config.updateCheckOnJoin.value, (Boolean) Config.updateCheckSeePreReleaseUpdates.value, (Integer) Config.updateCheckTimeInterval.value);
T2Ctemplate.onLoadFooter(prefix, long_);
T2Cregister.listener(new PluginEvents(), plugin);
Metrics.Bstats(plugin, bstatsID);
}
private static ChatConfirm chatListener;
private static GuiListener guiListener;
public static void loadReload() {
HandlerList.unregisterAll(chatListener);
HandlerList.unregisterAll(guiListener);
if (!new File(Main.getPath(), "config.yml").exists()) {
try {
CreateExampleAliasConfig.configCreate();
@ -59,19 +66,20 @@ public class Load {
} catch (Exception e) {
e.printStackTrace();
}
CreateConfig.configCreate();
LanguagesCreate.langCreate();
SelectConfig.onSelect();
SelectMessages.onSelect(Util.getPrefix());
FileSelect.config();
FileSelect.language();
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
SelectAlias.onSelect();
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
SelectSubAlias.onSelect();
SelectConfig.setConfigVersion();
if (SelectConfig.getSubAliasTab()) {
if ((Boolean) Config.subAliasTab.value) {
T2Cregister.listener(new TabEvent(), plugin);
}
chatListener = new ChatConfirm();
if (Config.buyConfirmDefault.value == Confirm.CHAT) T2Cregister.listener(chatListener, plugin);
guiListener = new GuiListener();
if (Config.buyConfirmDefault.value == Confirm.GUI) T2Cregister.listener(guiListener, plugin);
if (T2CLibConfig.getBungee()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
}

View File

@ -3,7 +3,6 @@
package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.config.config.SelectConfig;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;

View File

@ -1,7 +1,9 @@
package net.t2code.alias.Spigot.listener;
package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Cache;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.cmdManagement.ExecuteAlias;
import net.t2code.alias.Spigot.confirm.gui.ConfirmGUI;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import org.bukkit.entity.Player;
@ -14,7 +16,8 @@ public class PluginEvents implements Listener {
@EventHandler
public void onJoinEvent(PlayerQuitEvent event) {
Player player = event.getPlayer();
ExecuteAlias.aliasStorage.remove(player.getUniqueId());
Cache.aliasStorage.remove(player.getUniqueId());
Cache.openPlayers.remove(player.getUniqueId());
}
@EventHandler

View File

@ -8,7 +8,7 @@ public class Util {
}
public static String getRequiredT2CodeLibVersion() {
return "15.0";
return "15.6";
}
public static String getPrefix() {
@ -40,4 +40,8 @@ public class Util {
}
private static String prefix = "§8[§4T2Code§7-§aAlias§8]";
public static Integer getConfigVersion() {
return 4;
}
}

View File

@ -28,6 +28,9 @@ Alias:
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
# Here you can set if you have to confirm if you want to pay before executing the command
# In the config.yml you can set at 'buy.confirm.command' if a command or a chatListener should be used for confirming the command.
Confirm: true
Command:
# Here you can tell the alias to execute one or more commands
Enable: false

View File

@ -27,6 +27,9 @@ SubAlias:
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
# Here you can set if you have to confirm if you want to pay before executing the command
# In the config.yml you can set at 'buy.confirm.command' if a command or a chatListener should be used for confirming the command.
Confirm: true
Command:
# Here you can tell the alias to execute one or more commands
Enable: false