diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/Config.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/Config.java new file mode 100644 index 0000000..c54f982 --- /dev/null +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/Config.java @@ -0,0 +1,671 @@ +package net.t2code.commandguiv2.Spigot.config.config; + +import net.t2code.commandguiv2.Spigot.Main; +import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; +import net.t2code.commandguiv2.Util; +import net.t2code.t2codelib.SPIGOT.api.items.T2C_ItemVersion; +import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send; +import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion; +import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter; +import net.t2code.t2codelib.util.T2C_ConfigItem; +import net.t2code.t2codelib.util.T2C_LanguageEnum; +import org.bukkit.Material; +import org.bukkit.Sound; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +public class Config { + + public static enum VALUES implements T2C_ConfigItem { + + Debug("Plugin.Debug", false, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + + updateCheckOnJoin("Plugin.updateCheck.onJoin", true, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + updateCheckSeePreReleaseUpdates("Plugin.updateCheck.seePreReleaseUpdates", true, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + updateCheckTimeInterval("Plugin.updateCheck.timeInterval", 60, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + HelpAlias("Plugin.HelpAlias", true, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + adminSubCommand("Plugin.AdminSubCommand", "admin", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + language("Plugin.language", T2C_LanguageEnum.english, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + Currency("Plugin.Currency", "$", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + DefaultGUI("Plugin.DefaultGUI", "default", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + prefix("Plugin.Prefix", "&8[&4C&9GUI&8]", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + + storage("Storage.Type", Main.legacy ? "YML" : "SQLITE", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of("Speichermöglichkeiten: YML, SQLITE, MYSQL")); + put(T2C_LanguageEnum.english, List.of()); + }}), + + mysqlIp("Storage.MySQL.IP", "localhost", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + mysqlPort("Storage.MySQL.Port", 3306, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + mysqlDatabase("Storage.MySQL.Database", "database", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + mysqlUser("Storage.MySQL.User", "user", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + mysqlPassword("Storage.MySQL.Password", "password", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + mysqlSSL("Storage.MySQL.SSL", false, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + + UseItem_Enable("UseItem.Enable", true, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + UseItem_AllowToggle("UseItem.AllowToggle", true, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + UseItem_AllowSetSlot("UseItem.AllowSetSlot", true, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + UseItem_BlockMoveAndDrop("UseItem.BlockMoveAndDrop", true, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + UseItem_OpenGUI("UseItem.OpenGUI", "default", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + UseItem_Permission("UseItem.Permission.NeededToUse", true, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + UseItem_KeepAtCommandClear("UseItem.KeepAtCommandClear", true, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + + UseItem_InventorySlot_FreeSlot("UseItem.InventorySlot.FreeSlot", 1, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + UseItem_InventorySlot("UseItem.InventorySlot.Slot", false, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + UseItem_InventorySlotEnforce("UseItem.InventorySlot.SlotEnforce", false, true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + UseItem_Material("UseItem.Item.Material", "paper", true, + new HashMap<>() {{ + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + }}), + + UseItem_PlayerHead_Enable(isHead() ? "UseItem.Item.PlayerHead.Enable" : null, false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItem_Base64_Enable(isHead() ? "UseItem.Item.PlayerHead.Base64.Enable" : null, false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItem_Base64value(isHead() ? "UseItem.Item.PlayerHead.Base64.Base64Value" : null, "", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItem_PlayerWhoHasOpenedTheGUI(isHead() ? "UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI" : null, false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItem_PlayerName(isHead() ? "UseItem.Item.PlayerHead.PlayerName" : null, "", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItem_Name("UseItem.Item.Name", "&bDefault &6GUI", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItem_Lore("UseItem.Item.Lore", List.of("&eThis is an example GUI"), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItem_GiveOnEveryJoin("UseItem.Join.GiveOnEveryJoin", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItem_GiveOnlyOnFirstJoin("UseItem.Join.GiveOnlyOnFirstJoin", false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Cursor_ToGUIItem_OnLogin("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Cursor_ToGUIItem_OnlyOnFirstLogin("UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItem_ServerChange("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + toggleItemOnOrYesBase64("Toggle.Items.OnOrYes.Item.Base64.Enable", false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + toggleItemOnOrYesBase64Value("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + toggleItemOnOrYesMaterial("Toggle.Items.OnOrYes.Item.Material", Main.legacy ? "WOOL,5" : T2C_ItemVersion.getGreenWool().getType().toString(), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + toggleItemOffOrNoBase64("Toggle.Items.OffOrNo.Item.Base64.Enable", false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + toggleItemOffOrNoBase64Value("Toggle.Items.OffOrNo.Item.Base64.Base64Value", "", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + toggleItemOffOrNoMaterial("Toggle.Items.OffOrNo.Item.Material", Main.legacy ? "WOOL,14" : T2C_ItemVersion.getRedWool().getType().toString(), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + togglePermTrue("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + togglePermFalse("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + placeholderTrue("Placeholder.True", "&2true", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + + placeholderFalse("Placeholder.False", "&4false", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + + + Sound_Enable("Sound.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_OpenInventory_Enable("Sound.OpenInventory.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_OpenInventory_input("Sound.OpenInventory.Sound", getSoundOpenInventory(), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_Click_Enable("Sound.Click.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_Click_input("Sound.Click.Sound", getSoundClick(), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_NoMoney_Enable("Sound.NoMoney.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_NoMoney_input("Sound.NoMoney.Sound", getSoundNoMoney(), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + + Sound_NoInventorySpace_Enable("Sound.NoInventorySpace.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_NoInventorySpace_input("Sound.NoInventorySpace.Sound", getSoundNoInventorySpace(), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_Give_Enable("Sound.Give.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_Give_input("Sound.Give.Sound", getSoundGive(), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_PlayerNotFound_Enable("Sound.PlayerNotFound.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + Sound_PlayerNotFound_input("Sound.PlayerNotFound.Sound", getSoundPlayerNotFound(), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + + + UseItemGameModeChangeEnable("Advanced.UseItem.GameMode.Change.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItemGameModeChangeDelayInTicks("Advanced.UseItem.GameMode.Change.DelayInTicks", 1, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItemGameModeProtection("Advanced.UseItem.GameMode.Protection.Enable", false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItemGameModeRemoveItemWhenItIsDisabled("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled", false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItemGameModeMode("Advanced.UseItem.GameMode.Protection.Mode", "blacklist", true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + + UseItemGameModeList("Advanced.UseItem.GameMode.Protection.List", List.of("CREATIVE", "SPECTATOR"), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + + UseItemWorldChangeEnable("Advanced.UseItem.World.Change.Enable", true, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItemWorldChangeDelayInTicks("Advanced.UseItem.World.Change.DelayInTicks", 1, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItemWorldProtection("Advanced.UseItem.World.Protection.Enable", false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItemWorldRemoveItemWhenItIsDisabled("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", false, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItemWorldMode("Advanced.UseItem.World.Protection.Mode", List.of("CREATIVE", "Spectator"), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + UseItemWorldList("Advanced.UseItem.World.Protection.List", List.of("World1", "World2"), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + + + // if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null) { + // disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak"); + // } + disableInfoBySneak("Advanced.UseItem.DisableInfoBySneak", null, true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + + UseItemItemBlockBlacklist("Advanced.UseItem.ItemBlockBlacklist", getItemBlockBlacklist(), true, + new HashMap<>() { + { + put(T2C_LanguageEnum.german, List.of()); + put(T2C_LanguageEnum.english, List.of()); + } + }), + + ; + private final String path; + private Object value; + private final boolean forceSet; + private final HashMap> comments; + + VALUES(String path, Object value, boolean forceSet, HashMap> comments) { + this.path = path; + this.value = value; + this.forceSet = forceSet; + this.comments = comments; + } + + @Override + public String getPath() { + return path; + } + + @Override + public Object getValue() { + return value; + } + + @Override + public boolean getForceSet() { + return forceSet; + } + + @Override + public HashMap> getComments() { + return comments; + } + + @Override + public String getLanguagePath() { + return language.path; + } + + @Override + public void setValue(Object newValue) { + value = newValue; + } + } + + public static void set(boolean isReload) { + T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "config.yml"), VALUES.values(), isReload, Util.getConfigLogo()); + } + + + private static boolean isHead() { + if (!(T2C_McVersion.isMc1_8() || T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12())) { + return true; + } else return false; + } + + private static String getSoundOpenInventory() { + if (T2C_McVersion.isMc1_8()) { + return "CHEST_OPEN"; + } + return "BLOCK_CHEST_OPEN"; + + } + + private static String getSoundClick() { + if (T2C_McVersion.isMc1_8()) { + return "NOTE_STICKS"; + } else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) { + return "BLOCK_NOTE_HAT"; + } + return "BLOCK_NOTE_BLOCK_HAT"; + } + + private static String getSoundNoMoney() { + if (T2C_McVersion.isMc1_8()) { + return "NOTE_PIANO"; + } else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) { + return "BLOCK_NOTE_HARP"; + } + return "BLOCK_NOTE_BLOCK_HARP"; + } + + private static String getSoundNoInventorySpace() { + if (T2C_McVersion.isMc1_8()) { + return "NOTE_PIANO"; + } else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) { + return "BLOCK_NOTE_BASS"; + } + return "BLOCK_NOTE_BLOCK_GUITAR"; + } + + private static String getSoundGive() { + if (T2C_McVersion.isMc1_8()) { + return "LEVEL_UP"; + } + return "ENTITY_PLAYER_LEVELUP"; + } + + private static String getSoundPlayerNotFound() { + if (T2C_McVersion.isMc1_8()) { + return "NOTE_PIANO"; + } else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) { + return "BLOCK_NOTE_HARP"; + } else { + return "BLOCK_NOTE_BLOCK_HARP"; + } + } + + private static List getItemBlockBlacklist() { + List 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 materialBlacklist = new ArrayList<>(); + for (Material material : Material.values()) { + for (String target : materialList) { + if (material.toString().contains(target)) { + materialBlacklist.add(material.toString()); + } + } + } + return materialBlacklist; + } + + private static void checkSounds() { + checkSound(VALUES.Sound_OpenInventory_input, getSoundOpenInventory()); + checkSound(VALUES.Sound_Click_input, getSoundOpenInventory()); + checkSound(VALUES.Sound_NoMoney_input, getSoundOpenInventory()); + checkSound(VALUES.Sound_NoInventorySpace_input, getSoundOpenInventory()); + checkSound(VALUES.Sound_Give_input, getSoundOpenInventory()); + checkSound(VALUES.Sound_PlayerNotFound_input, getSoundOpenInventory()); + } + + private static void checkSound(VALUES item, String defaultSound) { + try { + item.setValue(Sound.valueOf(item.value.toString()).toString()); + } catch (Exception e) { + T2C_Send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Util.getPrefix()) + .replace("[sound]", "§8" + item.getPath() + item.value.toString()) + "§4\n§4\n§4\n"); + item.setValue(Sound.valueOf(defaultSound).toString()); + } + } +} diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigCreate.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigCreate.java index 41bd8cd..6362226 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigCreate.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/ConfigCreate.java @@ -4,6 +4,7 @@ import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Util; import net.t2code.t2codelib.SPIGOT.api.items.T2C_ItemVersion; +import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Replace; import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion; import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter; @@ -16,69 +17,10 @@ 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.HashMap; -import java.util.List; +import java.util.*; public class ConfigCreate { - public static enum VALUES implements T2C_ConfigItem { - subAliasTab("", null, true, - new HashMap<>() {{ - put(T2C_LanguageEnum.german, List.of()); - put(T2C_LanguageEnum.english, List.of()); }}), - ; - - private final String path; - private Object value; - private final boolean forceSet; - private final HashMap> comments; - - VALUES(String path, Object value, boolean forceSet, HashMap> comments) { - this.path = path; - this.value = value; - this.forceSet = forceSet; - this.comments = comments; - } - - @Override - public String getPath() { - return path; - } - - @Override - public Object getValue() { - return value; - } - - @Override - public boolean getForceSet() { - return forceSet; - } - - @Override - public HashMap> getComments() { - return comments; - } - - @Override - public String getLanguagePath() { - return language.path; - } - - @Override - public void setValue(Object newValue) { - value = newValue; - } - } - - public static void set(boolean isReload) { - T2C_ConfigWriter.createConfig(Util.getPrefix(),new File(Main.getPath(), "config.yml"), VALUES.values(),isReload, Util.getConfigLogo()); - } - - - public static void configCreate() { long long_ = System.currentTimeMillis(); if (new File(Main.getPath(), "config.yml").exists()) { @@ -221,7 +163,7 @@ public class ConfigCreate { T2Cconfig.set("Advanced.UseItem.World.Change.DelayInTicks", 1, yamlConfiguration); T2Cconfig.set("Advanced.UseItem.World.Protection.Enable", false, yamlConfiguration); T2Cconfig.set("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration); - T2Cconfig.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration); + T2Cconfig.set("Advanced.UseItem.World.Protection.Mode", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration); T2Cconfig.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration); if (!yamlConfiguration.contains("Advanced.UseItem.ItemBlockBlacklist")) { @@ -246,63 +188,4 @@ public class ConfigCreate { } T2C_Send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } - - - public static void sound(String Prefix) { - String soundOpenInventory; - if (T2C_McVersion.isMc1_8()) { - soundOpenInventory = "CHEST_OPEN"; - } else { - soundOpenInventory = "BLOCK_CHEST_OPEN"; - } - - String soundClick; - if (T2C_McVersion.isMc1_8()) { - soundClick = "NOTE_STICKS"; - } else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) { - soundClick = "BLOCK_NOTE_HAT"; - } else { - soundClick = "BLOCK_NOTE_BLOCK_HAT"; - } - - String soundNoMoney; - if (T2C_McVersion.isMc1_8()) { - soundNoMoney = "NOTE_PIANO"; - } else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) { - soundNoMoney = "BLOCK_NOTE_HARP"; - } else { - soundNoMoney = "BLOCK_NOTE_BLOCK_HARP"; - } - - String soundNoInventorySpace; - if (T2C_McVersion.isMc1_8()) { - soundNoInventorySpace = "NOTE_PIANO"; - } else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) { - soundNoInventorySpace = "BLOCK_NOTE_BASS"; - } else { - soundNoInventorySpace = "BLOCK_NOTE_BLOCK_GUITAR"; - } - - String soundGive; - if (T2C_McVersion.isMc1_8()) { - soundGive = "LEVEL_UP"; - } else { - soundGive = "ENTITY_PLAYER_LEVELUP"; - } - - String soundPlayerNotFound; - if (T2C_McVersion.isMc1_8()) { - soundPlayerNotFound = "NOTE_PIANO"; - } else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) { - soundPlayerNotFound = "BLOCK_NOTE_HARP"; - } else { - soundPlayerNotFound = "BLOCK_NOTE_BLOCK_HARP"; - } - } - private static String Sound_OpenInventory; - private static String Sound_Click; - private static String Sound_NoMoney; - private static String Sound_NoInventorySpace; - private static String soundGive; - private static String soundPlayerNotFound; } diff --git a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/SelectConfig.java b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/SelectConfig.java index f9d75a6..ee96b63 100644 --- a/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/SelectConfig.java +++ b/CommandGUI V2/src/main/java/net/t2code/commandguiv2/Spigot/config/config/SelectConfig.java @@ -98,13 +98,15 @@ public class SelectConfig { placeholderTrue = yamlConfiguration.getString("Placeholder.True"); placeholderFalse = yamlConfiguration.getString("Placeholder.False"); + + Sound_Enable = yamlConfiguration.getBoolean("Sound.Enable"); Sound_OpenInventory_Enable = yamlConfiguration.getBoolean("Sound.OpenInventory.Enable"); Sound_OpenInventory_input = (yamlConfiguration.getString("Sound.OpenInventory.Sound").toUpperCase().replace(".", "_")); Sound_Click_Enable = yamlConfiguration.getBoolean("Sound.Click.Enable"); Sound_Click_input = (yamlConfiguration.getString("Sound.Click.Sound").toUpperCase().replace(".", "_")); Sound_NoMoney_Enable = yamlConfiguration.getBoolean("Sound.NoMoney.Enable"); - Sound_NoMoney_input = (yamlConfiguration.getString("Sound.NoMoney.Sound").toUpperCase().replace(".", "_")); + Sound_Click_input = (yamlConfiguration.getString("Sound.NoMoney.Sound").toUpperCase().replace(".", "_")); Sound_NoInventorySpace_Enable = yamlConfiguration.getBoolean("Sound.NoInventorySpace.Enable"); Sound_NoInventorySpace_input = (yamlConfiguration.getString("Sound.NoInventorySpace.Sound").toUpperCase().replace(".", "_")); @@ -113,16 +115,15 @@ public class SelectConfig { Sound_PlayerNotFound_Enable = yamlConfiguration.getBoolean("Sound.PlayerNotFound.Enable"); Sound_PlayerNotFound_input = (yamlConfiguration.getString("Sound.PlayerNotFound.Sound").toUpperCase().replace(".", "_")); + + //todo noch zu neu config UseItemGameModeChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Change.Enable"); UseItemGameModeChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.GameMode.Change.DelayInTicks"); UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.Enable"); UseItemGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled"); UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameMode.Protection.Mode"); - List gml = new ArrayList<>(); - for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")) { - gml.add(gm.toUpperCase()); - } - UseItemGameModeList = gml; + + UseItemGameModeList = yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List"); UseItemWorldChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.World.Change.Enable"); UseItemWorldChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.World.Change.DelayInTicks"); @@ -248,10 +249,7 @@ public class SelectConfig { } try { - Sound sound_PlayerNotFound = Sound.valueOf(Sound_PlayerNotFound_input); - if (sound_PlayerNotFound != null) { - Sound_PlayerNotFound = sound_PlayerNotFound; - } + Sound_PlayerNotFound = Sound.valueOf(Sound_PlayerNotFound_input); } catch (Exception e) { T2C_Send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix) .replace("[sound]", "§8PlayerNotFound: §6" + Sound_PlayerNotFound_input) + "§4\n§4\n§4\n");