227 lines
13 KiB
Java
227 lines
13 KiB
Java
package de.jatitv.commandguiv2.Spigot.system.config.config;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.Main;
|
|
import de.jatitv.commandguiv2.Util;
|
|
import net.t2code.lib.Spigot.Lib.messages.send;
|
|
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
|
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
|
|
public class ConfigCreate {
|
|
|
|
private static String prefix = Util.Prefix;
|
|
|
|
public static Integer ConfigVersion = 2;
|
|
|
|
private static Boolean UpdateCheckOnJoin = true;
|
|
private static Boolean Debug = false;
|
|
private static Boolean HelpAlias = true;
|
|
private static String language = "english";
|
|
private static String Currency = "$";
|
|
private static String DefaultGUI = "default";
|
|
|
|
|
|
private static String Storage = "YML";
|
|
private static String ip = "localhost";
|
|
private static Integer port = 3306;
|
|
private static String database = "database";
|
|
private static String user = "root";
|
|
private static String password = "password";
|
|
private static Boolean SSL = false;
|
|
|
|
private static Boolean Bungee = false;
|
|
private static String thisServer = "server";
|
|
|
|
|
|
private static Boolean UseItem_Enable = true;
|
|
private static Boolean UseItem_AllowToggle = true;
|
|
private static Boolean UseItem_AllowSetSlot = true;
|
|
private static Boolean UseItem_BlockMoveAndDrop = true;
|
|
private static String UseItem_OpenGUI = "default";
|
|
private static Boolean UseItem_Permission = true;
|
|
private static Boolean UseItem_KeepAtCommandClear = true;
|
|
|
|
private static Integer UseItem_InventorySlot = 1;
|
|
private static Boolean UseItem_InventorySlotEnforce = false;
|
|
private static Boolean UseItem_InventorySlot_FreeSlot = false;
|
|
private static String UseItem_Material = "paper";
|
|
private static Boolean UseItem_PlayerHead_Enable = false;
|
|
private static Boolean base64_Enable = false;
|
|
private static String base64value= "";
|
|
private static Boolean UseItem_PlayerWhoHasOpenedTheGUI = false;
|
|
private static String UseItem_PlayerName = "";
|
|
private static String UseItem_Name = "&bDefault &6GUI";
|
|
private static List UseItem_Lore = Arrays.asList("&eThis is an example GUI");
|
|
private static Boolean UseItem_GiveOnEveryJoin = true;
|
|
private static Boolean UseItem_GiveOnlyOnFirstJoin = false;
|
|
private static Boolean Cursor_ToGUIItem_OnLogin = true;
|
|
private static Boolean Cursor_ToGUIItem_OnlyOnFirstLogin = true;
|
|
private static Boolean Cursor_ServerChange_EXPERIMENTELL = false;
|
|
|
|
private static int UseItemGameModeChangeDelayInTicks = 1;
|
|
private static boolean UseItemGameModeChangeDisableInSpectator = true;
|
|
|
|
private static Boolean Sound_Enable = true;
|
|
|
|
private static Boolean Sound_OpenInventory_Enable = true;
|
|
public static String Sound_OpenInventory_1_8 = "CHEST_OPEN";
|
|
public static String Sound_OpenInventory_ab_1_9 = "BLOCK_CHEST_OPEN";
|
|
|
|
private static Boolean Sound_Click_Enable = true;
|
|
public static String Sound_Click_1_8 = "NOTE_STICKS";
|
|
public static String Sound_Click_1_9_bis_1_12 = "BLOCK_NOTE_HAT";
|
|
public static String Sound_Click_ab_1_13 = "BLOCK_NOTE_BLOCK_HAT";
|
|
|
|
private static Boolean Sound_NoMoney_Enable = true;
|
|
public static String Sound_NoMoney_1_8 = "NOTE_PIANO";
|
|
public static String Sound_NoMoney_1_9_bis_1_12 = "BLOCK_NOTE_HARP";
|
|
public static String Sound_NoMoney_ab_1_13 = "BLOCK_NOTE_BLOCK_HARP";
|
|
|
|
private static Boolean Sound_NoInventorySpace_Enable = true;
|
|
public static String Sound_NoInventorySpace_1_8 = "NOTE_PIANO";
|
|
public static String Sound_NoInventorySpace_1_9_bis_1_12 = "BLOCK_NOTE_HARP";
|
|
public static String Sound_NoInventorySpace_ab_1_13 = "BLOCK_NOTE_BLOCK_HARP";
|
|
|
|
private static Boolean Sound_Give_Enable = true;
|
|
public static String Sound_Give_1_8 = "LEVEL_UP";
|
|
public static String Sound_Give_ab_1_9 = "ENTITY_PLAYER_LEVELUP";
|
|
|
|
private static Boolean Sound_PlayerNotFound_Enable = true;
|
|
public static String Sound_PlayerNotFound_1_8 = "NOTE_PIANO";
|
|
public static String Sound_PlayerNotFound_1_9_bis_1_12 = "BLOCK_NOTE_HARP";
|
|
public static String Sound_PlayerNotFound_ab_1_13 = "BLOCK_NOTE_BLOCK_HARP";
|
|
|
|
|
|
public static void configCreate() {
|
|
Long long_ = Long.valueOf(System.currentTimeMillis());
|
|
if (new File(Main.getPath(), "config.yml").exists()){
|
|
if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Main.prefix + " §5DEBUG: §6" + " §4config.yml are created / updated...");
|
|
} else send.console(Main.prefix + " §4config.yml are created...");
|
|
|
|
|
|
File config = new File(Main.getPath(), "config.yml");
|
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
|
|
|
yamlConfiguration.set("ConfigVersion", ConfigVersion);
|
|
|
|
Config.set("Plugin.UpdateCheckOnJoin", UpdateCheckOnJoin, yamlConfiguration);
|
|
Config.set("Plugin.Debug", Debug, yamlConfiguration);
|
|
Config.set("Plugin.HelpAlias", HelpAlias, yamlConfiguration);
|
|
Config.set("Plugin.language", language, yamlConfiguration);
|
|
Config.set("Plugin.Currency", Currency, yamlConfiguration);
|
|
Config.set("Plugin.DefaultGUI", DefaultGUI, yamlConfiguration);
|
|
|
|
Config.set("Storage.Type", Storage, yamlConfiguration);
|
|
Config.set("Storage.MySQL.IP", ip, yamlConfiguration);
|
|
Config.set("Storage.MySQL.Port", port, yamlConfiguration);
|
|
Config.set("Storage.MySQL.Database", database, yamlConfiguration);
|
|
Config.set("Storage.MySQL.User", user, yamlConfiguration);
|
|
Config.set("Storage.MySQL.Password", password, yamlConfiguration);
|
|
Config.set("Storage.MySQL.SSL", SSL, yamlConfiguration);
|
|
|
|
Config.set("BungeeCord.Enable", Bungee, yamlConfiguration);
|
|
Config.set("BungeeCord.ThisServer", thisServer, yamlConfiguration);
|
|
|
|
Config.set("UseItem.Enable", UseItem_Enable, yamlConfiguration);
|
|
Config.set("UseItem.AllowToggle", UseItem_AllowToggle, yamlConfiguration);
|
|
Config.set("UseItem.AllowSetSlot", UseItem_AllowSetSlot, yamlConfiguration);
|
|
Config.set("UseItem.BlockMoveAndDrop", UseItem_BlockMoveAndDrop, yamlConfiguration);
|
|
Config.set("UseItem.OpenGUI", UseItem_OpenGUI, yamlConfiguration);
|
|
Config.set("UseItem.Permission.NeededToUse", UseItem_Permission, yamlConfiguration);
|
|
Config.set("UseItem.KeepAtCommandClear", UseItem_KeepAtCommandClear, yamlConfiguration);
|
|
|
|
Config.set("UseItem.InventorySlot.Slot", UseItem_InventorySlot, yamlConfiguration);
|
|
Config.set("UseItem.InventorySlot.SlotEnforce", UseItem_InventorySlotEnforce, yamlConfiguration);
|
|
Config.set("UseItem.InventorySlot.FreeSlot", UseItem_InventorySlot_FreeSlot, yamlConfiguration);
|
|
|
|
Config.set("UseItem.Item.Material", UseItem_Material, yamlConfiguration);
|
|
if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) {
|
|
Config.set("UseItem.Item.PlayerHead.Enable", UseItem_PlayerHead_Enable, yamlConfiguration);
|
|
Config.set("UseItem.Item.PlayerHead.Base64.Enable", base64_Enable, yamlConfiguration);
|
|
Config.set("UseItem.Item.PlayerHead.Base64.Base64Value", base64value, yamlConfiguration);
|
|
Config.set("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", UseItem_PlayerWhoHasOpenedTheGUI, yamlConfiguration);
|
|
Config.set("UseItem.Item.PlayerHead.Playername", UseItem_PlayerName, yamlConfiguration);
|
|
}
|
|
Config.set("UseItem.Item.Name", UseItem_Name, yamlConfiguration);
|
|
Config.set("UseItem.Item.Lore", UseItem_Lore, yamlConfiguration);
|
|
Config.set("UseItem.Join.GiveOnEveryJoin", UseItem_GiveOnEveryJoin, yamlConfiguration);
|
|
Config.set("UseItem.Join.GiveOnlyOnFirstJoin", UseItem_GiveOnlyOnFirstJoin, yamlConfiguration);
|
|
|
|
//convert
|
|
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin")){
|
|
Config.set("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin", yamlConfiguration);
|
|
Config.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin"), yamlConfiguration);
|
|
}
|
|
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin")){
|
|
Config.set("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin", yamlConfiguration);
|
|
Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin"), yamlConfiguration);
|
|
}
|
|
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange")){
|
|
Config.set("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange", yamlConfiguration);
|
|
Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange"), yamlConfiguration);
|
|
}
|
|
|
|
Config.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", Cursor_ToGUIItem_OnLogin, yamlConfiguration);
|
|
Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", Cursor_ToGUIItem_OnlyOnFirstLogin, yamlConfiguration);
|
|
Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", Cursor_ServerChange_EXPERIMENTELL, yamlConfiguration);
|
|
|
|
Config.set("Advanced.UseItem.GameModeChange.DelayInTicks", UseItemGameModeChangeDelayInTicks, yamlConfiguration);
|
|
Config.set("Advanced.UseItem.GameModeChange.DisableInSpectator", UseItemGameModeChangeDisableInSpectator, yamlConfiguration);
|
|
|
|
Config.set("Sound.Enable", Sound_Enable, yamlConfiguration);
|
|
|
|
Config.set("Sound.OpenInventory.Enable", Sound_OpenInventory_Enable, yamlConfiguration);
|
|
if (MCVersion.minecraft1_8) {
|
|
Config.set("Sound.OpenInventory.Sound", Sound_OpenInventory_1_8, yamlConfiguration);
|
|
} else Config.set("Sound.OpenInventory.Sound", Sound_OpenInventory_ab_1_9, yamlConfiguration);
|
|
|
|
Config.set("Sound.Click.Enable", Sound_Click_Enable, yamlConfiguration);
|
|
if (MCVersion.minecraft1_8) {
|
|
Config.set("Sound.Click.Sound", Sound_Click_1_8, yamlConfiguration);
|
|
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
|
Config.set("Sound.Click.Sound", Sound_Click_1_9_bis_1_12, yamlConfiguration);
|
|
} else Config.set("Sound.Click.Sound", Sound_Click_ab_1_13, yamlConfiguration);
|
|
|
|
Config.set("Sound.NoMoney.Enable", Sound_NoMoney_Enable, yamlConfiguration);
|
|
if (MCVersion.minecraft1_8) {
|
|
Config.set("Sound.NoMoney.Sound", Sound_NoMoney_1_8, yamlConfiguration);
|
|
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
|
Config.set("Sound.NoMoney.Sound", Sound_NoMoney_1_9_bis_1_12, yamlConfiguration);
|
|
} else Config.set("Sound.NoMoney.Sound", Sound_NoMoney_ab_1_13, yamlConfiguration);
|
|
|
|
Config.set("Sound.NoInventorySpace.Enable", Sound_NoInventorySpace_Enable, yamlConfiguration);
|
|
if (MCVersion.minecraft1_8) {
|
|
Config.set("Sound.NoInventorySpace.Sound", Sound_NoInventorySpace_1_8, yamlConfiguration);
|
|
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
|
Config.set("Sound.NoInventorySpace.Sound", Sound_NoInventorySpace_1_9_bis_1_12, yamlConfiguration);
|
|
} else Config.set("Sound.NoInventorySpace.Sound", Sound_NoInventorySpace_ab_1_13, yamlConfiguration);
|
|
|
|
Config.set("Sound.Give.Enable", Sound_Give_Enable, yamlConfiguration);
|
|
if (MCVersion.minecraft1_8) {
|
|
Config.set("Sound.Give.Sound", Sound_Give_1_8, yamlConfiguration);
|
|
} else Config.set("Sound.Give.Sound", Sound_Give_ab_1_9, yamlConfiguration);
|
|
|
|
Config.set("Sound.PlayerNotFound.Enable", Sound_PlayerNotFound_Enable, yamlConfiguration);
|
|
if (MCVersion.minecraft1_8) {
|
|
Config.set("Sound.PlayerNotFound.Sound", Sound_PlayerNotFound_1_8, yamlConfiguration);
|
|
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
|
Config.set("Sound.PlayerNotFound.Sound", Sound_PlayerNotFound_1_9_bis_1_12, yamlConfiguration);
|
|
} else Config.set("Sound.PlayerNotFound.Sound", Sound_PlayerNotFound_ab_1_13, yamlConfiguration);
|
|
|
|
try {
|
|
yamlConfiguration.save(config);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
|
|
|
}
|
|
}
|