package de.jatitv.commandguiv2.Spigot.config.functions; import de.jatitv.commandguiv2.Spigot.Main; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.List; public class CreateFunctions { public static void create() { createFunction("UseItem", false, 1, false, false, "", false, "", "", "&6Toggle UseItem", Arrays.asList("&bYou currently have the UseItem set to: %commandgui_useitem%"), false, false, "", false, 0.0, false, false, false, Arrays.asList(), false, "", false, "", false, "", true, true, Arrays.asList("&bYour UseItem was set to: %commandgui_useitem%&b."), false, "", "", "String", "", false, 0, 0.0, Arrays.asList(), "", false, 0, 0.0, Arrays.asList(), false, ""); createFunction("SupportDiscord", false, 1, true, true, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzg3M2MxMmJmZmI1MjUxYTBiODhkNWFlNzVjNzI0N2NiMzlhNzVmZjFhODFjYmU0YzhhMzliMzExZGRlZGEifX19", false, "", "", "&3Support Discord", Arrays.asList("&8-----------------", "&bIf you need help setting up the plugin,", "&bfeel free to contact me on the Suport Discord.", "&8-----------------", "&eIf you find any errors or bugs,", "&eplease contact me so I can fix them.", "&8-----------------", "&5Discord: §7http://dc.t2code.net"), false, false, "", false, 0.0, false, false, false, Arrays.asList(), false, "", false, "", false, "", false, true, Arrays.asList("&6You can find more information on Discord: &ehttp://dc.t2code.net"), false, "", "", "String", "", false, 0, 0.0, Arrays.asList(), "", false, 0, 0.0, Arrays.asList(), false, ""); } public static void createFunction(String fileName, Boolean empty, Integer itemAmount, Boolean playerHeadEnable, Boolean base64Enable, String base64Value, Boolean playerWhoHasOpenedTheGUI, String playerName, String itemMaterial, String name, List lore, Boolean customSoundEnable, Boolean customSoundNoSound, String customSoundSound, Boolean costEnable, Double price, Boolean commandEnable, Boolean commandBungeeCommand, Boolean commandAsConsole, List command, Boolean serverChange, String serverChangeServer, Boolean openGUIEnable, String openGUI, Boolean togglePermission, String togglePermissionPerm, Boolean toggleUseItem, Boolean messageEnable, List message, Boolean setConfigEnable, String configFilePath, String configOptionPath, String configOptionPremat, String configStringValueLeft, Boolean configBooleanValueLeft, Integer configIntegerValueLeft, Double configDoubleValueLeft, List configListValueLeft, String configStringValueRight, Boolean configBooleanValueRight, Integer configIntegerValueRight, Double configDoubleValueRight, List configListValueRight, Boolean pluginReloadEnable, String pluginReloadCommand) { long long_ = System.currentTimeMillis(); File config = new File(Main.getPath(), "Functions/" + fileName + ".yml"); int i = 1; while (config.exists()) { config = new File(Main.getPath(), "Functions/" + fileName + "-" + i + ".yml"); i++; } send.console(Main.prefix + " §4Function GUI file (Functions/" + config.getName() + ") is loaded..."); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); set("Slots.Function.Item.Empty", empty, yamlConfiguration); set("Slots.Function.Item.Amount", itemAmount, yamlConfiguration); // if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) { set("Slots.Function.Item.PlayerHead.Enable", playerHeadEnable, yamlConfiguration); set("Slots.Function.Item.PlayerHead.Base64.Enable", base64Enable, yamlConfiguration); set("Slots.Function.Item.PlayerHead.Base64.Base64Value", base64Value, yamlConfiguration); set("Slots.Function.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", playerWhoHasOpenedTheGUI, yamlConfiguration); set("Slots.Function.Item.PlayerHead.PlayerName", playerName, yamlConfiguration); // } set("Slots.Function.Item.Material", itemMaterial == null ? "" : itemMaterial, yamlConfiguration); set("Slots.Function.Item.Name", name == null ? "" : name, yamlConfiguration); set("Slots.Function.Item.Lore", lore, yamlConfiguration); set("Slots.Function.CustomSound.Enable", customSoundEnable, yamlConfiguration); set("Slots.Function.CustomSound.NoSound", customSoundNoSound, yamlConfiguration); set("Slots.Function.CustomSound.Sound", customSoundSound == null ? "" : customSoundSound, yamlConfiguration); set("Slots.Function.Cost.Enable", costEnable, yamlConfiguration); set("Slots.Function.Cost.Price", price, yamlConfiguration); set("Slots.Function.Command.Enable", commandEnable, yamlConfiguration); set("Slots.Function.Command.BungeeCommand", commandBungeeCommand, yamlConfiguration); set("Slots.Function.Command.CommandAsConsole", commandAsConsole, yamlConfiguration); set("Slots.Function.Command.Command", command, yamlConfiguration); set("Slots.Function.ServerChange.Enable", serverChange, yamlConfiguration); set("Slots.Function.ServerChange.Server", serverChangeServer == null ? "" : serverChangeServer, yamlConfiguration); set("Slots.Function.OpenGUI.Enable", openGUIEnable, yamlConfiguration); set("Slots.Function.OpenGUI.GUI", openGUI == null ? "" : openGUI, yamlConfiguration); set("Slots.Function.Toggle.Permission.Enable", togglePermission, yamlConfiguration); set("Slots.Function.Toggle.Permission.Permission", togglePermissionPerm == null ? "" : togglePermissionPerm, yamlConfiguration); set("Slots.Function.Toggle.UseItem.Enable", toggleUseItem, yamlConfiguration); set("Slots.Function.Message.Enable", messageEnable, yamlConfiguration); set("Slots.Function.Message.Message", message, yamlConfiguration); set("Slots.Function.SetConfig.Enable", setConfigEnable, yamlConfiguration); set("Slots.Function.SetConfig.File.Path", configFilePath == null ? "" : configFilePath, yamlConfiguration); set("Slots.Function.SetConfig.Option.Path", configOptionPath == null ? "" : configOptionPath, yamlConfiguration); set("Slots.Function.SetConfig.Option.Premat", configOptionPremat == null ? "" : configOptionPremat, yamlConfiguration); set("Slots.Function.SetConfig.Value.LeftClick.String", configStringValueLeft == null ? "" : configStringValueLeft, yamlConfiguration); set("Slots.Function.SetConfig.Value.LeftClick.Boolean", configBooleanValueLeft, yamlConfiguration); set("Slots.Function.SetConfig.Value.LeftClick.Integer", configIntegerValueLeft, yamlConfiguration); set("Slots.Function.SetConfig.Value.LeftClick.Double", configDoubleValueLeft, yamlConfiguration); set("Slots.Function.SetConfig.Value.LeftClick.List", configListValueLeft, yamlConfiguration); set("Slots.Function.SetConfig.Value.RightClick.String", configStringValueRight == null ? "" : configStringValueRight, yamlConfiguration); set("Slots.Function.SetConfig.Value.RightClick.Boolean", configBooleanValueRight, yamlConfiguration); set("Slots.Function.SetConfig.Value.RightClick.Integer", configIntegerValueRight, yamlConfiguration); set("Slots.Function.SetConfig.Value.RightClick.Double", configDoubleValueRight, yamlConfiguration); set("Slots.Function.SetConfig.Value.RightClick.List", configListValueRight, yamlConfiguration); set("Slots.Function.SetConfig.PluginReload.Enable", pluginReloadEnable, yamlConfiguration); set("Slots.Function.SetConfig.PluginReload.Command", pluginReloadCommand == null ? "" : pluginReloadCommand, yamlConfiguration); try { yamlConfiguration.save(config); } catch (IOException e) { e.printStackTrace(); } send.console(Main.prefix + " §2Function file (Functions/" + config.getName() + ") was loaded." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } private static void set(String path, String value, YamlConfiguration config) { if (!config.contains(path)) { config.set(path, value); } } private static void set(String path, Integer value, YamlConfiguration config) { if (!config.contains(path)) { config.set(path, value); } } private static void set(String path, Boolean value, YamlConfiguration config) { if (!config.contains(path)) { config.set(path, value); } } private static void set(String path, List value, YamlConfiguration config) { if (!config.contains(path)) { config.set(path, value); } } private static void set(String path, Double value, YamlConfiguration config) { if (!config.contains(path)) { config.set(path, value); } } }