package de.jatitv.commandguiv2.Spigot.objects; import de.jatitv.commandguiv2.Spigot.Main; import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI; import de.jatitv.commandguiv2.Spigot.objects.functions.Function; import de.jatitv.commandguiv2.Spigot.objects.guis.Gui; import de.jatitv.commandguiv2.Spigot.objects.slots.Slot; import de.jatitv.commandguiv2.Spigot.enums.EcoEnum; import de.jatitv.commandguiv2.Spigot.enums.FunctionItemEnum; import de.jatitv.commandguiv2.Spigot.enums.FunctionVoteEnum; 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.ArrayList; import java.util.List; public class Obj_Select { public static void onSelect() { onSelectFunction(); onSelectGui(); } public static void onSelectGui() { Main.guiHashMap.clear(); Main.allAliases.clear(); File f = new File(Main.getPath() + "/GUIs/"); File[] fileArray = f.listFiles(); for (File config : fileArray) { try { if (config.getName().equals("guiDeclaration.yml")) continue; String sub = config.getName().substring(config.getName().length() - 4); if (sub.equals(".yml")) { String key = config.getName().replace(".yml", ""); Main.allAliases.add(key); YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config); Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable"); Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines"); if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) { yamlConfiguration_gui.set("GUI.Lines", 6); } if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) { yamlConfiguration_gui.set("GUI.Lines", 1); } String guiName = yamlConfiguration_gui.getString("GUI.Name"); Boolean guiFillItemEnable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable"); String guiFillItemItem; if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneColor"); } else guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.Item"); Boolean commandAliasEnable = yamlConfiguration_gui.getBoolean("Command.Alias"); Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required"); ArrayList slots = new ArrayList<>(); for (String slotKey : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) { Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + slotKey + ".Slot") - 1; Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Enable"); String function = yamlConfiguration_gui.getString("Slots." + slotKey + ".Function"); Function functionCheck = Main.functionHashMap.get(function); if (functionCheck == null) { send.error(Main.plugin, "The Function " + function + " in the GUI " + key + " does not exist!"); } Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Permission.Required"); String permSee = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.See"); String permUse = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.Use"); Slot slot = new Slot(slotNumber, enable, function, permRequired, permSee.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1)) .replace("[slotname]", slotKey.toLowerCase()), permUse.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1)) .replace("[slotname]", slotKey.toLowerCase())); slots.add(slot); } Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem, key, commandAliasEnable, commandPermission, slots); Main.guiHashMap.put(key, gui); CmdExecuter_GUI.arg1.put(config.getName() .replace(".yml", ""), "commandgui.gui." + key); yamlConfiguration_gui.save(config); } } catch (Exception e) { Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]); e.printStackTrace(); } } } public static void onSelectFunction() { Main.functionHashMap.clear(); File f = new File(Main.getPath() + "/Functions/"); File[] fileArray = f.listFiles(); for (File config : fileArray) { if (config.getName().equals("functionDeclaration.yml")) return; String sub = config.getName().substring(config.getName().length() - 4); if (sub.equals(".yml")) { YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); String key = config.getName().replace(".yml", ""); Boolean empty = yamlConfiguration.getBoolean("Slots.Function.Item.Empty"); Integer itemAmount = yamlConfiguration.getInt("Slots.Function.Item.Amount"); Boolean playerHead_Enable = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.Enable"); Boolean base64_Enable = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.Base64.Enable"); String base64Value = yamlConfiguration.getString("Slots.Function.Item.PlayerHead.Base64.Base64Value"); Boolean playerWhoHasOpenedTheGUI = yamlConfiguration.getBoolean("Slots.Function.Item.PlayerHead.PlayerWhoHasOpenedTheGUI"); String playerName = yamlConfiguration.getString("Slots.Function.Item.PlayerHead.PlayerName"); String item = yamlConfiguration.getString("Slots.Function.Item.Material"); String name = yamlConfiguration.getString("Slots.Function.Item.Name"); List lore = yamlConfiguration.getStringList("Slots.Function.Item.Lore"); Boolean customSound_Enable = yamlConfiguration.getBoolean("Slots.Function.CustomSound.Enable"); Boolean customSound_NoSound = yamlConfiguration.getBoolean("Slots.Function.CustomSound.NoSound"); String customSound_Sound = yamlConfiguration.getString("Slots.Function.CustomSound.Sound"); Boolean cost_Enable = yamlConfiguration.getBoolean("Slots.Function.Cost.Enable"); EcoEnum ecoModule = null; if (yamlConfiguration.get("Slots.Function.Cost.EcoModule") != null) { try { ecoModule = EcoEnum.valueOf(yamlConfiguration.getString("Slots.Function.Cost.EcoModule").toUpperCase()); } catch (Exception ex) { send.error(Main.plugin, "The EcoModule " + yamlConfiguration.getString("Slots.Function.Cost.EcoModule").toUpperCase() + " in the function file " + config.getName() + " does not exist. Please use one of the supported modules. (VAULT, ITEM, VOTEPOINTS)"); } } else ecoModule = EcoEnum.VAULT; String ecoItem = yamlConfiguration.getString("Slots.Function.Cost.Item"); Integer votePoints = yamlConfiguration.getInt("Slots.Function.Cost.VotePoints"); Double price = yamlConfiguration.getDouble("Slots.Function.Cost.Price"); Boolean command_Enable = yamlConfiguration.getBoolean("Slots.Function.Command.Enable"); Boolean command_BungeeCommand = yamlConfiguration.getBoolean("Slots.Function.Command.BungeeCommand"); Boolean commandAsConsole = yamlConfiguration.getBoolean("Slots.Function.Command.CommandAsConsole"); List command = yamlConfiguration.getStringList("Slots.Function.Command.Command"); Boolean serverChange = yamlConfiguration.getBoolean("Slots.Function.ServerChange.Enable"); String serverChangeServer = yamlConfiguration.getString("Slots.Function.ServerChange.Server"); Boolean openGUI_Enable = yamlConfiguration.getBoolean("Slots.Function.OpenGUI.Enable"); String openGUI = yamlConfiguration.getString("Slots.Function.OpenGUI.GUI"); Boolean togglePermission = yamlConfiguration.getBoolean("Slots.Function.Toggle.Permission.Enable"); String togglePermissionPerm = yamlConfiguration.getString("Slots.Function.Toggle.Permission.Permission"); Boolean toggleUseItem = yamlConfiguration.getBoolean("Slots.Function.Toggle.UseItem.Enable"); Boolean message_Enable = yamlConfiguration.getBoolean("Slots.Function.Message.Enable"); List message = yamlConfiguration.getStringList("Slots.Function.Message.Message"); Boolean setConfigEnable = yamlConfiguration.getBoolean("Slots.Function.SetConfig.Enable"); String configFilePath = yamlConfiguration.getString("Slots.Function.SetConfig.File.Path"); String configOptionPath = yamlConfiguration.getString("Slots.Function.SetConfig.Option.Path"); String configOptionPremat = yamlConfiguration.getString("Slots.Function.SetConfig.Option.Premat"); // Boolean ConfigChatInput = ; String configStringValueLeft = yamlConfiguration.getString("Slots.Function.SetConfig.Value.LeftClick.String"); Boolean configBooleanValueLeft = yamlConfiguration.getBoolean("Slots.Function.SetConfig.Value.LeftClick.Boolean"); Integer configIntegerValueLeft = yamlConfiguration.getInt("Slots.Function.SetConfig.Value.LeftClick.Integer"); Double configDoubleValueLeft = yamlConfiguration.getDouble("Slots.Function.SetConfig.Value.LeftClick.Double"); List configListValueLeft = yamlConfiguration.getStringList("Slots.Function.SetConfig.Value.LeftClick.List"); String configStringValueRight = yamlConfiguration.getString("Slots.Function.SetConfig.Value.RightClick.String"); Boolean configBooleanValueRight = yamlConfiguration.getBoolean("Slots.Function.SetConfig.Value.RightClick.Boolean"); Integer configIntegerValueRight = yamlConfiguration.getInt("Slots.Function.SetConfig.Value.RightClick.Integer"); Double configDoubleValueRight = yamlConfiguration.getDouble("Slots.Function.SetConfig.Value.RightClick.Double"); List configListValueRight = yamlConfiguration.getStringList("Slots.Function.SetConfig.RightClick.Value.List"); Boolean pluginReloadEnable = yamlConfiguration.getBoolean("Slots.Function.SetConfig.PluginReload.Enable"); String pluginReloadCommand = yamlConfiguration.getString("Slots.Function.SetConfig.PluginReload.Command"); Boolean functionVotePoints = yamlConfiguration.getBoolean("Slots.Function.FunctionVotePoints.Enable"); FunctionVoteEnum functionVotePointsMode = null; if (yamlConfiguration.get("Slots.Function.FunctionVotePoints.Mode") != null) { try { functionVotePointsMode = FunctionVoteEnum.valueOf(yamlConfiguration.getString("Slots.Function.FunctionVotePoints.Mode").toUpperCase()); } catch (Exception ex) { send.error(Main.plugin, "The VotePoints Mode " + yamlConfiguration.getString("Slots.Function.FunctionVotePoints.Mode").toUpperCase() + " in the function file " + config.getName() + " does not exist. Please use one of the supported modules. (ADD, REMOVE)"); } } Integer functionVotePointsAmount = yamlConfiguration.getInt("Slots.Function.FunctionVotePoints.Amount"); Boolean functionItem = yamlConfiguration.getBoolean("Slots.Function.FunctionItem.Enable"); FunctionItemEnum functionItemMode = null; if (yamlConfiguration.get("Slots.Function.FunctionItem.Mode") != null) { try { functionItemMode = FunctionItemEnum.valueOf(yamlConfiguration.getString("Slots.Function.FunctionItem.Mode").toUpperCase()); } catch (Exception ex) { send.error(Main.plugin, "The Item Mode " + yamlConfiguration.getString("Slots.Function.FunctionItem.Mode").toUpperCase() + " in the function file " + config.getName() + " does not exist. Please use one of the supported modules. (ADD, REMOVE)"); } } String functionItemItem = yamlConfiguration.getString("Slots.Function.FunctionItem.Item"); Function function = new Function(key, empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore, customSound_Enable, customSound_NoSound, customSound_Sound, cost_Enable, ecoModule, ecoItem, votePoints, price, command_Enable, command_BungeeCommand, commandAsConsole, command, serverChange, serverChangeServer, openGUI_Enable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, message_Enable, message, setConfigEnable, configFilePath, configOptionPath, configOptionPremat, configStringValueLeft, configBooleanValueLeft, configIntegerValueLeft, configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight, configListValueRight, pluginReloadEnable, pluginReloadCommand, functionVotePoints, functionVotePointsMode, functionVotePointsAmount, functionItem, functionItemMode, functionItemItem); Main.functionHashMap.put(key, function); try { yamlConfiguration.save(config); } catch (IOException e) { e.printStackTrace(); } } } } }