config recode in enum

This commit is contained in:
JaTiTV 2022-12-30 23:05:24 +01:00
parent cc9648315f
commit f68916ef54
24 changed files with 709 additions and 594 deletions

View File

@ -75,7 +75,8 @@
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>14.1</version> <version>DEV-14.2</version>
<classifier>1</classifier>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>

View File

@ -1,6 +1,7 @@
package net.t2code.commandguiv2.Spigot.cmdManagement; package net.t2code.commandguiv2.Spigot.cmdManagement;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig;
import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI; import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
@ -30,7 +31,7 @@ public class CmdExecuter_GUI implements CommandExecutor, TabCompleter {
Player player = (Player) sender; Player player = (Player) sender;
Commands.gui(player); Commands.gui(player);
} else { } else {
if (args[0].equals(SelectConfig.getAdminSubCommand())) { if (args[0].equals(String.valueOf(Config.adminSubCommand.value))) {
if (args.length == 1) { if (args.length == 1) {
Help.sendHelp(sender, prefix); Help.sendHelp(sender, prefix);
return false; return false;
@ -105,7 +106,7 @@ public class CmdExecuter_GUI implements CommandExecutor, TabCompleter {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
T2Ctab.tab(list, sender, 0, args, arg1); T2Ctab.tab(list, sender, 0, args, arg1);
T2Ctab.tab(list, sender, 0, SelectConfig.getAdminSubCommand(), 1, args, arg2); T2Ctab.tab(list, sender, 0, String.valueOf(Config.adminSubCommand.value), 1, args, arg2);
T2Ctab.tab(list, sender, 1, "give", 2, args, "commandgui.giveitem.other", true); T2Ctab.tab(list, sender, 1, "give", 2, args, "commandgui.giveitem.other", true);
return list; return list;
} }

View File

@ -1,5 +1,6 @@
package net.t2code.commandguiv2.Spigot.cmdManagement; package net.t2code.commandguiv2.Spigot.cmdManagement;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
@ -22,13 +23,13 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
Player player = (Player) sender; Player player = (Player) sender;
if (sender.hasPermission("commandgui.useitem.toggle")) { if (sender.hasPermission("commandgui.useitem.toggle")) {
if (args.length == 0) { if (args.length == 0) {
if (SelectConfig.getUseItem_AllowToggle()) { if ((Boolean) Config.useItemAllowToggle.value) {
Help.sendGUIItemHelp(sender); Help.sendGUIItemHelp(sender);
} else T2Csend.sender(sender, "§4UseItem toggle is disabled!");// todo } else T2Csend.sender(sender, "§4UseItem toggle is disabled!");// todo
} else { } else {
if (args.length == 1 || args.length == 2) { if (args.length == 1 || args.length == 2) {
if (sender instanceof Player) { if (sender instanceof Player) {
if (SelectConfig.getUseItem_AllowToggle()) { if ((Boolean) Config.useItemAllowToggle.value) {
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "on": case "on":
Commands.itemOn(player); Commands.itemOn(player);
@ -65,7 +66,7 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{ private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("on", "commandgui.useitem.toggle"); put("on", "commandgui.useitem.toggle");
put("off", "commandgui.useitem.toggle"); put("off", "commandgui.useitem.toggle");
if (SelectConfig.getUseItem_AllowSetSlot()) { if ((Boolean) Config.useItemAllowToggle.value) {
put("slot", "commandgui.useitem.toggle"); put("slot", "commandgui.useitem.toggle");
} }
}}; }};
@ -74,7 +75,7 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) { public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
if (sender instanceof Player) { if (sender instanceof Player) {
if (SelectConfig.getUseItem_AllowToggle()) { if ((Boolean) Config.useItemAllowToggle.value) {
Player p = (Player) sender; Player p = (Player) sender;
if (args.length == 1) { if (args.length == 1) {
for (String command : arg1.keySet()) { for (String command : arg1.keySet()) {

View File

@ -1,5 +1,7 @@
package net.t2code.commandguiv2.Spigot.cmdManagement; package net.t2code.commandguiv2.Spigot.cmdManagement;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.useItem.Events;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.objects.Obj_Select; import net.t2code.commandguiv2.Spigot.objects.Obj_Select;
@ -37,13 +39,13 @@ public class Commands {
T2Csend.console(Util.getPrefix() + "§8-------------------------------"); T2Csend.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + " §6Plugin reload..."); T2Csend.console(Util.getPrefix() + " §6Plugin reload...");
T2Csend.console(Util.getPrefix() + "§8-------------------------------"); T2Csend.console(Util.getPrefix() + "§8-------------------------------");
SelectConfig.onSelect(); ConfigSelect.selectConfig();
Main.getPlugin().reloadConfig(); Main.getPlugin().reloadConfig();
CmdExecuter_GUI.arg1.clear(); CmdExecuter_GUI.arg1.clear();
CmdExecuter_GUI.arg1.put(SelectConfig.getAdminSubCommand(), "commandgui.admin;commandgui.giveitem.other;commandgui.command.info"); CmdExecuter_GUI.arg1.put(String.valueOf(Config.adminSubCommand.value), "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.getStorage())) { if (!Objects.equals(SelectDatabase.getStorage().toString(), Config.storage.value)) {
if (sender instanceof Player) T2Csend.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!"); if (sender instanceof Player) T2Csend.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!");
T2Csend.warning(Main.getPlugin(), "You have changed the storage medium! To apply this change, you must restart the server!"); T2Csend.warning(Main.getPlugin(), "You have changed the storage medium! To apply this change, you must restart the server!");
} }
@ -52,7 +54,7 @@ public class Commands {
Obj_Select.onSelect(); Obj_Select.onSelect();
SelectMessages.onSelect(Util.getPrefix()); SelectMessages.onSelect(Util.getPrefix());
SelectConfig.sound(Util.getPrefix()); Config.sound();
try { try {
AliasRegister.onRegister(); AliasRegister.onRegister();
@ -81,8 +83,8 @@ public class Commands {
public static void give(CommandSender sender, Player target) { public static void give(CommandSender sender, Player target) {
if (Bukkit.getPlayer(target.getName()) != null) { if (Bukkit.getPlayer(target.getName()) != null) {
UseItem.giveUseItem(target); UseItem.giveUseItem(target);
T2Csend.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", SelectConfig.getUseItem_Name())); T2Csend.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", String.valueOf(Config.useItemName.value)));
T2Csend.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", SelectConfig.getUseItem_Name())); T2Csend.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]",String.valueOf(Config.useItemName.value)));
Sound.play(target, SoundEnum.Give); Sound.play(target, SoundEnum.Give);
} else { } else {
sender.sendMessage(SelectMessages.PlayerNotFond.replace("[player]", target.getName())); sender.sendMessage(SelectMessages.PlayerNotFond.replace("[player]", target.getName()));
@ -93,8 +95,8 @@ public class Commands {
public static void itemOn(Player player) { public static void itemOn(Player player) {
UseItem.removeItem(player); UseItem.removeItem(player);
Integer slot = null; Integer slot = null;
if (SelectConfig.getUseItem_InventorySlotEnforce()) { if ((Boolean) Config.useItemInventorySlotEnforce.value) {
slot = SelectConfig.getUseItem_InventorySlot(); slot = (Integer) Config.useItemInventorySlot.value;
} else { } else {
slot = Events.useItemSlotHashMap.get(player.getName()); slot = Events.useItemSlotHashMap.get(player.getName());
} }
@ -128,7 +130,7 @@ public class Commands {
} }
public static void onSetSlot(Player player, Integer setSlot) { public static void onSetSlot(Player player, Integer setSlot) {
if (!SelectConfig.getUseItem_AllowSetSlot()) { if (!(Boolean) Config.useItemAllowSetSlot.value) {
T2Csend.player(player, Util.getPrefix() + " §4Function disabled"); T2Csend.player(player, Util.getPrefix() + " §4Function disabled");
return; return;
} }
@ -149,7 +151,7 @@ public class Commands {
} }
} }
if (SelectConfig.getUseItem_InventorySlotEnforce() || player.getInventory().getItem(setSlot - 1) != null) { if ((Boolean) Config.useItemInventorySlotEnforce.value || player.getInventory().getItem(setSlot - 1) != null) {
T2Csend.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString())); T2Csend.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
return; return;
} }
@ -166,11 +168,11 @@ public class Commands {
} }
public static void gui(Player player) { public static void gui(Player player) {
if (Main.guiHashMap.containsKey(SelectConfig.getDefaultGUI())) { if (Main.guiHashMap.containsKey(String.valueOf(Config.defaultGUI.value))) {
Gui gui = Main.guiHashMap.get(SelectConfig.getDefaultGUI()); Gui gui = Main.guiHashMap.get(String.valueOf(Config.defaultGUI.value));
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) { if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, SelectConfig.getDefaultGUI(), true); OpenGUI.openGUI(player, String.valueOf(Config.defaultGUI.value), true);
} else T2Csend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui") } else T2Csend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui")
.replace("[perm]", "commandgui.command")); .replace("[perm]", "commandgui.command"));
} else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName)); } else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));

View File

@ -1,5 +1,6 @@
package net.t2code.commandguiv2.Spigot.cmdManagement; package net.t2code.commandguiv2.Spigot.cmdManagement;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui; import net.t2code.commandguiv2.Spigot.objects.guis.Gui;
@ -14,7 +15,7 @@ public class Help {
private static String prefix = Util.getPrefix(); private static String prefix = Util.getPrefix();
public static void sendHelp(CommandSender sender, String Prefix) { public static void sendHelp(CommandSender sender, String Prefix) {
Gui gui = Main.guiHashMap.get(SelectConfig.getDefaultGUI()); Gui gui = Main.guiHashMap.get(String.valueOf(Config.defaultGUI.value));
T2Csend.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----"); T2Csend.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----");
cgui(sender, gui); cgui(sender, gui);

View File

@ -1,115 +1,204 @@
package net.t2code.commandguiv2.Spigot.config.config; package net.t2code.commandguiv2.Spigot.config.config;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.enums.StorageEnum;
import net.t2code.commandguiv2.Util;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Material;
import org.bukkit.Sound;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List;
public enum Config { public enum Config {
debug("Plugins.Debug", false), configVersion("ConfigVersion", 6, true),
updateCheckOnJoin("Plugin.updateCheck.onJoin", true), debug("Plugins.Debug", false, false),
updateCheckSeePreReleaseUpdates("Plugin.updateCheck.seePreReleaseUpdates", true), updateCheckOnJoin("Plugin.updateCheck.onJoin", true, false),
updateCheckTimeInterval("Plugin.updateCheck.timeInterval", 60), updateCheckSeePreReleaseUpdates("Plugin.updateCheck.seePreReleaseUpdates", true, false),
helpAlias("Plugin.HelpAlias", true), updateCheckTimeInterval("Plugin.updateCheck.timeInterval", 60, false),
adminSubCommand("Plugin.AdminSubCommand", "admin"), helpAlias("Plugin.HelpAlias", true, false),
language("Plugin.language", "english"), adminSubCommand("Plugin.AdminSubCommand", "admin", false),
currency("Plugin.Currency", "$"), language("Plugin.language", "english", false),
defaultGUI("Plugin.DefaultGUI", "default"), currency("Plugin.Currency", "$", false),
defaultGUI("Plugin.DefaultGUI", "default", false),
storage("Storage.Type", "YML"), storage("Storage.Type", StorageEnum.SQLITE.name(), false),
mysqlIp("Storage.MySQL.IP", "localhost"), mysqlIp("Storage.MySQL.IP", "localhost", false),
mysqlPort("Storage.MySQL.Port", 3306), mysqlPort("Storage.MySQL.Port", 3306, false),
mysqlDatabase("Storage.MySQL.Database", "database"), mysqlDatabase("Storage.MySQL.Database", "database", false),
mysqlUser("Storage.MySQL.User", "root"), mysqlUser("Storage.MySQL.User", "root", false),
mysqlPassword("Storage.MySQL.Password", "password"), mysqlPassword("Storage.MySQL.Password", "password", false),
mysqlSSL("Storage.MySQL.SSL", false), mysqlSSL("Storage.MySQL.SSL", false, false),
useItem_Enable("UseItem.Enable", true), useItemEnable("UseItem.Enable", true, false),
UseItem_AllowToggle("UseItem.AllowToggle", true), useItemAllowToggle("UseItem.AllowToggle", true, false),
UseItem_AllowSetSlot("UseItem.AllowSetSlot", true), useItemAllowSetSlot("UseItem.AllowSetSlot", true, false),
UseItem_BlockMoveAndDrop("UseItem.BlockMoveAndDrop", true), useItemBlockMoveAndDrop("UseItem.BlockMoveAndDrop", true, false),
UseItem_OpenGUI("UseItem.OpenGUI", "default"), useItemOpenGUI("UseItem.OpenGUI", "default", false),
UseItem_Permission("UseItem.Permission.NeededToUse", true), useItemPermission("UseItem.Permission.NeededToUse", true, false),
UseItem_KeepAtCommandClear("UseItem.KeepAtCommandClear", true), useItemKeepAtCommandClear("UseItem.KeepAtCommandClear", true, false),
UseItem_InventorySlot_FreeSlot("UseItem.InventorySlot.FreeSlot", 1), useItemInventorySlotFreeSlot("UseItem.InventorySlot.FreeSlot", 1, false),
UseItem_InventorySlot("UseItem.InventorySlot.Slot", false), useItemInventorySlot("UseItem.InventorySlot.Slot", false, false),
UseItem_InventorySlotEnforce("UseItem.InventorySlot.SlotEnforce", false), useItemInventorySlotEnforce("UseItem.InventorySlot.SlotEnforce", false, false),
UseItem_Material("UseItem.Item.Material", "paper"), useItemMaterial("UseItem.Item.Material", "paper", false),
UseItem_PlayerHead_Enable("UseItem.Item.PlayerHead.Enable", false),
UseItem_Base64_Enable("UseItem.Item.PlayerHead.Base64.Enable", false), useItemPlayerHeadEnable("UseItem.Item.PlayerHead.Enable", false, false),
UseItem_Base64value("UseItem.Item.PlayerHead.Base64.Base64Value", ""), useItemBase64Enable("UseItem.Item.PlayerHead.Base64.Enable", false, false),
UseItem_PlayerWhoHasOpenedTheGUI("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false), useItemBase64value("UseItem.Item.PlayerHead.Base64.Base64Value", "", false),
UseItem_PlayerName("UseItem.Item.PlayerHead.PlayerName", ""), useItemPlayerWhoHasOpenedTheGUI("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, false),
UseItem_Name("UseItem.Item.Name", "&bDefault &6GUI"), useItemPlayerName("UseItem.Item.PlayerHead.PlayerName", "", false),
UseItem_Lore("UseItem.Item.Lore", Collections.singletonList("&eThis is an example GUI")), useItemName("UseItem.Item.Name", "&bDefault &6GUI", false),
UseItem_GiveOnEveryJoin("UseItem.Join.GiveOnEveryJoin", true), useItemLore("UseItem.Item.Lore", Collections.singletonList("&eThis is an example GUI"), false),
UseItem_GiveOnlyOnFirstJoin("UseItem.Join.GiveOnlyOnFirstJoin", false), useItemGiveOnEveryJoin("UseItem.Join.GiveOnEveryJoin", true, false),
Cursor_ToGUIItem_OnLogin("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", true), useItemGiveOnlyOnFirstJoin("UseItem.Join.GiveOnlyOnFirstJoin", false, false),
Cursor_ToGUIItem_OnlyOnFirstLogin("UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin", true), cursorToGUIItemOnLogin("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", true, false),
UseItem_ServerChange("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false), cursorToGUIItemOnlyOnFirstLogin("UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin", true, false),
useItemServerChange("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false, false),
toggleItemOnOrYesBase64("Toggle.Items.OnOrYes.Item.Base64.Enable", false), toggleItemOnOrYesBase64("Toggle.Items.OnOrYes.Item.Base64.Enable", false, false),
toggleItemOnOrYesBase64Value("Toggle.Items.OnOrYes.Item.Base64.Base64Value", ""), toggleItemOnOrYesBase64Value("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", false),
toggleItemOnOrYesMaterial("Toggle.Items.OnOrYes.Item.Material", Main.legacy ? "WOOL,5" : T2CitemVersion.getGreenWool().getType().toString()), toggleItemOnOrYesMaterial("Toggle.Items.OnOrYes.Item.Material", Main.legacy ? "WOOL,5" : T2CitemVersion.getGreenWool().getType().toString(), false),
toggleItemOffOrNoBase64("Toggle.Items.OffOrNo.Item.Base64.Enable", false), toggleItemOffOrNoBase64("Toggle.Items.OffOrNo.Item.Base64.Enable", false, false),
toggleItemOffOrNoBase64Value("Toggle.Items.OffOrNo.Item.Base64.Base64Value", T2CitemVersion.getGreenWool().getType().toString()), toggleItemOffOrNoBase64Value("Toggle.Items.OffOrNo.Item.Base64.Base64Value", T2CitemVersion.getGreenWool().getType().toString(), false),
toggleItemOffOrNoMaterial("Toggle.Items.OffOrNo.Item.Material", Main.legacy ? "WOOL,14" : T2CitemVersion.getRedWool().getType().toString()), toggleItemOffOrNoMaterial("Toggle.Items.OffOrNo.Item.Material", Main.legacy ? "WOOL,14" : T2CitemVersion.getRedWool().getType().toString(), false),
togglePermTrue("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true"), togglePermTrue("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true", false),
togglePermFalse("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false"), togglePermFalse("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false", false),
placeholderTrue("Placeholder.True", "&2true"), placeholderTrue("Placeholder.True", "&2true", false),
placeholderFalse("Placeholder.False", "&4false"), placeholderFalse("Placeholder.False", "&4false", false),
Sound_Enable("Sound.Enable", true), soundEnable("Sound.Enable", true, false),
Sound_OpenInventory_Enable("Sound.OpenInventory.Sound", true), soundOpenInventoryEnable("Sound.OpenInventory.Enable", true, false),
Sound_OpenInventory_input("Sound.OpenInventory.Sound", null), //todo sound create class soundOpenInventoryInput("Sound.OpenInventory.Sound", getOpenInventory().toString(), false),
Sound_Click_Enable("Sound.Click.Enable", null), soundClickEnable("Sound.Click.Enable", true, false),
Sound_Click_input("Sound.Click.Sound", null), soundClickInput("Sound.Click.Sound", getClick().toString(), false),
Sound_NoMoney_Enable("Sound.NoMoney.Enable", null), soundNoMoneyEnable("Sound.NoMoney.Enable", true, false),
Sound_NoMoney_input("Sound.NoMoney.Sound", null), soundNoMoneyInput("Sound.NoMoney.Sound", getNoMoney().toString(), false),
soundNoInventorySpaceEnable("Sound.NoInventorySpace.Enable", true, false),
soundNoInventorySpaceInput("Sound.NoInventorySpace.Sound", getNoInventorySpace().toString(), false),
soundGiveEnable("Sound.Give.Enable", true, false),
soundGiveInput("Sound.Give.Sound", getGive().toString(), false),
soundPlayerNotFoundEnable("Sound.PlayerNotFound.Enable", true, false),
soundPlayerNotFoundInput("Sound.PlayerNotFound.Sound", getPlayerNotFound().toString(), false),
Sound_NoInventorySpace_Enable("Sound.NoInventorySpace.Enable", null), useItemGameModeChangeEnable("Advanced.UseItem.GameMode.Change.Enable", true, false),
Sound_NoInventorySpace_input("Sound.NoInventorySpace.Sound", null), useItemGameModeChangeDelayInTicks("Advanced.UseItem.GameMode.Change.DelayInTicks", 1, false),
Sound_Give_Enable("Sound.Give.Enable", null), useItemGameModeProtection("Advanced.UseItem.GameMode.Protection.Enable", false, false),
Sound_Give_input("Sound.Give.Sound", null), useItemGameModeRemoveItemWhenItIsDisabled("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled", false, false),
Sound_PlayerNotFound_Enable("Sound.PlayerNotFound.Enable", null), useItemGameModeMode("Advanced.UseItem.GameMode.Protection.Mode", "blacklist", false),
Sound_PlayerNotFound_input("Sound.PlayerNotFound.Sound", null), useItemGameModeList("Advanced.UseItem.GameMode.Protection.List", Arrays.asList("CREATIVE", "Spectator"), false),
useItemWorldChangeEnable("Advanced.UseItem.World.Change.Enable", true, false),
useItemWorldChangeDelayInTicks("Advanced.UseItem.World.Change.DelayInTicks", 1, false),
useItemWorldProtection("Advanced.UseItem.World.Protection.Enable", false, false),
useItemWorldRemoveItemWhenItIsDisabled("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", false, false),
useItemWorldMode("Advanced.UseItem.World.Protection.Mode", "blacklist", false),
useItemWorldList("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), false),
UseItemGameModeChangeEnable("Advanced.UseItem.GameMode.Change.Enable", null), disableInfoBySneak("Advanced.UseItem.DisableInfoBySneak", false, false),
UseItemGameModeChangeDelayInTicks("Advanced.UseItem.GameMode.Change.DelayInTicks", null), useItemItemBlockBlacklist("Advanced.UseItem.ItemBlockBlacklist", getItemBlockBlacklist(), false);
UseItemGameModeProtection("Advanced.UseItem.GameMode.Protection.Enable", null),
UseItemGameModeRemoveItemWhenItIsDisabled("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled", null),
UseItemGameModeMode("Advanced.UseItem.GameMode.Protection.Mode", null),
UseItemGameModeList("Advanced.UseItem.GameMode.Protection.List", null),
UseItemWorldChangeEnable("Advanced.UseItem.World.Change.Enable", null),
UseItemWorldChangeDelayInTicks("Advanced.UseItem.World.Change.DelayInTicks", null),
UseItemWorldProtection("Advanced.UseItem.World.Protection.Enable", null),
UseItemWorldRemoveItemWhenItIsDisabled("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", null),
UseItemWorldMode("Advanced.UseItem.World.Protection.Mode", null),
UseItemWorldList("Advanced.UseItem.World.Protection.List", null),
disableInfoBySneak("Advanced.UseItem.DisableInfoBySneak", null),
UseItemItemBlockBlacklist("Advanced.UseItem.ItemBlockBlacklist", null);
public final String path; public final String path;
public Object value; public Object value;
public final boolean forceSet;
Config(String path, Object defaultValue) { Config(String path, Object defaultValue, boolean forceSet) {
this.path = path; this.path = path;
this.value = defaultValue; this.value = defaultValue;
this.forceSet = forceSet;
}
public static void sound() {
check(soundOpenInventoryInput,getOpenInventory());
check(soundNoMoneyInput,getNoMoney());
check(soundNoInventorySpaceInput,getNoInventorySpace());
check(soundGiveInput,getGive());
check(soundPlayerNotFoundInput,getPlayerNotFound());
}
private static void check(Config object, Sound defaultSound){
try {
Sound sound = Sound.valueOf(String.valueOf(object.value));
if (sound != null) {
object.value = defaultSound;
}
} catch (Exception e) {
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Util.getPrefix())
.replace("[sound]", "§8OpenInventory: §6" + object.value) + "§4\n§4\n§4\n");
object.value = defaultSound;
}
}
private static Sound getOpenInventory() {
if (T2CmcVersion.isMc1_8()) {
return Sound.valueOf("CHEST_OPEN");
} else return Sound.valueOf("BLOCK_CHEST_OPEN");
}
private static Sound getClick() {
if (T2CmcVersion.isMc1_8()) {
return Sound.valueOf("NOTE_STICKS");
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
return Sound.valueOf("BLOCK_NOTE_HAT");
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HAT");
}
private static Sound getNoMoney() {
if (T2CmcVersion.isMc1_8()) {
return Sound.valueOf("NOTE_PIANO");
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
return Sound.valueOf("BLOCK_NOTE_HARP");
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HARP");
}
private static Sound getNoInventorySpace() {
if (T2CmcVersion.isMc1_8()) {
return Sound.valueOf("NOTE_PIANO");
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
return Sound.valueOf("BLOCK_NOTE_HARP");
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HARP");
}
private static Sound getGive() {
if (T2CmcVersion.isMc1_8()) {
return Sound.valueOf("LEVEL_UP");
} else return Sound.valueOf("ENTITY_PLAYER_LEVELUP");
}
private static Sound getPlayerNotFound() {
if (T2CmcVersion.isMc1_8()) {
return Sound.valueOf("NOTE_PIANO");
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
return Sound.valueOf("BLOCK_NOTE_HARP");
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HARP");
}
private static List<String> getItemBlockBlacklist() {
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()) {
if (materialList.contains(material.toString())) materialBlacklist.add(material.toString());
}
return materialBlacklist;
} }
} }

View File

@ -14,9 +14,12 @@ public class ConfigSelect {
public static void selectConfig() { public static void selectConfig() {
File config = new File(Main.getPath(), "config.yml"); File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Config value : Config.values()) { for (Config value : Config.values()) {
T2Cconfig.set(value.path, value.value, yamlConfiguration); if (value.forceSet) {
value.value = T2Cconfig.selectObject(String.valueOf(Config.messagesPrefix.value), value.path, yamlConfiguration); yamlConfiguration.set(value.path, value.value);
} else T2Cconfig.set(value.path, value.value, yamlConfiguration);
value.value = T2Cconfig.selectObject(Util.getPrefix(), value.path, yamlConfiguration);
} }
try { try {

View File

@ -368,335 +368,335 @@ public class SelectConfig {
private static Sound Sound_PlayerNotFound; private static Sound Sound_PlayerNotFound;
private static String Sound_PlayerNotFound_input; private static String Sound_PlayerNotFound_input;
public static Boolean getDebug() { // public static Boolean getDebug() {
return Debug; // return Debug;
} // }
//
public static Boolean getUpdateCheckOnJoin() { // public static Boolean getUpdateCheckOnJoin() {
return updateCheckOnJoin; // return updateCheckOnJoin;
} // }
//
public static Boolean getUpdateCheckSeePreReleaseUpdates() { // public static Boolean getUpdateCheckSeePreReleaseUpdates() {
return updateCheckSeePreReleaseUpdates; // return updateCheckSeePreReleaseUpdates;
} // }
//
public static Integer getUpdateCheckTimeInterval() { // public static Integer getUpdateCheckTimeInterval() {
return updateCheckTimeInterval; // return updateCheckTimeInterval;
} // }
//
public static Boolean getHelpAlias() { // public static Boolean getHelpAlias() {
return HelpAlias; // return HelpAlias;
} // }
//
public static String getAdminSubCommand() { // public static String getAdminSubCommand() {
return adminSubCommand; // return adminSubCommand;
} // }
//
public static String getLanguage() { // public static String getLanguage() {
return language; // return language;
} // }
//
public static String getCurrency() { // public static String getCurrency() {
return Currency; // return Currency;
} // }
//
public static String getStorage() { // public static String getStorage() {
return storage; // return storage;
} // }
//
public static String getMysqlIp() { // public static String getMysqlIp() {
return mysqlIp; // return mysqlIp;
} // }
//
public static Integer getMysqlPort() { // public static Integer getMysqlPort() {
return mysqlPort; // return mysqlPort;
} // }
//
public static String getMysqlDatabase() { // public static String getMysqlDatabase() {
return mysqlDatabase; // return mysqlDatabase;
} // }
//
public static String getMysqlUser() { // public static String getMysqlUser() {
return mysqlUser; // return mysqlUser;
} // }
//
public static String getMysqlPassword() { // public static String getMysqlPassword() {
return mysqlPassword; // return mysqlPassword;
} // }
//
public static Boolean getMysqlSSL() { // public static Boolean getMysqlSSL() {
return mysqlSSL; // return mysqlSSL;
} // }
//
public static Boolean getBungee() { // public static Boolean getBungee() {
return Bungee; // return Bungee;
} // }
//
public static String getDefaultGUI() { // public static String getDefaultGUI() {
return DefaultGUI; // return DefaultGUI;
} // }
//
public static Boolean getUseItem_Enable() { // public static Boolean getUseItem_Enable() {
return UseItem_Enable; // return UseItem_Enable;
} // }
//
public static Boolean getUseItem_AllowToggle() { // public static Boolean getUseItem_AllowToggle() {
return UseItem_AllowToggle; // return UseItem_AllowToggle;
} // }
//
public static Boolean getUseItem_AllowSetSlot() { // public static Boolean getUseItem_AllowSetSlot() {
return UseItem_AllowSetSlot; // return UseItem_AllowSetSlot;
} // }
//
public static Boolean getUseItem_GiveOnEveryJoin() { // public static Boolean getUseItem_GiveOnEveryJoin() {
return UseItem_GiveOnEveryJoin; // return UseItem_GiveOnEveryJoin;
} // }
//
public static Boolean getUseItem_GiveOnlyOnFirstJoin() { // public static Boolean getUseItem_GiveOnlyOnFirstJoin() {
return UseItem_GiveOnlyOnFirstJoin; // return UseItem_GiveOnlyOnFirstJoin;
} // }
//
public static Boolean getUseItem_ServerChange() { // public static Boolean getUseItem_ServerChange() {
return UseItem_ServerChange; // return UseItem_ServerChange;
} // }
//
public static Boolean getCursor_ToGUIItem_OnLogin() { // public static Boolean getCursor_ToGUIItem_OnLogin() {
return Cursor_ToGUIItem_OnLogin; // return Cursor_ToGUIItem_OnLogin;
} // }
//
public static Boolean getCursor_ToGUIItem_OnlyOnFirstLogin() { // public static Boolean getCursor_ToGUIItem_OnlyOnFirstLogin() {
return Cursor_ToGUIItem_OnlyOnFirstLogin; // return Cursor_ToGUIItem_OnlyOnFirstLogin;
} // }
//
public static Boolean getUseItem_BlockMoveAndDrop() { // public static Boolean getUseItem_BlockMoveAndDrop() {
return UseItem_BlockMoveAndDrop; // return UseItem_BlockMoveAndDrop;
} // }
//
public static String getUseItem_OpenGUI() { // public static String getUseItem_OpenGUI() {
return UseItem_OpenGUI; // return UseItem_OpenGUI;
} // }
//
public static Boolean getUseItem_Permission() { // public static Boolean getUseItem_Permission() {
return UseItem_Permission; // return UseItem_Permission;
} // }
//
public static Boolean getUseItem_KeepAtCommandClear() { // public static Boolean getUseItem_KeepAtCommandClear() {
return UseItem_KeepAtCommandClear; // return UseItem_KeepAtCommandClear;
} // }
//
public static Boolean getUseItemGameModeChangeEnable() { // public static Boolean getUseItemGameModeChangeEnable() {
return UseItemGameModeChangeEnable; // return UseItemGameModeChangeEnable;
} // }
//
public static int getUseItemGameModeChangeDelayInTicks() { // public static int getUseItemGameModeChangeDelayInTicks() {
return UseItemGameModeChangeDelayInTicks; // return UseItemGameModeChangeDelayInTicks;
} // }
//
public static Boolean getUseItemGameModeProtection() { // public static Boolean getUseItemGameModeProtection() {
return UseItemGameModeProtection; // return UseItemGameModeProtection;
} // }
//
public static Boolean getUseItemGameModeRemoveItemWhenItIsDisabled() { // public static Boolean getUseItemGameModeRemoveItemWhenItIsDisabled() {
return UseItemGameModeRemoveItemWhenItIsDisabled; // return UseItemGameModeRemoveItemWhenItIsDisabled;
} // }
//
public static String getUseItemGameModeMode() { // public static String getUseItemGameModeMode() {
return UseItemGameModeMode; // return UseItemGameModeMode;
} // }
//
public static List<String> getUseItemGameModeList() { // public static List<String> getUseItemGameModeList() {
return UseItemGameModeList; // return UseItemGameModeList;
} // }
//
public static Boolean getUseItemWorldChangeEnable() { // public static Boolean getUseItemWorldChangeEnable() {
return UseItemWorldChangeEnable; // return UseItemWorldChangeEnable;
} // }
//
public static int getUseItemWorldChangeDelayInTicks() { // public static int getUseItemWorldChangeDelayInTicks() {
return UseItemWorldChangeDelayInTicks; // return UseItemWorldChangeDelayInTicks;
} // }
//
public static Boolean getUseItemWorldProtection() { // public static Boolean getUseItemWorldProtection() {
return UseItemWorldProtection; // return UseItemWorldProtection;
} // }
//
public static Boolean getUseItemWorldRemoveItemWhenItIsDisabled() { // public static Boolean getUseItemWorldRemoveItemWhenItIsDisabled() {
return UseItemWorldRemoveItemWhenItIsDisabled; // return UseItemWorldRemoveItemWhenItIsDisabled;
} // }
//
public static String getUseItemWorldMode() { // public static String getUseItemWorldMode() {
return UseItemWorldMode; // return UseItemWorldMode;
} // }
//
public static List<String> getUseItemWorldList() { // public static List<String> getUseItemWorldList() {
return UseItemWorldList; // return UseItemWorldList;
} // }
//
public static List<String> getUseItemItemBlockBlacklist() { // public static List<String> getUseItemItemBlockBlacklist() {
return UseItemItemBlockBlacklist; // return UseItemItemBlockBlacklist;
} // }
//
public static Boolean getDisableInfoBySneak() { // public static Boolean getDisableInfoBySneak() {
return disableInfoBySneak; // return disableInfoBySneak;
} // }
//
public static Boolean getUseItem_InventorySlot_FreeSlot() { // public static Boolean getUseItem_InventorySlot_FreeSlot() {
return UseItem_InventorySlot_FreeSlot; // return UseItem_InventorySlot_FreeSlot;
} // }
//
public static Integer getUseItem_InventorySlot() { // public static Integer getUseItem_InventorySlot() {
return UseItem_InventorySlot; // return UseItem_InventorySlot;
} // }
//
public static Boolean getUseItem_InventorySlotEnforce() { // public static Boolean getUseItem_InventorySlotEnforce() {
return UseItem_InventorySlotEnforce; // return UseItem_InventorySlotEnforce;
} // }
//
public static String getUseItem_Material() { // public static String getUseItem_Material() {
return UseItem_Material; // return UseItem_Material;
} // }
//
public static Boolean getUseItem_PlayerHead_Enable() { // public static Boolean getUseItem_PlayerHead_Enable() {
return UseItem_PlayerHead_Enable; // return UseItem_PlayerHead_Enable;
} // }
//
public static Boolean getUseItem_Base64_Enable() { // public static Boolean getUseItem_Base64_Enable() {
return UseItem_Base64_Enable; // return UseItem_Base64_Enable;
} // }
//
public static String getUseItem_Base64value() { // public static String getUseItem_Base64value() {
return UseItem_Base64value; // return UseItem_Base64value;
} // }
//
public static Boolean getUseItem_PlayerWhoHasOpenedTheGUI() { // public static Boolean getUseItem_PlayerWhoHasOpenedTheGUI() {
return UseItem_PlayerWhoHasOpenedTheGUI; // return UseItem_PlayerWhoHasOpenedTheGUI;
} // }
//
public static String getUseItem_PlayerName() { // public static String getUseItem_PlayerName() {
return UseItem_PlayerName; // return UseItem_PlayerName;
} // }
//
public static String getUseItem_Name() { // public static String getUseItem_Name() {
return UseItem_Name; // return UseItem_Name;
} // }
//
public static List<String> getUseItem_Lore() { // public static List<String> getUseItem_Lore() {
return UseItem_Lore; // return UseItem_Lore;
} // }
//
public static Boolean getToggleItemOnOrYesBase64() { // public static Boolean getToggleItemOnOrYesBase64() {
return toggleItemOnOrYesBase64; // return toggleItemOnOrYesBase64;
} // }
//
public static String getToggleItemOnOrYesBase64Value() { // public static String getToggleItemOnOrYesBase64Value() {
return toggleItemOnOrYesBase64Value; // return toggleItemOnOrYesBase64Value;
} // }
//
public static String getToggleItemOnOrYesMaterial() { // public static String getToggleItemOnOrYesMaterial() {
return toggleItemOnOrYesMaterial; // return toggleItemOnOrYesMaterial;
} // }
//
public static Boolean getToggleItemOffOrNoBase64() { // public static Boolean getToggleItemOffOrNoBase64() {
return toggleItemOffOrNoBase64; // return toggleItemOffOrNoBase64;
} // }
//
public static String getToggleItemOffOrNoBase64Value() { // public static String getToggleItemOffOrNoBase64Value() {
return toggleItemOffOrNoBase64Value; // return toggleItemOffOrNoBase64Value;
} // }
//
public static String getToggleItemOffOrNoMaterial() { // public static String getToggleItemOffOrNoMaterial() {
return toggleItemOffOrNoMaterial; // return toggleItemOffOrNoMaterial;
} // }
//
public static String getTogglePermTrue() { // public static String getTogglePermTrue() {
return togglePermTrue; // return togglePermTrue;
} // }
//
public static String getTogglePermFalse() { // public static String getTogglePermFalse() {
return togglePermFalse; // return togglePermFalse;
} // }
//
public static String getPlaceholderTrue() { // public static String getPlaceholderTrue() {
return placeholderTrue; // return placeholderTrue;
} // }
//
public static String getPlaceholderFalse() { // public static String getPlaceholderFalse() {
return placeholderFalse; // return placeholderFalse;
} // }
//
public static Boolean getSound_Enable() { // public static Boolean getSound_Enable() {
return Sound_Enable; // return Sound_Enable;
} // }
//
public static Boolean getSound_OpenInventory_Enable() { // public static Boolean getSound_OpenInventory_Enable() {
return Sound_OpenInventory_Enable; // return Sound_OpenInventory_Enable;
} // }
//
public static Sound getSound_OpenInventory() { // public static Sound getSound_OpenInventory() {
return Sound_OpenInventory; // return Sound_OpenInventory;
} // }
//
public static String getSound_OpenInventory_input() { // public static String getSound_OpenInventory_input() {
return Sound_OpenInventory_input; // return Sound_OpenInventory_input;
} // }
//
public static Boolean getSound_Click_Enable() { // public static Boolean getSound_Click_Enable() {
return Sound_Click_Enable; // return Sound_Click_Enable;
} // }
//
public static Sound getSound_Click() { // public static Sound getSound_Click() {
return Sound_Click; // return Sound_Click;
} // }
//
public static String getSound_Click_input() { // public static String getSound_Click_input() {
return Sound_Click_input; // return Sound_Click_input;
} // }
//
public static Boolean getSound_NoMoney_Enable() { // public static Boolean getSound_NoMoney_Enable() {
return Sound_NoMoney_Enable; // return Sound_NoMoney_Enable;
} // }
//
public static Sound getSound_NoMoney() { // public static Sound getSound_NoMoney() {
return Sound_NoMoney; // return Sound_NoMoney;
} // }
//
public static String getSound_NoMoney_input() { // public static String getSound_NoMoney_input() {
return Sound_NoMoney_input; // return Sound_NoMoney_input;
} // }
//
public static Boolean getSound_NoInventorySpace_Enable() { // public static Boolean getSound_NoInventorySpace_Enable() {
return Sound_NoInventorySpace_Enable; // return Sound_NoInventorySpace_Enable;
} // }
//
public static Sound getSound_NoInventorySpace() { // public static Sound getSound_NoInventorySpace() {
return Sound_NoInventorySpace; // return Sound_NoInventorySpace;
} // }
//
public static String getSound_NoInventorySpace_input() { // public static String getSound_NoInventorySpace_input() {
return Sound_NoInventorySpace_input; // return Sound_NoInventorySpace_input;
} // }
//
public static Boolean getSound_Give_Enable() { // public static Boolean getSound_Give_Enable() {
return Sound_Give_Enable; // return Sound_Give_Enable;
} // }
//
public static Sound getSound_Give() { // public static Sound getSound_Give() {
return Sound_Give; // return Sound_Give;
} // }
//
public static String getSound_Give_input() { // public static String getSound_Give_input() {
return Sound_Give_input; // return Sound_Give_input;
} // }
//
public static Boolean getSound_PlayerNotFound_Enable() { // public static Boolean getSound_PlayerNotFound_Enable() {
return Sound_PlayerNotFound_Enable; // return Sound_PlayerNotFound_Enable;
} // }
//
public static Sound getSound_PlayerNotFound() { // public static Sound getSound_PlayerNotFound() {
return Sound_PlayerNotFound; // return Sound_PlayerNotFound;
} // }
//
public static String getSound_PlayerNotFound_input() { // public static String getSound_PlayerNotFound_input() {
return Sound_PlayerNotFound_input; // return Sound_PlayerNotFound_input;
} // }
} }

View File

@ -0,0 +1,10 @@
package net.t2code.commandguiv2.Spigot.config.configConverter;
public class ConfigConverterUnderV6 {
}

View File

@ -1,6 +1,7 @@
package net.t2code.commandguiv2.Spigot.config.languages; package net.t2code.commandguiv2.Spigot.config.languages;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
@ -87,17 +88,17 @@ public class SelectMessages {
File msg; File msg;
msg = new File(Main.getPath(), "languages/" + SelectConfig.getLanguage() + "_messages.yml"); msg = new File(Main.getPath(), "languages/" + Config.language.value + "_messages.yml");
if (!msg.isFile()) { if (!msg.isFile()) {
T2Csend.console(Prefix); T2Csend.console(Prefix);
T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Prefix + " §4The selected §c" + SelectConfig.getLanguage() + " §4language file was not found."); T2Csend.console(Prefix + " §4The selected §c" + Config.language.value + " §4language file was not found.");
T2Csend.console(Prefix + " §6The default language §eEnglish §6is used!"); T2Csend.console(Prefix + " §6The default language §eEnglish §6is used!");
T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Prefix); T2Csend.console(Prefix);
msg = new File(Main.getPath(), "languages/" + "english_messages.yml"); msg = new File(Main.getPath(), "languages/" + "english_messages.yml");
selectMSG = "english"; selectMSG = "english";
} else selectMSG = SelectConfig.getLanguage(); } else selectMSG = String.valueOf(Config.language.value);
YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg); YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg);
VaultNotSetUp = select("Plugin.VaultNotSetUp", yamlConfiguration_msg); VaultNotSetUp = select("Plugin.VaultNotSetUp", yamlConfiguration_msg);

View File

@ -3,6 +3,7 @@ package net.t2code.commandguiv2.Spigot.database;
import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.HikariDataSource;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
@ -24,11 +25,11 @@ public class MySQL {
ZoneId timeZone = now.getTimeZone().toZoneId(); ZoneId timeZone = now.getTimeZone().toZoneId();
T2Csend.debug(Main.getPlugin(), "Server TimeZone is : " + timeZone); T2Csend.debug(Main.getPlugin(), "Server TimeZone is : " + timeZone);
try { try {
config.setJdbcUrl("jdbc:mysql://" + SelectConfig.getMysqlIp() + ":" + SelectConfig.getMysqlPort() + "/" + SelectConfig.getMysqlDatabase() config.setJdbcUrl("jdbc:mysql://" + Config.mysqlIp.value + ":" + Config.mysqlPort.value + "/" + Config.mysqlDatabase.value
+ "?useJDBCCompliantTimezoneShift=true&allowMultiQueries=true&useLegacyDatetimeCode=false&autoReconnect=true&serverTimezone=" + timeZone + "?useJDBCCompliantTimezoneShift=true&allowMultiQueries=true&useLegacyDatetimeCode=false&autoReconnect=true&serverTimezone=" + timeZone
+ "&useSSL=" + SelectConfig.getMysqlSSL()); + "&useSSL=" + Config.mysqlSSL.value);
config.setUsername(SelectConfig.getMysqlUser()); config.setUsername(String.valueOf(Config.mysqlUser.value));
config.setPassword(SelectConfig.getMysqlPassword()); config.setPassword(String.valueOf(Config.mysqlPassword.value));
config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
@ -39,7 +40,7 @@ public class MySQL {
T2Csend.error(Main.getPlugin(), ex.getMessage() + " --- " + (System.currentTimeMillis() - long_) + "ms"); T2Csend.error(Main.getPlugin(), ex.getMessage() + " --- " + (System.currentTimeMillis() - long_) + "ms");
} }
if (SelectConfig.getDebug() || Main.version.toLowerCase().contains("dev") || Main.version.toLowerCase().contains("beta") || Main.version.toLowerCase().contains("snapshot")) { if ((Boolean) Config.debug.value || Main.version.toLowerCase().contains("dev") || Main.version.toLowerCase().contains("beta") || Main.version.toLowerCase().contains("snapshot")) {
try { try {
T2Csend.error(Main.getPlugin(), "MySQL DEBUG:"); T2Csend.error(Main.getPlugin(), "MySQL DEBUG:");
Connection con = ds.getConnection(); Connection con = ds.getConnection();

View File

@ -101,7 +101,7 @@ public class SelectDatabase {
} }
break; break;
case YML: case YML:
YML.setGuiitemOff(player); YML.setGuiItem(player, status);
break; break;
case SQLITE: case SQLITE:
default: default:

View File

@ -1,5 +1,6 @@
package net.t2code.commandguiv2.Spigot.gui; package net.t2code.commandguiv2.Spigot.gui;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.listener.ServerChange; import net.t2code.commandguiv2.Spigot.listener.ServerChange;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.useItem.Events;
import net.t2code.commandguiv2.Spigot.objects.functions.Function; import net.t2code.commandguiv2.Spigot.objects.functions.Function;
@ -18,6 +19,7 @@ import net.t2code.t2codelib.SPIGOT.api.eco.T2Ceco;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -29,6 +31,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.checkerframework.checker.units.qual.C;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -118,7 +121,7 @@ public class GUIListener implements Listener {
@Override @Override
public void run() { public void run() {
if (slot.command_BungeeCommand) { if (slot.command_BungeeCommand) {
if (SelectConfig.getBungee()) { if (T2CLibConfig.getBungee()) {
for (String cmd : slot.command) { for (String cmd : slot.command) {
Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.commandAsConsole); Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.commandAsConsole);
} }
@ -152,11 +155,11 @@ public class GUIListener implements Listener {
for (String msg : slot.message) { for (String msg : slot.message) {
if (Main.PaPi) { if (Main.PaPi) {
if (slot.cost_Enable) { if (slot.cost_Enable) {
T2Csend.player(player, T2Creplace.replacePrice(prefix, player, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.getCurrency())); T2Csend.player(player, T2Creplace.replacePrice(prefix, player, Placeholder.replace(msg, player), slot.price + " " + Config.currency.value));
} else T2Csend.player(player, T2Creplace.replace(prefix, player, Placeholder.replace(msg, player))); } else T2Csend.player(player, T2Creplace.replace(prefix, player, Placeholder.replace(msg, player)));
} else { } else {
if (slot.cost_Enable) { if (slot.cost_Enable) {
T2Csend.player(player, T2Creplace.replacePrice(prefix, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.getCurrency())); T2Csend.player(player, T2Creplace.replacePrice(prefix, Placeholder.replace(msg, player), slot.price + " " + Config.currency.value));
} else T2Csend.player(player, T2Creplace.replace(prefix, Placeholder.replace(msg, player))); } else T2Csend.player(player, T2Creplace.replace(prefix, Placeholder.replace(msg, player)));
} }
} }
@ -246,7 +249,7 @@ public class GUIListener implements Listener {
private static void togglePerm(Function function, Gui gui, Player player) { private static void togglePerm(Function function, Gui gui, Player player) {
if (player.hasPermission(function.togglePermissionPerm)) { if (player.hasPermission(function.togglePermissionPerm)) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.getTogglePermFalse().replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm)); Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), String.valueOf(Config.togglePermFalse.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -255,7 +258,7 @@ public class GUIListener implements Listener {
} }
}.runTaskLater(plugin, 4L); }.runTaskLater(plugin, 4L);
} else } else
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.getTogglePermTrue().replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm)); Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), String.valueOf(Config.togglePermTrue.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -360,7 +363,7 @@ public class GUIListener implements Listener {
Sound.play(player, SoundEnum.NoMoney); Sound.play(player, SoundEnum.NoMoney);
} else { } else {
T2Csend.player(player, SelectMessages.Buy_msg.replace("[itemname]", T2Creplace.replace(prefix, function.name)) T2Csend.player(player, SelectMessages.Buy_msg.replace("[itemname]", T2Creplace.replace(prefix, function.name))
.replace("[price]", function.price + " " + SelectConfig.getCurrency())); .replace("[price]", function.price + " " + Config.currency.value));
execute(function, slot, player, e, gui); execute(function, slot, player, e, gui);
} }
break; break;

View File

@ -3,6 +3,7 @@ package net.t2code.commandguiv2.Spigot.gui;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui; import net.t2code.commandguiv2.Spigot.objects.guis.Gui;
import net.t2code.commandguiv2.Spigot.objects.functions.Function; import net.t2code.commandguiv2.Spigot.objects.functions.Function;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig;
@ -68,13 +69,13 @@ public class GuiBuilder {
if (Main.PaPi) { if (Main.PaPi) {
itemMeta.setDisplayName(T2Creplace.replace(prefix, player, Placeholder.replace(function.name, player))); itemMeta.setDisplayName(T2Creplace.replace(prefix, player, Placeholder.replace(function.name, player)));
if (slot.permission && !player.hasPermission(slot.permissionToUse) && function.noPermLoreEnable) { if (slot.permission && !player.hasPermission(slot.permissionToUse) && function.noPermLoreEnable) {
itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.noPermLore, player), function.price + " " + SelectConfig.getCurrency())); itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.noPermLore, player), function.price + " " + Config.currency.value));
} else itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.lore, player), function.price + " " + SelectConfig.getCurrency())); } else itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.lore, player), function.price + " " + Config.currency.value));
} else { } else {
itemMeta.setDisplayName(T2Creplace.replace(prefix, Placeholder.replace(function.name, player))); itemMeta.setDisplayName(T2Creplace.replace(prefix, Placeholder.replace(function.name, player)));
if (slot.permission && !player.hasPermission(slot.permissionToUse) && function.noPermLoreEnable) { if (slot.permission && !player.hasPermission(slot.permissionToUse) && function.noPermLoreEnable) {
itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.noPermLore, player), function.price + " " + SelectConfig.getCurrency())); itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.noPermLore, player), function.price + " " + Config.currency.value));
} else itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.lore, player), function.price + " " + SelectConfig.getCurrency())); } else itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.lore, player), function.price + " " + Config.currency.value));
} }
} }

View File

@ -1,5 +1,6 @@
package net.t2code.commandguiv2.Spigot.gui; package net.t2code.commandguiv2.Spigot.gui;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.system.Permissions; import net.t2code.commandguiv2.Spigot.system.Permissions;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.useItem.Events;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
@ -136,14 +137,14 @@ public class OpenGUI {
} }
private static void toggleOn(Function function, Slot slot, Player player, Inventory inventory) { private static void toggleOn(Function function, Slot slot, Player player, Inventory inventory) {
if (SelectConfig.getToggleItemOnOrYesBase64()) { if ((Boolean) Config.toggleItemOnOrYesBase64.value) {
GuiBuilder.base64(SelectConfig.getToggleItemOnOrYesBase64Value(), slot, player, inventory); GuiBuilder.base64(String.valueOf( Config.toggleItemOnOrYesBase64Value.value), slot, player, inventory);
} else GuiBuilder.item(SelectConfig.getToggleItemOnOrYesMaterial(), slot, player, inventory); } else GuiBuilder.item(String.valueOf(Config.toggleItemOnOrYesMaterial.value), slot, player, inventory);
} }
private static void toggleOff(Function function, Slot slot, Player player, Inventory inventory) { private static void toggleOff(Function function, Slot slot, Player player, Inventory inventory) {
if (SelectConfig.getToggleItemOffOrNoBase64()) { if ((Boolean) Config.toggleItemOffOrNoBase64.value) {
GuiBuilder.base64(SelectConfig.getToggleItemOffOrNoBase64Value(), slot, player, inventory); GuiBuilder.base64(String.valueOf( Config.toggleItemOffOrNoBase64Value.value), slot, player, inventory);
} else GuiBuilder.item(SelectConfig.getToggleItemOffOrNoMaterial(), slot, player, inventory); } else GuiBuilder.item(String.valueOf(Config.toggleItemOffOrNoMaterial.value), slot, player, inventory);
} }
} }

