T2C-CommandGUI/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/Spigot/config/config/ConfigCreate.java

202 lines
13 KiB
Java
Raw Normal View History

2022-01-06 01:21:27 +00:00
package de.jatitv.commandguiv2.Spigot.config.config;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Util;
2022-04-16 12:32:22 +00:00
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
2022-01-06 01:21:27 +00:00
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.Material;
2022-01-06 01:21:27 +00:00
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
2022-01-06 01:21:27 +00:00
import java.util.Arrays;
import java.util.List;
2022-01-06 01:21:27 +00:00
public class ConfigCreate {
2022-01-06 01:21:27 +00:00
public static void configCreate() {
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
long long_ = System.currentTimeMillis();
2022-01-06 01:21:27 +00:00
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);
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
2022-01-06 01:21:27 +00:00
Config.set("Plugin.Debug", false, yamlConfiguration);
Config.set("Plugin.HelpAlias", true, yamlConfiguration);
Config.set("Plugin.language", "english", yamlConfiguration);
Config.set("Plugin.Currency", "$", yamlConfiguration);
Config.set("Plugin.DefaultGUI", "default", yamlConfiguration);
if (Main.legacy){
Config.set("Storage.Type", "YML", yamlConfiguration);
} else Config.set("Storage.Type", "SQLITE", yamlConfiguration);
2022-01-06 01:21:27 +00:00
Config.set("Storage.MySQL.IP", "localhost", yamlConfiguration);
Config.set("Storage.MySQL.Port", 3306, yamlConfiguration);
Config.set("Storage.MySQL.Database", "database", yamlConfiguration);
Config.set("Storage.MySQL.User", "root", yamlConfiguration);
Config.set("Storage.MySQL.Password", "password", yamlConfiguration);
Config.set("Storage.MySQL.SSL", false, yamlConfiguration);
Config.set("BungeeCord.Enable", false, yamlConfiguration);
Config.set("BungeeCord.ThisServer", "server", yamlConfiguration);
Config.set("UseItem.Enable", true, yamlConfiguration);
Config.set("UseItem.AllowToggle", true, yamlConfiguration);
Config.set("UseItem.AllowSetSlot", true, yamlConfiguration);
Config.set("UseItem.BlockMoveAndDrop", true, yamlConfiguration);
Config.set("UseItem.OpenGUI", "default", yamlConfiguration);
Config.set("UseItem.Permission.NeededToUse", true, yamlConfiguration);
Config.set("UseItem.KeepAtCommandClear", true, yamlConfiguration);
Config.set("UseItem.InventorySlot.Slot", 1, yamlConfiguration);
Config.set("UseItem.InventorySlot.SlotEnforce", false, yamlConfiguration);
Config.set("UseItem.InventorySlot.FreeSlot", false, yamlConfiguration);
Config.set("UseItem.Item.Material", "paper", yamlConfiguration);
if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) {
Config.set("UseItem.Item.PlayerHead.Enable", false, yamlConfiguration);
Config.set("UseItem.Item.PlayerHead.Base64.Enable", false, yamlConfiguration);
Config.set("UseItem.Item.PlayerHead.Base64.Base64Value", "", yamlConfiguration);
Config.set("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration);
Config.set("UseItem.Item.PlayerHead.Playername", "", yamlConfiguration);
}
Config.set("UseItem.Item.Name", "&bDefault &6GUI", yamlConfiguration);
Config.set("UseItem.Item.Lore", Arrays.asList("&eThis is an example GUI"), yamlConfiguration);
Config.set("UseItem.Join.GiveOnEveryJoin", true, yamlConfiguration);
Config.set("UseItem.Join.GiveOnlyOnFirstJoin", false, 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", true, yamlConfiguration);
Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", true, yamlConfiguration);
Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Change.Enable", true, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Change.DelayInTicks", 1, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.Enable", false, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.GameMode.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration);
2022-01-06 01:21:27 +00:00
Config.set("Advanced.UseItem.World.Change.Enable", true, yamlConfiguration);
Config.set("Advanced.UseItem.World.Change.DelayInTicks", 1, yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.Enable", false, yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration);
/*
Config.set("Advanced.UseItem.ItemBlockBlacklist", Arrays.asList("CHEST", "TRAPPED_CHEST", "FURNACE", "NOTE_BLOCK",
"CRAFTING_TABLE", "ENDER_CHEST", "ANVIL", "LOOM", "COMPOSTER", "BARREL", "SMOKER",
"BLAST_FURNACE", "CARTOGRAPHY_TABLE", "FLETCHING_TABLE", "GRINDSTONE", "SMITHING_TABLE", "STONECUTTER",
"HOPPER", "DISPENSER", "DROPPER", "REPEATER", "COMPARATOR", "LEVER", "DAYLIGHT_DETECTOR",
"STONE_BUTTON", "OAK_BUTTON", "SPRUCE_BUTTON", "BIRCH_BUTTON", "JUNGLE_BUTTON", "ACACIA_BUTTON", "DARK_OAK_BUTTON", "CRIMSON_BUTTON",
"IRON_DOOR", "OAK_DOOR", "SPRUCE_DOOR", "BIRCH_DOOR", "JUNGLE_DOOR", "ACACIA_DOOR", "DARK_OAK_DOOR", "CRIMSON_DOOR", "WARPED_DOOR",
"OAK_FENCE", "SPRUCE_FENCE", "BIRCH_FENCE", "JUNGLE_FENCE", "ACACIA_FENCE", "DARK_OAK_FENCE", "CRIMSON_FENCE", "WARPED_FENCE", "NETHER_BRICK_FENCE"), yamlConfiguration);
*/
if (!yamlConfiguration.contains("Advanced.UseItem.ItemBlockBlacklist")) {
List<String> materialList = Arrays.asList("BUTTON", "DOOR", "FENCE", "CHEST", "FURNACE", "NOTE_BLOCK", "CRAFTING_TABLE", "WORKBENCH",
"ANVIL", "LOOM", "COMPOSTER", "BARREL", "SMOKER", "BLAST_FURNACE", "CARTOGRAPHY_TABLE", "FLETCHING_TABLE", "GRINDSTONE",
"SMITHING_TABLE", "STONECUTTER", "HOPPER", "DISPENSER", "DROPPER", "REPEATER", "COMPARATOR", "LEVER", "DAYLIGHT_DETECTOR", "BREWING_STAND", "TRAPDOOR", "BEACON"
);
List<String> materialBlacklist = new ArrayList<>();
for (Material material : Material.values()) {
for (String target : materialList) {
if (material.toString().contains(target)) materialBlacklist.add(material.toString());
}
}
Config.set("Advanced.UseItem.ItemBlockBlacklist", materialBlacklist, yamlConfiguration);
}
2022-04-16 12:32:22 +00:00
Config.set("Toggle.Items.OnOrYes.Item.Base64.Enable", false, yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration);
if (Main.legacy) {
Config.set("Toggle.Items.OnOrYes.Item.Material", "WOOL,5", yamlConfiguration);
} else Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), yamlConfiguration);
2022-04-16 12:32:22 +00:00
Config.set("Toggle.Items.OffOrNo.Item.Base64.Enable", false, yamlConfiguration);
Config.set("Toggle.Items.OffOrNo.Item.Base64.Base64Value", "", yamlConfiguration);
if (Main.legacy) {
Config.set("Toggle.Items.OffOrNo.Item.Material", "WOOL,14", yamlConfiguration);
} else Config.set("Toggle.Items.OffOrNo.Item.Material", ItemVersion.getRedWool().getType().toString(), yamlConfiguration);
2022-04-16 12:32:22 +00:00
Config.set("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true", yamlConfiguration);
Config.set("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false", yamlConfiguration);
Config.set("Placeholder.True", "&2true", yamlConfiguration);
Config.set("Placeholder.False", "&4false", yamlConfiguration);
2022-01-06 01:21:27 +00:00
Config.set("Sound.Enable", true, yamlConfiguration);
Config.set("Sound.OpenInventory.Enable", true, yamlConfiguration);
if (MCVersion.minecraft1_8) {
Config.set("Sound.OpenInventory.Sound", "CHEST_OPEN", yamlConfiguration);
} else Config.set("Sound.OpenInventory.Sound", "BLOCK_CHEST_OPEN", yamlConfiguration);
Config.set("Sound.Click.Enable", true, yamlConfiguration);
if (MCVersion.minecraft1_8) {
Config.set("Sound.Click.Sound", "NOTE_STICKS", yamlConfiguration);
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
Config.set("Sound.Click.Sound", "BLOCK_NOTE_HAT", yamlConfiguration);
} else Config.set("Sound.Click.Sound", "BLOCK_NOTE_BLOCK_HAT", yamlConfiguration);
Config.set("Sound.NoMoney.Enable", true, yamlConfiguration);
if (MCVersion.minecraft1_8) {
Config.set("Sound.NoMoney.Sound", "NOTE_PIANO", yamlConfiguration);
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
Config.set("Sound.NoMoney.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
} else Config.set("Sound.NoMoney.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
Config.set("Sound.NoInventorySpace.Enable", true, yamlConfiguration);
if (MCVersion.minecraft1_8) {
Config.set("Sound.NoInventorySpace.Sound", "NOTE_PIANO", yamlConfiguration);
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
Config.set("Sound.NoInventorySpace.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
} else Config.set("Sound.NoInventorySpace.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
Config.set("Sound.Give.Enable", true, yamlConfiguration);
if (MCVersion.minecraft1_8) {
Config.set("Sound.Give.Sound", "LEVEL_UP", yamlConfiguration);
} else Config.set("Sound.Give.Sound", "ENTITY_PLAYER_LEVELUP", yamlConfiguration);
Config.set("Sound.PlayerNotFound.Enable", true, yamlConfiguration);
if (MCVersion.minecraft1_8) {
Config.set("Sound.PlayerNotFound.Sound", "NOTE_PIANO", yamlConfiguration);
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
Config.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
} else Config.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
2022-01-06 01:21:27 +00:00
}
}