202 lines
13 KiB
Java
202 lines
13 KiB
Java
package de.jatitv.commandguiv2.Spigot.config.config;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.Main;
|
|
import de.jatitv.commandguiv2.Util;
|
|
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
|
|
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;
|
|
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 ConfigCreate {
|
|
|
|
|
|
public static void configCreate() {
|
|
long long_ = 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);
|
|
|
|
if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
|
|
|
|
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);
|
|
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);
|
|
|
|
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);
|
|
}
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
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();
|
|
}
|
|
send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
}
|
|
}
|