View File

@ -1,6 +1,6 @@
package net.t2code.commandguiv2.Spigot.sound; package net.t2code.commandguiv2.Spigot.sound;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.objects.functions.Function; import net.t2code.commandguiv2.Spigot.objects.functions.Function;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui; import net.t2code.commandguiv2.Spigot.objects.guis.Gui;
@ -14,21 +14,20 @@ public class Sound {
private static String prefix = Util.getPrefix(); private static String prefix = Util.getPrefix();
public static void play(Player player, SoundEnum soundEnum) { public static void play(Player player, SoundEnum soundEnum) {
if (!SelectConfig.getSound_Enable()) return;
play(player, soundEnum, null, null, null); play(player, soundEnum, null, null, null);
} }
public static void play(Player player, SoundEnum soundEnum, Function function, Slot slot, Gui gui) { public static void play(Player player, SoundEnum soundEnum, Function function, Slot slot, Gui gui) {
if (!SelectConfig.getSound_Enable()) return; if (!(Boolean) Config.soundEnable.value) return;
switch (soundEnum) { switch (soundEnum) {
case OpenInventory: case OpenInventory:
if (!SelectConfig.getSound_OpenInventory_Enable()) return; if (!(Boolean) Config.soundOpenInventoryEnable.value) return;
player.playSound(player.getLocation(), SelectConfig.getSound_OpenInventory(), 3, 1); player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundOpenInventoryInput.value)), 3, 1);
break; break;
case Click: case Click:
if (!SelectConfig.getSound_Click_Enable()) return; if (!(Boolean) Config.soundClickEnable.value) return;
if (!function.customSound_Enable) { if (!function.customSound_Enable) {
player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1); player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundClickInput.value)), 3, 1);
return; return;
} }
@ -38,24 +37,24 @@ public class Sound {
} catch (Exception e1) { } catch (Exception e1) {
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix) T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
.replace("[sound]", "§6GUI: §e" + gui.key + " §6Function: §e" + function.key + "§r §6Slot: §e" + (slot.slot + 1) + " §6CustomSound: §9" + function.customSound_Sound)); .replace("[sound]", "§6GUI: §e" + gui.key + " §6Function: §e" + function.key + "§r §6Slot: §e" + (slot.slot + 1) + " §6CustomSound: §9" + function.customSound_Sound));
player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1); player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundClickInput.value)), 3, 1);
} }
break; break;
case NoMoney: case NoMoney:
if (!SelectConfig.getSound_NoMoney_Enable()) return; if (!(Boolean) Config.soundNoMoneyEnable.value) return;
player.playSound(player.getLocation(), SelectConfig.getSound_NoMoney(), 3, 1); player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundNoMoneyInput.value)), 3, 1);
break; break;
case NoInventorySpace: case NoInventorySpace:
if (!SelectConfig.getSound_NoInventorySpace_Enable()) return; if (!(Boolean) Config.soundNoInventorySpaceEnable.value) return;
player.playSound(player.getLocation(), SelectConfig.getSound_NoInventorySpace(), 3, 1); player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundNoInventorySpaceInput.value)), 3, 1);
break; break;
case Give: case Give:
if (!SelectConfig.getSound_Give_Enable()) return; if (!(Boolean) Config.soundGiveEnable.value) return;
player.playSound(player.getLocation(), SelectConfig.getSound_Give(), 3, 1); player.playSound(player.getLocation(),org.bukkit.Sound.valueOf(String.valueOf( Config.soundGiveInput.value)), 3, 1);
break; break;
case PlayerNotFound: case PlayerNotFound:
if (!SelectConfig.getSound_PlayerNotFound_Enable()) return; if (!(Boolean) Config.soundPlayerNotFoundEnable.value) return;
player.playSound(player.getLocation(), SelectConfig.getSound_PlayerNotFound(), 3, 1); player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(Config.soundPlayerNotFoundInput.value)), 3, 1);
break; break;
} }
} }

View File

@ -1,5 +1,7 @@
package net.t2code.commandguiv2.Spigot.system; package net.t2code.commandguiv2.Spigot.system;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect;
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5; import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5;
import net.t2code.commandguiv2.Spigot.gui.GUIListener; import net.t2code.commandguiv2.Spigot.gui.GUIListener;
import net.t2code.commandguiv2.Spigot.listener.Bungee_Sender_Reciver; import net.t2code.commandguiv2.Spigot.listener.Bungee_Sender_Reciver;
@ -28,6 +30,7 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck; import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -74,12 +77,7 @@ public class Load {
} }
try { try {
ConfigCreate.configCreate(); ConfigSelect.selectConfig();
} catch (Exception e) {
e.printStackTrace();
}
try {
SelectConfig.onSelect();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -96,7 +94,7 @@ public class Load {
SelectConfig.setConfigVersion(); SelectConfig.setConfigVersion();
if (SelectConfig.getBungee()) { if (T2CLibConfig.getBungee()) {
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "t2c:bcmd")) { if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "t2c:bcmd")) {
T2Csend.debug(plugin, "registerOutgoingPluginChannel §et2c:bcmd"); T2Csend.debug(plugin, "registerOutgoingPluginChannel §et2c:bcmd");
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd"); Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
@ -128,12 +126,12 @@ public class Load {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
SelectConfig.sound(prefix); Config.sound();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
CmdExecuter_GUI.arg1.put(SelectConfig.getAdminSubCommand(), Permissions.admin + ";" + Permissions.giveItemOther + ";" + Permissions.info); CmdExecuter_GUI.arg1.put(String.valueOf(Config.adminSubCommand.value), Permissions.admin + ";" + Permissions.giveItemOther + ";" + Permissions.info);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -154,7 +152,7 @@ public class Load {
e.printStackTrace(); e.printStackTrace();
} }
if (SelectConfig.getHelpAlias()) { if ((Boolean) Config.helpAlias.value) {
Main.getPlugin().getCommand("commandguihelp").setExecutor(new CmdExecuter_Help()); Main.getPlugin().getCommand("commandguihelp").setExecutor(new CmdExecuter_Help());
T2Csend.debug(plugin, "CommandRegister: commandguihelp"); T2Csend.debug(plugin, "CommandRegister: commandguihelp");
} }
@ -179,7 +177,7 @@ public class Load {
} }
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), spigotID, discord T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), spigotID, discord
,SelectConfig.getUpdateCheckOnJoin(),SelectConfig.getUpdateCheckSeePreReleaseUpdates(),SelectConfig.getUpdateCheckTimeInterval()); , (Boolean) Config.updateCheckOnJoin.value, (Boolean) Config.updateCheckSeePreReleaseUpdates.value, (Integer) Config.updateCheckTimeInterval.value);
Metrics.Bstats(); Metrics.Bstats();
Main.addonLoad(); Main.addonLoad();
T2Ctemplate.onLoadFooter(prefix, long_); T2Ctemplate.onLoadFooter(prefix, long_);
@ -187,9 +185,9 @@ public class Load {
private static void loadStorage(String prefix) { private static void loadStorage(String prefix) {
try { try {
SelectDatabase.setStorage(StorageEnum.valueOf(SelectConfig.getStorage())); SelectDatabase.setStorage(StorageEnum.valueOf(String.valueOf(Config.storage.value)));
} catch (Exception ignored) { } catch (Exception ignored) {
T2Csend.error(plugin, "The storage medium " + SelectConfig.getStorage() + " is not supported!"); T2Csend.error(plugin, "The storage medium '" + Config.storage.value + "' is not supported!");
T2Csend.error(plugin, "Storage medium " + StorageEnum.SQLITE + " is used."); T2Csend.error(plugin, "Storage medium " + StorageEnum.SQLITE + " is used.");
SelectDatabase.setStorage(StorageEnum.SQLITE); SelectDatabase.setStorage(StorageEnum.SQLITE);
} }

View File

@ -1,5 +1,6 @@
package net.t2code.commandguiv2.Spigot.system; package net.t2code.commandguiv2.Spigot.system;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.useItem.Events;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -10,8 +11,8 @@ import java.util.List;
public class Placeholder { public class Placeholder {
public static String useitem(Player p) { public static String useitem(Player p) {
if (Events.useItemHashMap.get(p.getName())) { if (Events.useItemHashMap.get(p.getName())) {
return SelectConfig.getPlaceholderTrue(); return Config.placeholderTrue.name();
} else return SelectConfig.getPlaceholderFalse(); } else return Config.placeholderFalse.name();
} }
public static String useitem_boolean(Player p) { public static String useitem_boolean(Player p) {

View File

@ -2,7 +2,7 @@ package net.t2code.commandguiv2.Spigot.useItem;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.cmdManagement.Commands; import net.t2code.commandguiv2.Spigot.cmdManagement.Commands;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.gui.OpenGUI; import net.t2code.commandguiv2.Spigot.gui.OpenGUI;
import net.t2code.commandguiv2.Spigot.database.SelectDatabase; import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
@ -40,7 +40,7 @@ public class Events implements Listener {
useItemHashMap.put(e.getPlayer().getName(), SelectDatabase.selectItemStatus(e.getPlayer())); useItemHashMap.put(e.getPlayer().getName(), SelectDatabase.selectItemStatus(e.getPlayer()));
Integer i = SelectDatabase.selectSlot(e.getPlayer()); Integer i = SelectDatabase.selectSlot(e.getPlayer());
if (i == null) { if (i == null) {
useItemSlotHashMap.put(e.getPlayer().getName(), SelectConfig.getUseItem_InventorySlot()); useItemSlotHashMap.put(e.getPlayer().getName(), (Integer) Config.useItemInventorySlot.value);
} else useItemSlotHashMap.put(e.getPlayer().getName(), i); } else useItemSlotHashMap.put(e.getPlayer().getName(), i);
if (CGuiAPI.JoinDisable) { if (CGuiAPI.JoinDisable) {
@ -64,7 +64,6 @@ public class Events implements Listener {
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onDeathDrop(PlayerDeathEvent e) { public void onDeathDrop(PlayerDeathEvent e) {
Player player = e.getEntity().getPlayer(); Player player = e.getEntity().getPlayer();
@ -74,7 +73,7 @@ public class Events implements Listener {
while (var3.hasNext()) { while (var3.hasNext()) {
ItemStack items = (ItemStack) var3.next(); ItemStack items = (ItemStack) var3.next();
if (items != null && items.hasItemMeta() && items.getItemMeta().hasDisplayName() if (items != null && items.hasItemMeta() && items.getItemMeta().hasDisplayName()
&& items.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && items.getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
e.getDrops().remove(items); e.getDrops().remove(items);
} }
} }
@ -84,10 +83,10 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onRespawn(PlayerRespawnEvent e) { public void onRespawn(PlayerRespawnEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();
if (SelectConfig.getUseItem_Enable()) { if ((Boolean) Config.useItemEnable.value) {
ItemChange.itemChange(player, false); ItemChange.itemChange(player, false);
//if (!SelectConfig.getUseItem_AllowToggle || Select_Database.selectItemStatus(player)) { //if (!Config.getUseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
// if (SelectConfig.getUseItem_GiveOnlyOnFirstJoin) { // if (Config.getUseItem_GiveOnlyOnFirstJoin) {
// if (!player.hasPlayedBefore()) { // if (!player.hasPlayedBefore()) {
// new BukkitRunnable() { // new BukkitRunnable() {
// @Override // @Override
@ -111,7 +110,7 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onGameModeChange(PlayerGameModeChangeEvent e) { public void onGameModeChange(PlayerGameModeChangeEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();
if (!SelectConfig.getUseItemGameModeChangeEnable()) { if (!(Boolean) Config.useItemGameModeChangeEnable.value) {
return; return;
} }
new BukkitRunnable() { new BukkitRunnable() {
@ -119,13 +118,13 @@ public class Events implements Listener {
public void run() { public void run() {
ItemChange.itemChange(player, false); ItemChange.itemChange(player, false);
} }
}.runTaskLater(Main.getPlugin(), SelectConfig.getUseItemGameModeChangeDelayInTicks() * 1L); }.runTaskLater(Main.getPlugin(), (Integer) Config.useItemGameModeChangeDelayInTicks.value * 1L);
} }
@EventHandler @EventHandler
public void onWorldChange(PlayerChangedWorldEvent e) { public void onWorldChange(PlayerChangedWorldEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();
if (!SelectConfig.getUseItemWorldChangeEnable()) { if (!(Boolean) Config.useItemWorldChangeEnable.value) {
return; return;
} }
new BukkitRunnable() { new BukkitRunnable() {
@ -133,30 +132,30 @@ public class Events implements Listener {
public void run() { public void run() {
ItemChange.itemChange(player, false); ItemChange.itemChange(player, false);
} }
}.runTaskLater(Main.getPlugin(), SelectConfig.getUseItemWorldChangeDelayInTicks() * 1L); }.runTaskLater(Main.getPlugin(), (Integer) Config.useItemWorldChangeDelayInTicks.value * 1L);
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent e) { public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (!p.isSneaking()) { if (!p.isSneaking()) {
for (String material : SelectConfig.getUseItemItemBlockBlacklist()) { for (String material : (ArrayList<String>) Config.useItemItemBlockBlacklist.value) {
if (e.getClickedBlock() != null) { if (e.getClickedBlock() != null) {
if (e.getClickedBlock().getType() == Material.valueOf(material)) return; if (e.getClickedBlock().getType() == Material.valueOf(material)) return;
} }
} }
} }
if (SelectConfig.getUseItem_Enable()) { if ((Boolean) Config.useItemEnable.value) {
if (SelectConfig.getUseItem_PlayerHead_Enable()) { if ((Boolean) Config.useItemPlayerHeadEnable.value) {
if (e.getItem() != null && p.getItemInHand().getType() == T2CitemVersion.getHead()) { if (e.getItem() != null && p.getItemInHand().getType() == T2CitemVersion.getHead()) {
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { if (e.getItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
openGUI(e, p); openGUI(e, p);
} }
} }
} else { } else {
if (e.getItem() != null && p.getItemInHand().getType() == Material.valueOf(SelectConfig.getUseItem_Material())) { if (e.getItem() != null && p.getItemInHand().getType() == Material.valueOf(String.valueOf(Config.useItemMaterial.value))) {
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { if (e.getItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
openGUI(e, p); openGUI(e, p);
} }
} }
@ -167,7 +166,7 @@ public class Events implements Listener {
private static void openGUI(PlayerInteractEvent e, Player player) { private static void openGUI(PlayerInteractEvent e, Player player) {
e.setCancelled(true); e.setCancelled(true);
if ((!SelectConfig.getDisableInfoBySneak()) && player.isSneaking()) { if ((!(Boolean) Config.disableInfoBySneak.value) && player.isSneaking()) {
Commands.info(player); Commands.info(player);
return; return;
} }
@ -178,45 +177,45 @@ public class Events implements Listener {
if (UseItem.protection(player, true)) return; if (UseItem.protection(player, true)) return;
if (SelectConfig.getUseItemGameModeProtection()) { if ((Boolean) Config.useItemGameModeProtection.value) {
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) { if (String.valueOf(Config.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(Config.useItemGameModeList.value).contains(player.getGameMode().toString())) {
e.setCancelled(true); e.setCancelled(true);
T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode); T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode);
return; return;
} }
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) { if (String.valueOf(Config.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(Config.useItemGameModeList.value).contains(player.getGameMode().toString())) {
e.setCancelled(true); e.setCancelled(true);
T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode); T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode);
return; return;
} }
} }
if (SelectConfig.getUseItemWorldProtection()) { if ((Boolean) Config.useItemWorldProtection.value) {
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) { if (String.valueOf(Config.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(Config.useItemWorldList.value).contains(player.getWorld().getName())) {
e.setCancelled(true); e.setCancelled(true);
T2Csend.player(player, SelectMessages.UseItemDisabledInWorld); T2Csend.player(player, SelectMessages.UseItemDisabledInWorld);
return; return;
} }
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) { if (String.valueOf(Config.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(Config.useItemWorldList.value).contains(player.getWorld().getName())) {
e.setCancelled(true); e.setCancelled(true);
T2Csend.player(player, SelectMessages.UseItemDisabledInWorld); T2Csend.player(player, SelectMessages.UseItemDisabledInWorld);
return; return;
} }
} }
if (!SelectConfig.getUseItem_Permission() || player.hasPermission("commandgui.useitem")) { if (!(Boolean) Config.useItemPermission.value || player.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(player, SelectConfig.getUseItem_OpenGUI(), true); OpenGUI.openGUI(player, String.valueOf(Config.useItemOpenGUI.value), true);
} else { } else {
T2Csend.player(player, SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem") T2Csend.player(player, SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
.replace("[gui]", SelectConfig.getUseItem_OpenGUI())); .replace("[gui]", String.valueOf(Config.useItemOpenGUI.value)));
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onItemMoveEvent(InventoryMoveItemEvent e) { public void onItemMoveEvent(InventoryMoveItemEvent e) {
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return; if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return;
if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().hasDisplayName() if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().hasDisplayName()
&& e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -224,19 +223,19 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryDragEvent e) { public void onItemMove(InventoryDragEvent e) {
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return; if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return;
if (e.getWhoClicked() instanceof Player) { if (e.getWhoClicked() instanceof Player) {
Player p = (Player) e.getWhoClicked(); Player p = (Player) e.getWhoClicked();
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName() if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getCursor().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
p.closeInventory(); p.closeInventory();
e.setCancelled(true); e.setCancelled(true);
ItemChange.itemChange(p, false); ItemChange.itemChange(p, false);
} }
if (e.getOldCursor() != null && e.getOldCursor().hasItemMeta() && e.getOldCursor().getItemMeta().hasDisplayName() if (e.getOldCursor() != null && e.getOldCursor().hasItemMeta() && e.getOldCursor().getItemMeta().hasDisplayName()
&& e.getOldCursor().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getOldCursor().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
p.closeInventory(); p.closeInventory();
e.setCancelled(true); e.setCancelled(true);
ItemChange.itemChange(p, false); ItemChange.itemChange(p, false);
@ -246,14 +245,14 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemMove(InventoryClickEvent e) { public void onItemMove(InventoryClickEvent e) {
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return; if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return;
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName() if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getCursor().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
e.setCancelled(true); e.setCancelled(true);
} }
if (e.getCurrentItem() != null && e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName() if (e.getCurrentItem() != null && e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName()
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getCurrentItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
e.setCancelled(true); e.setCancelled(true);
} }
@ -261,12 +260,12 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryPickupItemEvent e) { public void onItemMove(InventoryPickupItemEvent e) {
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return; if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return;
if (e.getItem() != null && e.getItem().getItemStack() != null) { if (e.getItem() != null && e.getItem().getItemStack() != null) {
ItemStack item = e.getItem().getItemStack(); ItemStack item = e.getItem().getItemStack();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && item.getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -274,21 +273,21 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlace(BlockPlaceEvent e) { public void onPlace(BlockPlaceEvent e) {
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return; if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return;
if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName() if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName()
&& e.getItemInHand().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getItemInHand().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onDrop(PlayerDropItemEvent e) { public void onDrop(PlayerDropItemEvent e) {
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return; if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return;
if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) { if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) {
ItemStack item = e.getItemDrop().getItemStack(); ItemStack item = e.getItemDrop().getItemStack();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName() if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && item.getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -300,7 +299,7 @@ public class Events implements Listener {
@EventHandler @EventHandler
public void onClearServer(ServerCommandEvent event) { public void onClearServer(ServerCommandEvent event) {
if (SelectConfig.getUseItem_KeepAtCommandClear()) { if ((Boolean) Config.useItemKeepAtCommandClear.value) {
if (event.getCommand().contains("clear " + event.getCommand().replace("/", "").replace("clear ", ""))) { if (event.getCommand().contains("clear " + event.getCommand().replace("/", "").replace("clear ", ""))) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
@ -324,7 +323,7 @@ public class Events implements Listener {
@EventHandler @EventHandler
public void onClearPlayer(PlayerCommandPreprocessEvent event) { public void onClearPlayer(PlayerCommandPreprocessEvent event) {
if (SelectConfig.getUseItem_KeepAtCommandClear()) { if ((Boolean) Config.useItemKeepAtCommandClear.value) {
if (event.getMessage().toLowerCase().contains("clear")) { if (event.getMessage().toLowerCase().contains("clear")) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override

View File

@ -1,6 +1,6 @@
package net.t2code.commandguiv2.Spigot.useItem; package net.t2code.commandguiv2.Spigot.useItem;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.Config;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -11,27 +11,27 @@ public class EventsFrom110 implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onHandSwap(PlayerSwapHandItemsEvent e) { public void onHandSwap(PlayerSwapHandItemsEvent e) {
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return; if (!(Boolean) Config.useItemBlockMoveAndDrop.value || !(Boolean) Config.useItemEnable.value) return;
if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName() if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName()
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getMainHandItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
} }
if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName() if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName()
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getOffHandItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(PlayerSwapHandItemsEvent e) { public void onItemMove(PlayerSwapHandItemsEvent e) {
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return; if (!(Boolean)Config.useItemBlockMoveAndDrop.value || !(Boolean)Config.useItemEnable.value) return;
Player p = e.getPlayer(); Player p = e.getPlayer();
if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName() if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName()
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getOffHandItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
p.closeInventory(); p.closeInventory();
e.setCancelled(true); e.setCancelled(true);
} }
if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName() if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName()
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { && e.getMainHandItem().getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
p.closeInventory(); p.closeInventory();
e.setCancelled(true); e.setCancelled(true);
} }

View File

@ -1,27 +1,28 @@
package net.t2code.commandguiv2.Spigot.useItem; package net.t2code.commandguiv2.Spigot.useItem;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class ItemChange { public class ItemChange {
public static void itemChange(Player player, Boolean setCursor) { public static void itemChange(Player player, Boolean setCursor) {
Integer slot; Integer slot;
if (SelectConfig.getUseItem_InventorySlotEnforce()) { if ((Boolean) Config.useItemInventorySlotEnforce.value) {
slot = SelectConfig.getUseItem_InventorySlot(); slot =(Integer) Config.useItemInventorySlot.value;
} else { } else {
slot = Events.useItemSlotHashMap.get(player.getName()); slot = Events.useItemSlotHashMap.get(player.getName());
} }
if (!SelectConfig.getUseItem_Enable()) { if (!(Boolean)Config.useItemEnable.value) {
return; return;
} }
UseItem.removeItem(player); UseItem.removeItem(player);
if (UseItem.protection(player, false)) return; if (UseItem.protection(player, false)) return;
if (SelectConfig.getUseItem_GiveOnlyOnFirstJoin()) { if ((Boolean)Config.useItemGiveOnlyOnFirstJoin.value) {
if (!SelectConfig.getUseItem_AllowToggle() || Events.useItemHashMap.get(player.getName())) { if (!(Boolean)Config.useItemAllowToggle.value || Events.useItemHashMap.get(player.getName())) {
if (!player.hasPlayedBefore()) { if (!player.hasPlayedBefore()) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
@ -32,7 +33,7 @@ public class ItemChange {
} }
} }
}.runTaskLater(Main.getPlugin(), 1L * 1); }.runTaskLater(Main.getPlugin(), 1L * 1);
if (SelectConfig.getCursor_ToGUIItem_OnlyOnFirstLogin() || SelectConfig.getCursor_ToGUIItem_OnLogin()) { if ((Boolean)Config.cursorToGUIItemOnlyOnFirstLogin.value ||(Boolean) Config.cursorToGUIItemOnLogin.value) {
player.getInventory().setHeldItemSlot(slot - 1); player.getInventory().setHeldItemSlot(slot - 1);
} }
} }
@ -40,7 +41,7 @@ public class ItemChange {
T2Csend.debug(Main.getPlugin(), "GiveOnlyOnFirstJoin: " + player.getName()); T2Csend.debug(Main.getPlugin(), "GiveOnlyOnFirstJoin: " + player.getName());
return; return;
} }
if (!SelectConfig.getUseItem_GiveOnEveryJoin()) { if (!(Boolean)Config.useItemGiveOnEveryJoin.value) {
T2Csend.debug(Main.getPlugin(), "!GiveOnEveryJoin: " + player.getName()); T2Csend.debug(Main.getPlugin(), "!GiveOnEveryJoin: " + player.getName());
return; return;
} }
@ -49,14 +50,14 @@ public class ItemChange {
public void run() { public void run() {
Boolean pln = Events.useItemHashMap.get(player.getName()); Boolean pln = Events.useItemHashMap.get(player.getName());
if (pln == null) return; if (pln == null) return;
if (!SelectConfig.getUseItem_AllowToggle() || pln) { if (!(Boolean)Config.useItemAllowToggle.value || pln) {
if (SelectConfig.getUseItem_InventorySlotEnforce() || player.getInventory().getItem(slot - 1) == null) { if ((Boolean)Config.useItemInventorySlotEnforce.value || player.getInventory().getItem(slot - 1) == null) {
T2Csend.debug(Main.getPlugin(), "Give: " + player.getName()); T2Csend.debug(Main.getPlugin(), "Give: " + player.getName());
UseItem.giveUseItem(player); UseItem.giveUseItem(player);
if (setCursor) { if (setCursor) {
setCursor(player, slot); setCursor(player, slot);
} }
} else if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) { } else if ((Boolean)Config.useItemInventorySlotFreeSlot.value) {
boolean empty = false; boolean empty = false;
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
if (player.getInventory().getItem(i) == null) { if (player.getInventory().getItem(i) == null) {
@ -76,11 +77,11 @@ public class ItemChange {
private static void setCursor(Player player, int slot) { private static void setCursor(Player player, int slot) {
T2Csend.debug(Main.getPlugin(), "setCursor 1 Player: " + player.getName()); T2Csend.debug(Main.getPlugin(), "setCursor 1 Player: " + player.getName());
if (!SelectConfig.getCursor_ToGUIItem_OnLogin()) { if (!(Boolean)Config.cursorToGUIItemOnLogin.value) {
return; return;
} }
T2Csend.debug(Main.getPlugin(), "setCursor 2 Player: " + player.getName()); T2Csend.debug(Main.getPlugin(), "setCursor 2 Player: " + player.getName());
if (SelectConfig.getCursor_ToGUIItem_OnlyOnFirstLogin()) { if ((Boolean)Config.cursorToGUIItemOnlyOnFirstLogin.value) {
if (!player.hasPlayedBefore()) { if (!player.hasPlayedBefore()) {
player.getInventory().setHeldItemSlot(slot - 1); player.getInventory().setHeldItemSlot(slot - 1);
T2Csend.debug(Main.getPlugin(), "setCursor 3 Player: " + player.getName()); T2Csend.debug(Main.getPlugin(), "setCursor 3 Player: " + player.getName());
@ -88,13 +89,13 @@ public class ItemChange {
return; return;
} }
T2Csend.debug(Main.getPlugin(), "setCursor 4 Player: " + player.getName()); T2Csend.debug(Main.getPlugin(), "setCursor 4 Player: " + player.getName());
if (!SelectConfig.getBungee()) { if (!T2CLibConfig.getBungee()) {
player.getInventory().setHeldItemSlot(slot - 1); player.getInventory().setHeldItemSlot(slot - 1);
T2Csend.debug(Main.getPlugin(), "setCursor 5 Player: " + player.getName()); T2Csend.debug(Main.getPlugin(), "setCursor 5 Player: " + player.getName());
return; return;
} }
T2Csend.debug(Main.getPlugin(), "setCursor 6 Player: " + player.getName()); T2Csend.debug(Main.getPlugin(), "setCursor 6 Player: " + player.getName());
if (SelectConfig.getUseItem_ServerChange()) { if ((Boolean)Config.useItemServerChange.value) {
player.getInventory().setHeldItemSlot(slot - 1); player.getInventory().setHeldItemSlot(slot - 1);
T2Csend.debug(Main.getPlugin(), "setCursor 7 Player: " + player.getName()); T2Csend.debug(Main.getPlugin(), "setCursor 7 Player: " + player.getName());
return; return;

View File

@ -3,7 +3,7 @@ package net.t2code.commandguiv2.Spigot.useItem;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.old.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
@ -17,18 +17,19 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
public class UseItem { public class UseItem {
public static void giveUseItem(Player player) { public static void giveUseItem(Player player) {
Integer slot; Integer slot;
if (protection(player, false)) return; if (protection(player, false)) return;
if (SelectConfig.getUseItem_InventorySlotEnforce()) { if ((Boolean) Config.useItemInventorySlotEnforce.value) {
slot = SelectConfig.getUseItem_InventorySlot(); slot = (Integer) Config.useItemInventorySlot.value;
} else { } else {
slot = Events.useItemSlotHashMap.get(player.getName()); slot = Events.useItemSlotHashMap.get(player.getName());
} }
if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) { if ((Boolean) Config.useItemInventorySlotFreeSlot.value) {
player.getInventory().addItem(itemStack(player)); player.getInventory().addItem(itemStack(player));
} else { } else {
T2Csend.debug(Main.getPlugin(), "setUseItem: " + player.getName() + " Slot: " + Integer.parseInt(String.valueOf(slot - 1))); T2Csend.debug(Main.getPlugin(), "setUseItem: " + player.getName() + " Slot: " + Integer.parseInt(String.valueOf(slot - 1)));
@ -38,27 +39,27 @@ public class UseItem {
public static void addUseItem(Player player) { public static void addUseItem(Player player) {
if (protection(player, false)) return; if (protection(player, false)) return;
if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) { if ((Boolean) Config.useItemInventorySlotFreeSlot.value) {
player.getInventory().addItem(itemStack(player)); player.getInventory().addItem(itemStack(player));
} else player.getInventory().addItem(itemStack(player)); } else player.getInventory().addItem(itemStack(player));
} }
private static ItemStack itemStack(Player player) { private static ItemStack itemStack(Player player) {
ItemStack item = null; ItemStack item = null;
if (SelectConfig.getUseItem_PlayerHead_Enable()) { if ((Boolean) Config.useItemPlayerHeadEnable.value) {
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) { if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
T2Csend.player(player, Util.getPrefix() + "§c Playerheads for UseItem are only available from version §61.13§c!"); T2Csend.player(player, Util.getPrefix() + "§c Playerheads for UseItem are only available from version §61.13§c!");
T2Csend.error(Main.getPlugin(), "Playerheads for UseItem are only available from version 1.13!"); T2Csend.error(Main.getPlugin(), "Playerheads for UseItem are only available from version 1.13!");
} else { } else {
item = T2CitemVersion.getHeadIS(); item = T2CitemVersion.getHeadIS();
SkullMeta playerheadmeta = (SkullMeta) item.getItemMeta(); SkullMeta playerheadmeta = (SkullMeta) item.getItemMeta();
playerheadmeta.setDisplayName(SelectConfig.getUseItem_Name()); playerheadmeta.setDisplayName(String.valueOf(Config.useItemName.value));
if (SelectConfig.getUseItem_Base64_Enable()) { if ((Boolean) Config.useItemBase64Enable.value) {
if (Main.PaPi) { if (Main.PaPi) {
playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, SelectConfig.getUseItem_Lore())); playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList<String>) Config.useItemLore.value));
} else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore())); } else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList<String>) Config.useItemLore.value));
GameProfile profile = new GameProfile(UUID.randomUUID(), ""); GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", SelectConfig.getUseItem_Base64value())); profile.getProperties().put("textures", new Property("textures", String.valueOf(Config.useItemBase64value.value)));
Field profileField = null; Field profileField = null;
try { try {
profileField = playerheadmeta.getClass().getDeclaredField("profile"); profileField = playerheadmeta.getClass().getDeclaredField("profile");
@ -69,23 +70,23 @@ public class UseItem {
} }
} else { } else {
String p; String p;
if (SelectConfig.getUseItem_PlayerWhoHasOpenedTheGUI()) { if ((Boolean) Config.useItemPlayerWhoHasOpenedTheGUI.value) {
p = player.getName(); p = player.getName();
} else p = SelectConfig.getUseItem_PlayerName(); } else p = String.valueOf(Config.useItemPlayerName.value);
playerheadmeta.setOwner(p); playerheadmeta.setOwner(p);
if (Main.PaPi) { if (Main.PaPi) {
playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, SelectConfig.getUseItem_Lore())); playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList<String>) Config.useItemLore.value));
} else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore())); } else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList<String>) Config.useItemLore.value));
} }
item.setItemMeta(playerheadmeta); item.setItemMeta(playerheadmeta);
} }
} else { } else {
item = new ItemStack(Material.valueOf(SelectConfig.getUseItem_Material())); item = new ItemStack(Material.valueOf(String.valueOf(Config.useItemMaterial.value)));
ItemMeta itemMeta = item.getItemMeta(); ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(SelectConfig.getUseItem_Name()); itemMeta.setDisplayName(String.valueOf(Config.useItemName.value));
if (Main.PaPi) { if (Main.PaPi) {
itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), player, SelectConfig.getUseItem_Lore())); itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList<String>) Config.useItemLore.value));
} else itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore())); } else itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList<String>) Config.useItemLore.value));
item.setItemMeta(itemMeta); item.setItemMeta(itemMeta);
item.setAmount(1); item.setAmount(1);
} }
@ -93,31 +94,31 @@ public class UseItem {
} }
public static boolean protection(Player player, Boolean interact) { public static boolean protection(Player player, Boolean interact) {
if (SelectConfig.getUseItemGameModeProtection()) { if ((Boolean) Config.useItemGameModeProtection.value) {
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) { if (String.valueOf(Config.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(Config.useItemGameModeList.value).contains(player.getGameMode().toString())) {
if (interact) { if (interact) {
T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode); T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode);
} else if (!SelectConfig.getUseItemGameModeRemoveItemWhenItIsDisabled()) removeItem(player); } else if (!(Boolean) Config.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player);
return true; return true;
} }
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) { if (String.valueOf(Config.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(Config.useItemGameModeList.value).contains(player.getGameMode().toString())) {
if (interact) { if (interact) {
T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode); T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode);
} else if (!SelectConfig.getUseItemGameModeRemoveItemWhenItIsDisabled()) removeItem(player); } else if (!(Boolean) Config.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player);
return true; return true;
} }
} }
if (SelectConfig.getUseItemWorldProtection()) { if ((Boolean) Config.useItemWorldProtection.value) {
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) { if (String.valueOf(Config.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(Config.useItemWorldList.value).contains(player.getWorld().getName())) {
if (interact) { if (interact) {
T2Csend.player(player, SelectMessages.UseItemDisabledInWorld); T2Csend.player(player, SelectMessages.UseItemDisabledInWorld);
} else if (!SelectConfig.getUseItemWorldRemoveItemWhenItIsDisabled()) removeItem(player); } else if (!(Boolean) Config.useItemWorldRemoveItemWhenItIsDisabled.value) removeItem(player);
return true; return true;
} }
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) { if (String.valueOf(Config.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(Config.useItemWorldList.value).contains(player.getWorld().getName())) {
if (interact) { if (interact) {
T2Csend.player(player, SelectMessages.UseItemDisabledInWorld); T2Csend.player(player, SelectMessages.UseItemDisabledInWorld);
} else if (!SelectConfig.getUseItemWorldRemoveItemWhenItIsDisabled()) removeItem(player); } else if (!(Boolean) Config.useItemWorldRemoveItemWhenItIsDisabled.value) removeItem(player);
return true; return true;
} }
} }
@ -129,8 +130,8 @@ public class UseItem {
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) { for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
ItemStack itm = player.getInventory().getItem(iam); ItemStack itm = player.getInventory().getItem(iam);
if (itm != null) { if (itm != null) {
if (itm.getType() == Material.valueOf(SelectConfig.getUseItem_Material()) || itm.getType() == T2CitemVersion.getHead()) { if (itm.getType() == Material.valueOf(String.valueOf(Config.useItemMaterial.value)) || itm.getType() == T2CitemVersion.getHead()) {
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { if (itm.getItemMeta().getDisplayName().equals(Config.useItemName.value)) {
player.getInventory().remove(itm); player.getInventory().remove(itm);
player.updateInventory(); player.updateInventory();
break; break;

View File

@ -7,7 +7,7 @@ public class Util {
} }
public static String getRequiredT2CodeLibVersion() { public static String getRequiredT2CodeLibVersion() {
return "14.0"; return "14.2";
} }
public static String getPrefix() { public static String getPrefix() {

View File

@ -1,5 +1,6 @@
package net.t2code.commandguiv2.api; package net.t2code.commandguiv2.api;
import net.t2code.commandguiv2.Spigot.config.config.Config;
import net.t2code.commandguiv2.Spigot.useItem.ItemChange; import net.t2code.commandguiv2.Spigot.useItem.ItemChange;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.useItem.Events;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
@ -29,13 +30,13 @@ public class CGuiAPI {
public static boolean hasUseItemInMainHand(Player player) { public static boolean hasUseItemInMainHand(Player player) {
ItemStack item = player.getInventory().getItemInMainHand(); ItemStack item = player.getInventory().getItemInMainHand();
return item.hasItemMeta() && item.getItemMeta().hasDisplayName() return item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name()); && item.getItemMeta().getDisplayName().equals(String.valueOf(Config.useItemName.value));
} }
public static boolean hasUseItemInOffHand(Player player) { public static boolean hasUseItemInOffHand(Player player) {
ItemStack item = player.getInventory().getItemInOffHand(); ItemStack item = player.getInventory().getItemInOffHand();
return item.hasItemMeta() && item.getItemMeta().hasDisplayName() return item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name()); && item.getItemMeta().getDisplayName().equals(String.valueOf(Config.useItemName.value));
} }
public static void disableItemGiveOnJoin(Boolean disableItemGiveOnJoin) { public static void disableItemGiveOnJoin(Boolean disableItemGiveOnJoin) {