Compare commits

...

9 Commits
main ... 2.9.0

Author SHA1 Message Date
JaTiTV 33fbe74818 UseItem Config 2023-01-04 12:36:23 +01:00
JaTiTV 2abdcdd3ad big changes 2023-01-04 05:58:48 +01:00
JaTiTV 754f486d1b Update ItemChange.java 2022-12-31 18:33:27 +01:00
JaTiTV 9059790a65 config change for useItems 2022-12-31 17:57:44 +01:00
JaTiTV 6fefa8701e config convert v6 2022-12-31 02:59:15 +01:00
JaTiTV 052d2393aa language fix
when trying to open a gui that does not esist, it now shows which gui you tried to open
2022-12-31 01:27:17 +01:00
JaTiTV c34c6ab09f config convert 2022-12-31 01:22:40 +01:00
JaTiTV f68916ef54 config recode in enum 2022-12-30 23:05:24 +01:00
JaTiTV cc9648315f config changes (not compelable) 2022-12-30 06:31:43 +01:00
49 changed files with 1944 additions and 1104 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId> <artifactId>CommandGUI_V2</artifactId>
<version>2.8.14</version> <version>2.9.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>CommandGUI</name> <name>CommandGUI</name>
@ -75,7 +75,8 @@
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>13.4</version> <version>DEV-14.2</version>
<classifier>1</classifier>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>

View File

@ -1,8 +1,8 @@
package net.t2code.commandguiv2.Spigot; package net.t2code.commandguiv2.Spigot;
import net.t2code.commandguiv2.Spigot.objects.functions.Function; import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
import net.t2code.commandguiv2.Spigot.system.Load; import net.t2code.commandguiv2.Spigot.system.Load;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui; import net.t2code.commandguiv2.Spigot.objects.GuiObject;
import net.t2code.commandguiv2.Spigot.database.MySQL; import net.t2code.commandguiv2.Spigot.database.MySQL;
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;
@ -39,11 +39,6 @@ public final class Main extends JavaPlugin {
public static Boolean LuckyBox = false; public static Boolean LuckyBox = false;
public static Boolean PlugManGUI = false; public static Boolean PlugManGUI = false;
public static HashMap<String, Gui> guiHashMap = new HashMap<>();
public static ArrayList<String> allAliases = new ArrayList<>();
public static HashMap<String, Function> functionHashMap = new HashMap<>();
@Override @Override
public void onEnable() { public void onEnable() {
// Plugin startup logic // Plugin startup logic

View File

@ -1,7 +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.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
@ -30,7 +30,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(ConfigValues.adminSubCommand.value))) {
if (args.length == 1) { if (args.length == 1) {
Help.sendHelp(sender, prefix); Help.sendHelp(sender, prefix);
return false; return false;
@ -105,7 +105,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(ConfigValues.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,8 +1,9 @@
package net.t2code.commandguiv2.Spigot.cmdManagement; package net.t2code.commandguiv2.Spigot.cmdManagement;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -20,26 +21,44 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
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) ConfigValues.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 == 2 || args.length == 3) {
String useItemKey= args[0];
if (!Cache.useItemHash.containsKey(useItemKey)){
T2Csend.sender(sender,"das useitem " +useItemKey+" exestiert nicht");
return false;
}
if (sender instanceof Player) { if (sender instanceof Player) {
if (SelectConfig.getUseItem_AllowToggle()) { if ((Boolean) ConfigValues.useItemAllowToggle.value) {
switch (args[0].toLowerCase()) { switch (args[1].toLowerCase()) {
case "on": case "on":
Commands.itemOn(player); Commands.itemOn(player, useItemKey);
break; break;
case "off": case "off":
Commands.itemOff(player); Commands.itemOff(player, useItemKey);
break; break;
case "slot": case "slot":
if (args.length == 2) { if (args.length == 3) {
try { try {
Commands.onSetSlot(player, Integer.valueOf(args[1])); Commands.onSetSlot(player, useItemKey, Integer.valueOf(args[2]));
} catch (Exception e5) { } catch (Exception e5) {
T2Csend.player(player, SelectMessages.ItemSlot_wrongValue); T2Csend.player(player, SelectMessages.ItemSlot_wrongValue);
} }
@ -65,7 +84,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) ConfigValues.useItemAllowToggle.value) {
put("slot", "commandgui.useitem.toggle"); put("slot", "commandgui.useitem.toggle");
} }
}}; }};
@ -74,7 +93,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) ConfigValues.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,26 +1,31 @@
package net.t2code.commandguiv2.Spigot.cmdManagement; package net.t2code.commandguiv2.Spigot.cmdManagement;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect;
import net.t2code.commandguiv2.Spigot.config.functions.SelectFunctions;
import net.t2code.commandguiv2.Spigot.config.gui.SelectGui;
import net.t2code.commandguiv2.Spigot.function.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.GuiObject;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui;
import net.t2code.commandguiv2.Spigot.cmdManagement.register.AliasRegister; import net.t2code.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
import net.t2code.commandguiv2.Spigot.gui.OpenGUI; import net.t2code.commandguiv2.Spigot.function.gui.OpenGUI;
import net.t2code.commandguiv2.Spigot.useItem.UseItem; import net.t2code.commandguiv2.Spigot.function.useItem.UseItem;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.commandguiv2.Spigot.config.languages.LanguagesCreate; import net.t2code.commandguiv2.Spigot.config.languages.LanguagesCreate;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.system.Permissions; import net.t2code.commandguiv2.Spigot.system.Permissions;
import net.t2code.commandguiv2.Spigot.database.SelectDatabase; import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
import net.t2code.commandguiv2.Spigot.sound.Sound; import net.t2code.commandguiv2.Spigot.sound.PlaySound;
import net.t2code.commandguiv2.Spigot.enums.SoundEnum; import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.Objects; import java.util.Objects;
public class Commands { public class Commands {
@ -36,22 +41,35 @@ 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(); try {
ConfigSelect.selectConfig();
} catch (IOException e) {
throw new RuntimeException(e);
}
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(ConfigValues.adminSubCommand.value), "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.getStorage())) { if (!Objects.equals(SelectDatabase.getStorage().toString(), ConfigValues.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!");
} }
LanguagesCreate.langCreate(); LanguagesCreate.langCreate();
Obj_Select.onSelect(); try {
SelectFunctions.onSelectFunction();
} catch (Exception e) {
e.printStackTrace();
}
try {
SelectGui.onSelectGui();
} catch (Exception e) {
e.printStackTrace();
}
SelectMessages.onSelect(Util.getPrefix()); SelectMessages.onSelect(Util.getPrefix());
SelectConfig.sound(Util.getPrefix()); ConfigValues.sound();
try { try {
AliasRegister.onRegister(); AliasRegister.onRegister();
@ -64,7 +82,7 @@ public class Commands {
e.printStackTrace(); e.printStackTrace();
} }
if (SelectConfig.getBungee()) { if (SelectLibConfig.getBungee()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.getPlugin(), "commandgui:bungee"); Bukkit.getMessenger().registerOutgoingPluginChannel(Main.getPlugin(), "commandgui:bungee");
} }
@ -80,26 +98,26 @@ 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(ConfigValues.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(ConfigValues.useItemName.value)));
Sound.play(target, SoundEnum.Give); PlaySound.play(target, SoundEnum.Give);
} else { } else {
sender.sendMessage(SelectMessages.PlayerNotFond.replace("[player]", target.getName())); sender.sendMessage(SelectMessages.PlayerNotFond.replace("[player]", target.getName()));
if (sender instanceof Player) Sound.play((Player) sender, SoundEnum.PlayerNotFound); if (sender instanceof Player) PlaySound.play((Player) sender, SoundEnum.PlayerNotFound);
} }
} }
public static void itemOn(Player player) { public static void itemOn(Player player, String useItemKey) {
UseItem.removeItem(player); UseItem.removeItem(player);
Integer slot = null; Integer slot = null;
if (SelectConfig.getUseItem_InventorySlotEnforce()) { if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value) {
slot = SelectConfig.getUseItem_InventorySlot(); slot = (Integer) ConfigValues.useItemInventorySlot.value;
} else { } else {
slot = Events.useItemSlotHashMap.get(player.getName()); slot = Events.useItemSlotHashMap.get(player.getName());
} }
T2Csend.debug(Main.getPlugin(), String.valueOf(slot)); T2Csend.debug(Main.getPlugin(), String.valueOf(slot));
if (player.getInventory().getItem(slot - 1) == null) { if (player.getInventory().getItem(slot - 1) == null) {
SelectDatabase.setItemStatusTrue(player); SelectDatabase.setItemStatus(player, useItemKey, true);
UseItem.giveUseItem(player); UseItem.giveUseItem(player);
} else { } else {
boolean empty = false; boolean empty = false;
@ -110,24 +128,24 @@ public class Commands {
} }
} }
if (empty) { if (empty) {
SelectDatabase.setItemStatusTrue(player); SelectDatabase.setItemStatus(player, useItemKey, true);
UseItem.addUseItem(player); UseItem.addUseItem(player);
T2Csend.player(player, SelectMessages.ItemON); T2Csend.player(player, SelectMessages.ItemON);
} else { } else {
T2Csend.player(player, SelectMessages.NoInventorySpace); T2Csend.player(player, SelectMessages.NoInventorySpace);
Sound.play(player, SoundEnum.NoInventorySpace); PlaySound.play(player, SoundEnum.NoInventorySpace);
} }
} }
} }
public static void itemOff(Player player) { public static void itemOff(Player player, String useItemKey) {
SelectDatabase.setItemStatusFalse(player); SelectDatabase.setItemStatus(player, useItemKey, false);
UseItem.removeItem(player); UseItem.removeItem(player);
T2Csend.player(player, SelectMessages.ItemOFF); T2Csend.player(player, SelectMessages.ItemOFF);
} }
public static void onSetSlot(Player player, Integer setSlot) { public static void onSetSlot(Player player, String useItemKey, Integer setSlot) {
if (!SelectConfig.getUseItem_AllowSetSlot()) { if (!(Boolean) ConfigValues.useItemAllowSetSlot.value) {
T2Csend.player(player, Util.getPrefix() + " §4Function disabled"); T2Csend.player(player, Util.getPrefix() + " §4Function disabled");
return; return;
} }
@ -148,13 +166,13 @@ public class Commands {
} }
} }
if (SelectConfig.getUseItem_InventorySlotEnforce() || player.getInventory().getItem(setSlot - 1) != null) { if ((Boolean) ConfigValues.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;
} }
UseItem.removeItem(player); UseItem.removeItem(player);
SelectDatabase.setSlot(player, setSlot); SelectDatabase.setSlot(player, useItemKey, setSlot);
Events.useItemSlotHashMap.replace(player.getName(), setSlot); Events.useItemSlotHashMap.replace(player.getName(), setSlot);
if (Events.useItemHashMap.get(player.getName())) { if (Events.useItemHashMap.get(player.getName())) {
@ -165,11 +183,11 @@ public class Commands {
} }
public static void gui(Player player) { public static void gui(Player player) {
if (Main.guiHashMap.containsKey(SelectConfig.getDefaultGUI())) { if (Cache.guiHashMap.containsKey(String.valueOf(ConfigValues.defaultGUI.value))) {
Gui gui = Main.guiHashMap.get(SelectConfig.getDefaultGUI()); GuiObject gui = Cache.guiHashMap.get(String.valueOf(ConfigValues.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(ConfigValues.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));
@ -177,14 +195,14 @@ public class Commands {
} }
public static void gui(Player player, String arg) { public static void gui(Player player, String arg) {
if (Main.guiHashMap.containsKey(arg)) { if (Cache.guiHashMap.containsKey(arg)) {
Gui gui = Main.guiHashMap.get(arg); GuiObject gui = Cache.guiHashMap.get(arg);
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) { if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, arg, true); OpenGUI.openGUI(player, arg, true);
} else T2Csend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.key) } else T2Csend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.key)
.replace("[perm]", "commandgui.command." + arg.toLowerCase())); .replace("[perm]", "commandgui.command." + arg.toLowerCase()));
} else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.key)); } else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.key));
} else T2Csend.player(player, SelectMessages.guiNotFound); } else T2Csend.player(player, SelectMessages.guiNotFound.replace("[gui]", arg));
} }
} }

View File

@ -1,10 +1,11 @@
package net.t2code.commandguiv2.Spigot.cmdManagement; package net.t2code.commandguiv2.Spigot.cmdManagement;
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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.GuiObject;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
import net.t2code.commandguiv2.cache.Cache;
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 org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -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()); GuiObject gui = Cache.guiHashMap.get(String.valueOf(ConfigValues.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);
@ -29,7 +30,7 @@ public class Help {
} }
private static void cgui(CommandSender sender, Gui gui) { private static void cgui(CommandSender sender, GuiObject gui) {
if (!sender.hasPermission("commandgui.command")) return; if (!sender.hasPermission("commandgui.command")) return;
if (sender instanceof Player) { if (sender instanceof Player) {
@ -40,12 +41,12 @@ public class Help {
private static void open(CommandSender sender) { private static void open(CommandSender sender) {
if (!sender.hasPermission("commandgui.command")) return; if (!sender.hasPermission("commandgui.command")) return;
for (String alias : Main.allAliases) { for (String alias : Cache.allAliases) {
if (Main.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) { if (Cache.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) {
if (sender instanceof Player) { if (sender instanceof Player) {
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Main.guiHashMap.get(alias).guiName))); T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Cache.guiHashMap.get(alias).guiName)));
} else } else
T2Csend.sender(sender, prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Main.guiHashMap.get(alias).guiName))); T2Csend.sender(sender, prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Cache.guiHashMap.get(alias).guiName)));
} }
} }
} }

View File

@ -2,6 +2,7 @@ package net.t2code.commandguiv2.Spigot.cmdManagement.register;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
@ -14,13 +15,13 @@ public class AliasRegister {
public static void onRegister() { public static void onRegister() {
Plugin plugin = Main.getPlugin(); Plugin plugin = Main.getPlugin();
T2Csend.debug(plugin, Bukkit.getServer().getClass().getPackage().getName()); T2Csend.debug(plugin, Bukkit.getServer().getClass().getPackage().getName());
if (Main.allAliases.toString().equals("[]")) { if (Cache.allAliases.toString().equals("[]")) {
T2Csend.console(Util.getPrefix() + " §4No GUI files available"); T2Csend.console(Util.getPrefix() + " §4No GUI files available");
return; return;
} }
for (String alias : Main.allAliases) { for (String alias : Cache.allAliases) {
if (Main.guiHashMap.get(alias) != null) { if (Cache.guiHashMap.get(alias) != null) {
if (Main.guiHashMap.get(alias).commandAliasEnable) { if (Cache.guiHashMap.get(alias).commandAliasEnable) {
try { try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap"); final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true); bukkitCommandMap.setAccessible(true);

View File

@ -2,9 +2,10 @@ package net.t2code.commandguiv2.Spigot.cmdManagement.register;
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.GuiObject;
import net.t2code.commandguiv2.Spigot.gui.OpenGUI; import net.t2code.commandguiv2.Spigot.function.gui.OpenGUI;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -23,7 +24,7 @@ public class RegisterCommand extends Command {
if (sender instanceof Player) { if (sender instanceof Player) {
Player player = (Player) sender; Player player = (Player) sender;
Gui gui = Main.guiHashMap.get(alias); GuiObject gui = Cache.guiHashMap.get(alias);
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) { if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) { if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, alias, true); OpenGUI.openGUI(player, alias, true);

View File

@ -0,0 +1,54 @@
package net.t2code.commandguiv2.Spigot.config.config;
import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV6;
import net.t2code.commandguiv2.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class ConfigSelect {
public static void selectConfig() throws IOException {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (yamlConfiguration.contains("ConfigVersion")) {
if (yamlConfiguration.getInt("ConfigVersion") < (Integer) ConfigValues.configVersion.value && new File(Main.getPath(), "config.yml").exists()) {
T2Csend.console(Util.getPrefix() + " §4----------------------");
T2Csend.console(Util.getPrefix() + " ");
T2Csend.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
T2Csend.console(Util.getPrefix() + " ");
T2Csend.console(Util.getPrefix() + " §4----------------------");
if (yamlConfiguration.getInt("ConfigVersion") < 5) {
ConfigConverterV5.convert();
config = new File(Main.getPath(), "config.yml");
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
}
if (yamlConfiguration.getInt("ConfigVersion") < 6) {
new ConfigConverterV6();
config = new File(Main.getPath(), "config.yml");
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
}
}
}
yamlConfiguration.set(ConfigValues.configVersion.path, ConfigValues.configVersion.value);
for (ConfigValues value : ConfigValues.values()) {
T2Cconfig.set(value.path, value.value, yamlConfiguration);
value.value = T2Cconfig.selectObject(Util.getPrefix(), value.path, yamlConfiguration);
}
try {
yamlConfiguration.save(config);
} catch (
IOException e) {
e.printStackTrace();
}
T2Csend.console(Util.getPrefix() + " §2Config was loaded successfully.");
}
}

View File

@ -0,0 +1,200 @@
package net.t2code.commandguiv2.Spigot.config.config;
import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.enums.StorageEnum;
import net.t2code.commandguiv2.Util;
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.Collections;
import java.util.List;
public enum ConfigValues {
configVersion("configVersion", 6),
debug("plugins.debug", false),
updateCheckOnJoin("plugin.updateCheck.onJoin", true),
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true),
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60),
helpAlias("plugin.helpAlias", true),
adminSubCommand("plugin.adminSubCommand", "admin"),
language("plugin.language", "english"),
currency("plugin.currency", "$"),
defaultGUI("plugin.defaultGUI", "default"),
storage("storage.type", StorageEnum.SQLITE.name()),
mysqlIp("storage.mySQL.ip", "localhost"),
mysqlPort("storage.mySQL.port", 3306),
mysqlDatabase("storage.mySQL.database", "database"),
mysqlUser("storage.mySQL.user", "root"),
mysqlPassword("storage.mySQL.password", "password"),
mysqlSSL("storage.mySQL.ssl", false),
useItemEnable("useItem.enable", true),
useItemAllowToggle("useItem.allowToggle", true),
useItemAllowSetSlot("useItem.allowSetSlot", true),
useItemBlockMoveAndDrop("useItem.blockMoveAndDrop", true),
useItemOpenGUI("useItem.openGUI", "default"),
useItemPermission("useItem.permission.neededToUse", true),
useItemKeepAtCommandClear("useItem.keepAtCommandClear", true),
useItemInventorySlotFreeSlot("useItem.inventorySlot.freeSlot", 1),
useItemInventorySlot("useItem.inventorySlot.slot", 1),
useItemInventorySlotEnforce("useItem.inventorySlot.slotEnforce", false),
useItemMaterial("useItem.item.material", "paper"),
useItemPlayerHeadEnable("useItem.item.playerHead.enable", false),
useItemBase64Enable("useItem.item.playerHead.base64.enable", false),
useItemBase64value("useItem.item.playerHead.base64.base64Value", ""),
useItemPlayerWhoHasOpenedTheGUI("useItem.item.playerHead.playerWhoHasOpenedTheGUI", false),
useItemPlayerName("useItem.item.playerHead.playerName", ""),
useItemName("useItem.item.name", "&bDefault &6GUI"),
useItemLore("useItem.item.lore", Collections.singletonList("&eThis is an example GUI")),
useItemGiveOnEveryJoin("useItem.join.giveOnEveryJoin", true),
useItemGiveOnlyOnFirstJoin("useItem.join.giveOnlyOnFirstJoin", false),
cursorToGUIItemOnLogin("useItem.join.cursor.toGUIItem.onLogin.enable", true),
cursorToGUIItemOnlyOnFirstLogin("useItem.join.cursor.toGUIItem.spigot.onlyOnFirstLogin", true),
useItemServerChange("useItem.join.cursor.toGUIItem.bungee.onServerChange", false),
toggleItemOnOrYesBase64("toggle.items.onOrYes.item.base64.enable", false),
toggleItemOnOrYesBase64Value("toggle.items.onOrYes.item.base64.base64Value", ""),
toggleItemOnOrYesMaterial("toggle.items.onOrYes.item.material", Main.legacy ? "WOOL,5" : T2CitemVersion.getGreenWool().getType().toString()),
toggleItemOffOrNoBase64("toggle.items.offOrNo.item.base64.enable", false),
toggleItemOffOrNoBase64Value("toggle.items.offOrNo.item.base64.base64Value", T2CitemVersion.getGreenWool().getType().toString()),
toggleItemOffOrNoMaterial("toggle.items.offOrNo.item.material", Main.legacy ? "WOOL,14" : T2CitemVersion.getRedWool().getType().toString()),
togglePermTrue("toggle.permission.commands.true", "luckperms user [player] permission set [perm] true"),
togglePermFalse("toggle.permission.commands.false", "luckperms user [player] permission set [perm] false"),
placeholderTrue("placeholder.True", "&2true"),
placeholderFalse("placeholder.False", "&4false"),
soundEnable("sound.enable", true),
soundOpenInventoryEnable("sound.openInventory.enable", true),
soundOpenInventoryInput("sound.openInventory.sound", getOpenInventory().toString()),
soundClickEnable("sound.click.enable", true),
soundClickInput("sound.click.sound", getClick().toString()),
soundNoMoneyEnable("sound.noMoney.enable", true),
soundNoMoneyInput("sound.noMoney.sound", getNoMoney().toString()),
soundNoInventorySpaceEnable("sound.noInventorySpace.enable", true),
soundNoInventorySpaceInput("sound.noInventorySpace.sound", getNoInventorySpace().toString()),
soundGiveEnable("sound.give.enable", true),
soundGiveInput("sound.give.sound", getGive().toString()),
soundPlayerNotFoundEnable("sound.playerNotFound.enable", true),
soundPlayerNotFoundInput("sound.playerNotFound.sound", getPlayerNotFound().toString()),
useItemGameModeChangeEnable("advanced.useItem.gameMode.change.enable", true),
useItemGameModeChangeDelayInTicks("advanced.useItem.gameMode.change.delayInTicks", 1),
useItemGameModeProtection("advanced.useItem.gameMode.protection.enable", false),
useItemGameModeRemoveItemWhenItIsDisabled("advanced.useItem.gameMode.protection.removeItemWhenItIsDisabled", false),
useItemGameModeMode("advanced.useItem.gameMode.protection.mode", "blacklist"),
useItemGameModeList("advanced.useItem.gameMode.protection.list", Arrays.asList("CREATIVE", "Spectator")),
useItemWorldChangeEnable("advanced.useItem.world.change.enable", true),
useItemWorldChangeDelayInTicks("advanced.useItem.world.change.delayInTicks", 1),
useItemWorldProtection("advanced.useItem.world.protection.enable", false),
useItemWorldRemoveItemWhenItIsDisabled("advanced.useItem.world.protection.removeItemWhenItIsDisabled", false),
useItemWorldMode("advanced.useItem.world.protection.mode", "blacklist"),
useItemWorldList("advanced.useItem.world.protection.list", Arrays.asList("World1", "World2")),
disableInfoBySneak("advanced.useItem.disableInfoBySneak", false),
useItemItemBlockBlacklist("advanced.useItem.itemBlockBlacklist", getItemBlockBlacklist());
public final String path;
public Object value;
ConfigValues(String path, Object defaultValue) {
this.path = path;
this.value = defaultValue;
}
public static void sound() {
check(soundOpenInventoryInput,getOpenInventory());
check(soundNoMoneyInput,getNoMoney());
check(soundNoInventorySpaceInput,getNoInventorySpace());
check(soundGiveInput,getGive());
check(soundPlayerNotFoundInput,getPlayerNotFound());
}
private static void check(ConfigValues 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

@ -1,4 +1,4 @@
package net.t2code.commandguiv2.Spigot.config.config; package net.t2code.commandguiv2.Spigot.config.config.old;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
@ -26,7 +26,7 @@ public class ConfigCreate {
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);
if (!config.exists()) T2Cconfig.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration); // if (!config.exists()) T2Cconfig.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
T2Cconfig.set("Plugin.Debug", false, yamlConfiguration); T2Cconfig.set("Plugin.Debug", false, yamlConfiguration);
T2Cconfig.set("Plugin.updateCheck.onJoin", true, yamlConfiguration); T2Cconfig.set("Plugin.updateCheck.onJoin", true, yamlConfiguration);
@ -78,7 +78,7 @@ public class ConfigCreate {
//convert //convert
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin")) { if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin")) {
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin", yamlConfiguration); T2Cconfig.set( "UseItem.Join.Cursor.ToGUIItem.OnEveryLogin", yamlConfiguration);
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin"), yamlConfiguration); T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin"), yamlConfiguration);
} }
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin")) { if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin")) {

View File

@ -1,7 +1,7 @@
package net.t2code.commandguiv2.Spigot.config.config; package net.t2code.commandguiv2.Spigot.config.config.old;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5; import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
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.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
@ -12,7 +12,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class SelectConfig { public class SelectConfig {
@ -20,16 +19,16 @@ public class 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);
if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) { // if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) {
T2Csend.console(Util.getPrefix() + " §4----------------------"); // T2Csend.console(Util.getPrefix() + " §4----------------------");
T2Csend.console(Util.getPrefix() + " "); // T2Csend.console(Util.getPrefix() + " ");
T2Csend.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!"); // T2Csend.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
T2Csend.console(Util.getPrefix() + " "); // T2Csend.console(Util.getPrefix() + " ");
T2Csend.console(Util.getPrefix() + " §4----------------------"); // T2Csend.console(Util.getPrefix() + " §4----------------------");
if (yamlConfiguration.getInt("ConfigVersion") < 5) { // if (yamlConfiguration.getInt("ConfigVersion") < 5) {
ConfigConverterUnderV5.convert(); // ConfigConverterV5.convert();
} // }
} // }
Debug = yamlConfiguration.getBoolean("Plugin.Debug"); Debug = yamlConfiguration.getBoolean("Plugin.Debug");
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin"); updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin");
@ -51,7 +50,6 @@ public class SelectConfig {
mysqlSSL = yamlConfiguration.getBoolean("Storage.MySQL.SSL"); mysqlSSL = yamlConfiguration.getBoolean("Storage.MySQL.SSL");
Bungee = yamlConfiguration.getBoolean("BungeeCord.Enable"); Bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
thisServer = yamlConfiguration.getString("BungeeCord.ThisServer");
UseItem_Enable = yamlConfiguration.getBoolean("UseItem.Enable"); UseItem_Enable = yamlConfiguration.getBoolean("UseItem.Enable");
@ -113,11 +111,8 @@ public class SelectConfig {
UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.Enable"); UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.Enable");
UseItemGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled"); UseItemGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled");
UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameMode.Protection.Mode"); UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameMode.Protection.Mode");
List<String> gml = new ArrayList<>();
for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")) { UseItemGameModeList = yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List");
gml.add(gm.toUpperCase());
}
UseItemGameModeList = gml;
UseItemWorldChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.World.Change.Enable"); UseItemWorldChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.World.Change.Enable");
UseItemWorldChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.World.Change.DelayInTicks"); UseItemWorldChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.World.Change.DelayInTicks");
@ -258,7 +253,7 @@ public class SelectConfig {
public static void setConfigVersion() { public static void setConfigVersion() {
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);
yamlConfiguration.set("ConfigVersion", Util.getConfigVersion()); // yamlConfiguration.set("ConfigVersion", Util.getConfigVersion());
try { try {
yamlConfiguration.save(config); yamlConfiguration.save(config);
} catch (IOException e) { } catch (IOException e) {
@ -287,7 +282,6 @@ public class SelectConfig {
private static Boolean Bungee; private static Boolean Bungee;
private static String thisServer;
private static String DefaultGUI; private static String DefaultGUI;
@ -373,339 +367,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 getThisServer() { // public static String getDefaultGUI() {
return thisServer; // return DefaultGUI;
} // }
//
public static String getDefaultGUI() { // public static Boolean getUseItem_Enable() {
return DefaultGUI; // return UseItem_Enable;
} // }
//
public static Boolean getUseItem_Enable() { // public static Boolean getUseItem_AllowToggle() {
return UseItem_Enable; // return UseItem_AllowToggle;
} // }
//
public static Boolean getUseItem_AllowToggle() { // public static Boolean getUseItem_AllowSetSlot() {
return UseItem_AllowToggle; // return UseItem_AllowSetSlot;
} // }
//
public static Boolean getUseItem_AllowSetSlot() { // public static Boolean getUseItem_GiveOnEveryJoin() {
return UseItem_AllowSetSlot; // return UseItem_GiveOnEveryJoin;
} // }
//
public static Boolean getUseItem_GiveOnEveryJoin() { // public static Boolean getUseItem_GiveOnlyOnFirstJoin() {
return UseItem_GiveOnEveryJoin; // return UseItem_GiveOnlyOnFirstJoin;
} // }
//
public static Boolean getUseItem_GiveOnlyOnFirstJoin() { // public static Boolean getUseItem_ServerChange() {
return UseItem_GiveOnlyOnFirstJoin; // return UseItem_ServerChange;
} // }
//
public static Boolean getUseItem_ServerChange() { // public static Boolean getCursor_ToGUIItem_OnLogin() {
return UseItem_ServerChange; // return Cursor_ToGUIItem_OnLogin;
} // }
//
public static Boolean getCursor_ToGUIItem_OnLogin() { // public static Boolean getCursor_ToGUIItem_OnlyOnFirstLogin() {
return Cursor_ToGUIItem_OnLogin; // return Cursor_ToGUIItem_OnlyOnFirstLogin;
} // }
//
public static Boolean getCursor_ToGUIItem_OnlyOnFirstLogin() { // public static Boolean getUseItem_BlockMoveAndDrop() {
return Cursor_ToGUIItem_OnlyOnFirstLogin; // return UseItem_BlockMoveAndDrop;
} // }
//
public static Boolean getUseItem_BlockMoveAndDrop() { // public static String getUseItem_OpenGUI() {
return UseItem_BlockMoveAndDrop; // return UseItem_OpenGUI;
} // }
//
public static String getUseItem_OpenGUI() { // public static Boolean getUseItem_Permission() {
return UseItem_OpenGUI; // return UseItem_Permission;
} // }
//
public static Boolean getUseItem_Permission() { // public static Boolean getUseItem_KeepAtCommandClear() {
return UseItem_Permission; // return UseItem_KeepAtCommandClear;
} // }
//
public static Boolean getUseItem_KeepAtCommandClear() { // public static Boolean getUseItemGameModeChangeEnable() {
return UseItem_KeepAtCommandClear; // return UseItemGameModeChangeEnable;
} // }
//
public static Boolean getUseItemGameModeChangeEnable() { // public static int getUseItemGameModeChangeDelayInTicks() {
return UseItemGameModeChangeEnable; // return UseItemGameModeChangeDelayInTicks;
} // }
//
public static int getUseItemGameModeChangeDelayInTicks() { // public static Boolean getUseItemGameModeProtection() {
return UseItemGameModeChangeDelayInTicks; // return UseItemGameModeProtection;
} // }
//
public static Boolean getUseItemGameModeProtection() { // public static Boolean getUseItemGameModeRemoveItemWhenItIsDisabled() {
return UseItemGameModeProtection; // return UseItemGameModeRemoveItemWhenItIsDisabled;
} // }
//
public static Boolean getUseItemGameModeRemoveItemWhenItIsDisabled() { // public static String getUseItemGameModeMode() {
return UseItemGameModeRemoveItemWhenItIsDisabled; // return UseItemGameModeMode;
} // }
//
public static String getUseItemGameModeMode() { // public static List<String> getUseItemGameModeList() {
return UseItemGameModeMode; // return UseItemGameModeList;
} // }
//
public static List<String> getUseItemGameModeList() { // public static Boolean getUseItemWorldChangeEnable() {
return UseItemGameModeList; // return UseItemWorldChangeEnable;
} // }
//
public static Boolean getUseItemWorldChangeEnable() { // public static int getUseItemWorldChangeDelayInTicks() {
return UseItemWorldChangeEnable; // return UseItemWorldChangeDelayInTicks;
} // }
//
public static int getUseItemWorldChangeDelayInTicks() { // public static Boolean getUseItemWorldProtection() {
return UseItemWorldChangeDelayInTicks; // return UseItemWorldProtection;
} // }
//
public static Boolean getUseItemWorldProtection() { // public static Boolean getUseItemWorldRemoveItemWhenItIsDisabled() {
return UseItemWorldProtection; // return UseItemWorldRemoveItemWhenItIsDisabled;
} // }
//
public static Boolean getUseItemWorldRemoveItemWhenItIsDisabled() { // public static String getUseItemWorldMode() {
return UseItemWorldRemoveItemWhenItIsDisabled; // return UseItemWorldMode;
} // }
//
public static String getUseItemWorldMode() { // public static List<String> getUseItemWorldList() {
return UseItemWorldMode; // return UseItemWorldList;
} // }
//
public static List<String> getUseItemWorldList() { // public static List<String> getUseItemItemBlockBlacklist() {
return UseItemWorldList; // return UseItemItemBlockBlacklist;
} // }
//
public static List<String> getUseItemItemBlockBlacklist() { // public static Boolean getDisableInfoBySneak() {
return UseItemItemBlockBlacklist; // return disableInfoBySneak;
} // }
//
public static Boolean getDisableInfoBySneak() { // public static Boolean getUseItem_InventorySlot_FreeSlot() {
return disableInfoBySneak; // return UseItem_InventorySlot_FreeSlot;
} // }
//
public static Boolean getUseItem_InventorySlot_FreeSlot() { // public static Integer getUseItem_InventorySlot() {
return UseItem_InventorySlot_FreeSlot; // return UseItem_InventorySlot;
} // }
//
public static Integer getUseItem_InventorySlot() { // public static Boolean getUseItem_InventorySlotEnforce() {
return UseItem_InventorySlot; // return UseItem_InventorySlotEnforce;
} // }
//
public static Boolean getUseItem_InventorySlotEnforce() { // public static String getUseItem_Material() {
return UseItem_InventorySlotEnforce; // return UseItem_Material;
} // }
//
public static String getUseItem_Material() { // public static Boolean getUseItem_PlayerHead_Enable() {
return UseItem_Material; // return UseItem_PlayerHead_Enable;
} // }
//
public static Boolean getUseItem_PlayerHead_Enable() { // public static Boolean getUseItem_Base64_Enable() {
return UseItem_PlayerHead_Enable; // return UseItem_Base64_Enable;
} // }
//
public static Boolean getUseItem_Base64_Enable() { // public static String getUseItem_Base64value() {
return UseItem_Base64_Enable; // return UseItem_Base64value;
} // }
//
public static String getUseItem_Base64value() { // public static Boolean getUseItem_PlayerWhoHasOpenedTheGUI() {
return UseItem_Base64value; // return UseItem_PlayerWhoHasOpenedTheGUI;
} // }
//
public static Boolean getUseItem_PlayerWhoHasOpenedTheGUI() { // public static String getUseItem_PlayerName() {
return UseItem_PlayerWhoHasOpenedTheGUI; // return UseItem_PlayerName;
} // }
//
public static String getUseItem_PlayerName() { // public static String getUseItem_Name() {
return UseItem_PlayerName; // return UseItem_Name;
} // }
//
public static String getUseItem_Name() { // public static List<String> getUseItem_Lore() {
return UseItem_Name; // return UseItem_Lore;
} // }
//
public static List<String> getUseItem_Lore() { // public static Boolean getToggleItemOnOrYesBase64() {
return UseItem_Lore; // return toggleItemOnOrYesBase64;
} // }
//
public static Boolean getToggleItemOnOrYesBase64() { // public static String getToggleItemOnOrYesBase64Value() {
return toggleItemOnOrYesBase64; // return toggleItemOnOrYesBase64Value;
} // }
//
public static String getToggleItemOnOrYesBase64Value() { // public static String getToggleItemOnOrYesMaterial() {
return toggleItemOnOrYesBase64Value; // return toggleItemOnOrYesMaterial;
} // }
//
public static String getToggleItemOnOrYesMaterial() { // public static Boolean getToggleItemOffOrNoBase64() {
return toggleItemOnOrYesMaterial; // return toggleItemOffOrNoBase64;
} // }
//
public static Boolean getToggleItemOffOrNoBase64() { // public static String getToggleItemOffOrNoBase64Value() {
return toggleItemOffOrNoBase64; // return toggleItemOffOrNoBase64Value;
} // }
//
public static String getToggleItemOffOrNoBase64Value() { // public static String getToggleItemOffOrNoMaterial() {
return toggleItemOffOrNoBase64Value; // return toggleItemOffOrNoMaterial;
} // }
//
public static String getToggleItemOffOrNoMaterial() { // public static String getTogglePermTrue() {
return toggleItemOffOrNoMaterial; // return togglePermTrue;
} // }
//
public static String getTogglePermTrue() { // public static String getTogglePermFalse() {
return togglePermTrue; // return togglePermFalse;
} // }
//
public static String getTogglePermFalse() { // public static String getPlaceholderTrue() {
return togglePermFalse; // return placeholderTrue;
} // }
//
public static String getPlaceholderTrue() { // public static String getPlaceholderFalse() {
return placeholderTrue; // return placeholderFalse;
} // }
//
public static String getPlaceholderFalse() { // public static Boolean getSound_Enable() {
return placeholderFalse; // return Sound_Enable;
} // }
//
public static Boolean getSound_Enable() { // public static Boolean getSound_OpenInventory_Enable() {
return Sound_Enable; // return Sound_OpenInventory_Enable;
} // }
//
public static Boolean getSound_OpenInventory_Enable() { // public static Sound getSound_OpenInventory() {
return Sound_OpenInventory_Enable; // return Sound_OpenInventory;
} // }
//
public static Sound getSound_OpenInventory() { // public static String getSound_OpenInventory_input() {
return Sound_OpenInventory; // return Sound_OpenInventory_input;
} // }
//
public static String getSound_OpenInventory_input() { // public static Boolean getSound_Click_Enable() {
return Sound_OpenInventory_input; // return Sound_Click_Enable;
} // }
//
public static Boolean getSound_Click_Enable() { // public static Sound getSound_Click() {
return Sound_Click_Enable; // return Sound_Click;
} // }
//
public static Sound getSound_Click() { // public static String getSound_Click_input() {
return Sound_Click; // return Sound_Click_input;
} // }
//
public static String getSound_Click_input() { // public static Boolean getSound_NoMoney_Enable() {
return Sound_Click_input; // return Sound_NoMoney_Enable;
} // }
//
public static Boolean getSound_NoMoney_Enable() { // public static Sound getSound_NoMoney() {
return Sound_NoMoney_Enable; // return Sound_NoMoney;
} // }
//
public static Sound getSound_NoMoney() { // public static String getSound_NoMoney_input() {
return Sound_NoMoney; // return Sound_NoMoney_input;
} // }
//
public static String getSound_NoMoney_input() { // public static Boolean getSound_NoInventorySpace_Enable() {
return Sound_NoMoney_input; // return Sound_NoInventorySpace_Enable;
} // }
//
public static Boolean getSound_NoInventorySpace_Enable() { // public static Sound getSound_NoInventorySpace() {
return Sound_NoInventorySpace_Enable; // return Sound_NoInventorySpace;
} // }
//
public static Sound getSound_NoInventorySpace() { // public static String getSound_NoInventorySpace_input() {
return Sound_NoInventorySpace; // return Sound_NoInventorySpace_input;
} // }
//
public static String getSound_NoInventorySpace_input() { // public static Boolean getSound_Give_Enable() {
return Sound_NoInventorySpace_input; // return Sound_Give_Enable;
} // }
//
public static Boolean getSound_Give_Enable() { // public static Sound getSound_Give() {
return Sound_Give_Enable; // return Sound_Give;
} // }
//
public static Sound getSound_Give() { // public static String getSound_Give_input() {
return Sound_Give; // return Sound_Give_input;
} // }
//
public static String getSound_Give_input() { // public static Boolean getSound_PlayerNotFound_Enable() {
return Sound_Give_input; // return Sound_PlayerNotFound_Enable;
} // }
//
public static Boolean getSound_PlayerNotFound_Enable() { // public static Sound getSound_PlayerNotFound() {
return Sound_PlayerNotFound_Enable; // return Sound_PlayerNotFound;
} // }
//
public static Sound getSound_PlayerNotFound() { // public static String getSound_PlayerNotFound_input() {
return Sound_PlayerNotFound; // return Sound_PlayerNotFound_input;
} // }
public static String getSound_PlayerNotFound_input() {
return Sound_PlayerNotFound_input;
}
} }

View File

@ -1,6 +1,7 @@
package net.t2code.commandguiv2.Spigot.config.configConverter; package net.t2code.commandguiv2.Spigot.config.configConverter;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import net.t2code.commandguiv2.Spigot.config.functions.CreateFunctions; import net.t2code.commandguiv2.Spigot.config.functions.CreateFunctions;
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum; import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum; import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
@ -15,7 +16,7 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class ConfigConverterUnderV5 { public class ConfigConverterV5 {
public static void renameMainFolder() { public static void renameMainFolder() {
if (new File("plugins/CommandGUI").exists() && !Main.getPath().exists()) { if (new File("plugins/CommandGUI").exists() && !Main.getPath().exists()) {
File oldF = new File("plugins/CommandGUI"); File oldF = new File("plugins/CommandGUI");
@ -77,6 +78,8 @@ public class ConfigConverterUnderV5 {
File config = new File(Main.getPath(), "GUIs/" + configOld.getName().replace(".yml", "") + ".yml"); File config = new File(Main.getPath(), "GUIs/" + configOld.getName().replace(".yml", "") + ".yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
yamlConfiguration.set(ConfigValues.configVersion.path, 5);
Boolean enable = yamlConfigurationOld.getBoolean("GUI.Enable"); Boolean enable = yamlConfigurationOld.getBoolean("GUI.Enable");
Integer lines = yamlConfigurationOld.getInt("GUI.Lines"); Integer lines = yamlConfigurationOld.getInt("GUI.Lines");

View File

@ -0,0 +1,134 @@
package net.t2code.commandguiv2.Spigot.config.configConverter;
import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class ConfigConverterV6 {
public ConfigConverterV6() {
try {
convert();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private File configOld;
private YamlConfiguration yamlConfigurationOld;
private File defaultUseItem = new File(Main.getPath(), "UseItems/default.yml");
private YamlConfiguration yamlConfigurationUseItem = YamlConfiguration.loadConfiguration(defaultUseItem);
private void convert() throws IOException {
File oldF = new File("plugins/T2C-CommandGUI/config.yml");
File newF = new File("plugins/T2C-CommandGUI/configV5.yml");
oldF.renameTo(newF);
configOld = new File(Main.getPath(), "configV5.yml");
yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld);
set(ConfigValues.debug, "Plugin.Debug");
set(ConfigValues.updateCheckOnJoin, "Plugin.updateCheck.onJoin");
set(ConfigValues.updateCheckSeePreReleaseUpdates, "Plugin.updateCheck.seePreReleaseUpdates");
set(ConfigValues.updateCheckTimeInterval, "Plugin.updateCheck.timeInterval");
set(ConfigValues.helpAlias, "Plugin.HelpAlias");
set(ConfigValues.adminSubCommand, "Plugin.AdminSubCommand");
set(ConfigValues.language, "Plugin.language");
set(ConfigValues.currency, "Plugin.Currency");
set(ConfigValues.defaultGUI, "Plugin.DefaultGUI");
set(ConfigValues.storage, "Storage.Type");
set(ConfigValues.mysqlIp, "Storage.MySQL.IP");
set(ConfigValues.mysqlPort, "Storage.MySQL.Port");
set(ConfigValues.mysqlDatabase, "Storage.MySQL.Database");
set(ConfigValues.mysqlUser, "Storage.MySQL.User");
set(ConfigValues.mysqlPassword, "Storage.MySQL.Password");
set(ConfigValues.mysqlSSL, "Storage.MySQL.SSL");
set(ConfigValues.useItemEnable, "UseItem.Enable");
set(ConfigValues.useItemAllowToggle, "UseItem.AllowToggle");
set(ConfigValues.useItemAllowSetSlot, "UseItem.AllowSetSlot");
set(ConfigValues.useItemBlockMoveAndDrop, "UseItem.BlockMoveAndDrop");
set(ConfigValues.useItemOpenGUI, "UseItem.OpenGUI");
set(ConfigValues.useItemPermission, "UseItem.Permission.NeededToUse");
set(ConfigValues.useItemKeepAtCommandClear, "UseItem.KeepAtCommandClear");
set(ConfigValues.useItemInventorySlotFreeSlot, "UseItem.InventorySlot.FreeSlot");
set(ConfigValues.useItemInventorySlot, "UseItem.InventorySlot.Slot");
set(ConfigValues.useItemInventorySlotEnforce, "UseItem.InventorySlot.SlotEnforce");
set(ConfigValues.useItemMaterial, "UseItem.Item.Material");
set(ConfigValues.useItemPlayerHeadEnable, "UseItem.Item.PlayerHead.Enable");
set(ConfigValues.useItemBase64Enable, "UseItem.Item.PlayerHead.Base64.Enable");
set(ConfigValues.useItemBase64value, "UseItem.Item.PlayerHead.Base64.Base64Value");
set(ConfigValues.useItemPlayerWhoHasOpenedTheGUI, "UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI");
set(ConfigValues.useItemPlayerName, "UseItem.Item.PlayerHead.PlayerName");
set(ConfigValues.useItemName, "UseItem.Item.Name");
set(ConfigValues.useItemLore, "UseItem.Item.Lore");
set(ConfigValues.useItemGiveOnEveryJoin, "UseItem.Join.GiveOnEveryJoin");
set(ConfigValues.useItemGiveOnlyOnFirstJoin, "UseItem.Join.GiveOnlyOnFirstJoin");
set(ConfigValues.cursorToGUIItemOnLogin, "UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable");
set(ConfigValues.cursorToGUIItemOnlyOnFirstLogin, "UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin");
set(ConfigValues.useItemServerChange, "UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange");
set(ConfigValues.toggleItemOnOrYesBase64, "Toggle.Items.OnOrYes.Item.Base64.Enable");
set(ConfigValues.toggleItemOnOrYesBase64Value, "Toggle.Items.OnOrYes.Item.Base64.Base64Value");
set(ConfigValues.toggleItemOnOrYesMaterial, "Toggle.Items.OnOrYes.Item.Material");
set(ConfigValues.toggleItemOffOrNoBase64, "Toggle.Items.OffOrNo.Item.Base64.Enable");
set(ConfigValues.toggleItemOffOrNoBase64Value, "Toggle.Items.OffOrNo.Item.Base64.Base64Value");
set(ConfigValues.toggleItemOffOrNoMaterial, "Toggle.Items.OffOrNo.Item.Material");
set(ConfigValues.togglePermTrue, "Toggle.Permission.Commands.True");
set(ConfigValues.togglePermFalse, "Toggle.Permission.Commands.False");
set(ConfigValues.placeholderTrue, "Placeholder.True");
set(ConfigValues.placeholderFalse, "Placeholder.False");
set(ConfigValues.soundEnable, "Sound.Enable");
set(ConfigValues.soundOpenInventoryEnable, "Sound.OpenInventory.Enable");
set(ConfigValues.soundOpenInventoryInput, "Sound.OpenInventory.Sound");
set(ConfigValues.soundClickEnable, "Sound.Click.Enable");
set(ConfigValues.soundClickInput, "Sound.Click.Sound");
set(ConfigValues.soundNoMoneyEnable, "Sound.NoMoney.Enable");
set(ConfigValues.soundNoMoneyInput, "Sound.NoMoney.Sound");
set(ConfigValues.soundNoInventorySpaceEnable, "Sound.NoInventorySpace.Enable");
set(ConfigValues.soundNoInventorySpaceInput, "Sound.NoInventorySpace.Sound");
set(ConfigValues.soundGiveEnable, "Sound.Give.Enable");
set(ConfigValues.soundGiveInput, "Sound.Give.Sound");
set(ConfigValues.soundPlayerNotFoundEnable, "Sound.PlayerNotFound.Enable");
set(ConfigValues.soundPlayerNotFoundInput, "Sound.PlayerNotFound.Sound");
set(ConfigValues.useItemGameModeChangeEnable, "Advanced.UseItem.GameMode.Change.Enable");
set(ConfigValues.useItemGameModeChangeDelayInTicks, "Advanced.UseItem.GameMode.Change.DelayInTicks");
set(ConfigValues.useItemGameModeProtection, "Advanced.UseItem.GameMode.Protection.Enable");
set(ConfigValues.useItemGameModeRemoveItemWhenItIsDisabled, "Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled");
set(ConfigValues.useItemGameModeMode, "Advanced.UseItem.GameMode.Protection.Mode");
set(ConfigValues.useItemGameModeList, "Advanced.UseItem.GameMode.Protection.List");
set(ConfigValues.useItemWorldChangeEnable, "Advanced.UseItem.World.Change.Enable");
set(ConfigValues.useItemWorldChangeDelayInTicks, "Advanced.UseItem.World.Change.DelayInTicks");
set(ConfigValues.useItemWorldProtection, "Advanced.UseItem.World.Protection.Enable");
set(ConfigValues.useItemWorldRemoveItemWhenItIsDisabled, "Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled");
set(ConfigValues.useItemWorldMode, "Advanced.UseItem.World.Protection.Mode");
set(ConfigValues.useItemWorldList, "Advanced.UseItem.World.Protection.List");
set(ConfigValues.disableInfoBySneak, "Advanced.UseItem.DisableInfoBySneak");
set(ConfigValues.useItemItemBlockBlacklist, "Advanced.UseItem.ItemBlockBlacklist");
}
private void set(ConfigValues obj, String path) {
if (!yamlConfigurationOld.contains(path)) return;
obj.value = yamlConfigurationOld.get(path);
}
}

View File

@ -1,102 +1,22 @@
package net.t2code.commandguiv2.Spigot.objects; package net.t2code.commandguiv2.Spigot.config.functions;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI; import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5;
import net.t2code.commandguiv2.Spigot.objects.functions.Function;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui;
import net.t2code.commandguiv2.Spigot.objects.slots.Slot;
import net.t2code.commandguiv2.Spigot.enums.EcoEnum; import net.t2code.commandguiv2.Spigot.enums.EcoEnum;
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum; import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum; import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class Obj_Select { public class SelectFunctions {
public static void onSelect() {
onSelectFunction();
onSelectGui();
}
public static void onSelectGui() {
Main.guiHashMap.clear();
Main.allAliases.clear();
File f = new File(Main.getPath() + "/GUIs/");
File[] fileArray = f.listFiles();
for (File config : fileArray) {
try {
if (config.getName().equals("guiDeclaration.yml")) continue;
String sub = config.getName().substring(config.getName().length() - 4);
if (sub.equals(".yml")) {
String key = config.getName().replace(".yml", "");
Main.allAliases.add(key);
YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config);
Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable");
Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines");
if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) {
yamlConfiguration_gui.set("GUI.Lines", 6);
}
if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) {
yamlConfiguration_gui.set("GUI.Lines", 1);
}
String guiName = yamlConfiguration_gui.getString("GUI.Name");
Boolean guiFillItemEnable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable");
String guiFillItemItem;
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneColor");
} else guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.Item");
Boolean commandAliasEnable = yamlConfiguration_gui.getBoolean("Command.Alias");
Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
ArrayList<Slot> slots = new ArrayList<>();
for (String slotKey : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + slotKey + ".Slot") - 1;
Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Enable");
String function = yamlConfiguration_gui.getString("Slots." + slotKey + ".Function");
Function functionCheck = Main.functionHashMap.get(function);
if (functionCheck == null) {
T2Csend.error(Main.getPlugin(), "The Function " + function + " in the GUI " + key + " does not exist!");
}
Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Permission.Required");
String permSee = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.See");
String permUse = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.Use");
Slot slot = new Slot(slotNumber, enable, function, permRequired,
permSee.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
.replace("[slotname]", slotKey.toLowerCase()),
permUse.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
.replace("[slotname]", slotKey.toLowerCase()));
slots.add(slot);
}
Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem,
key, commandAliasEnable, commandPermission, slots);
Main.guiHashMap.put(key, gui);
CmdExecuter_GUI.arg1.put(config.getName()
.replace(".yml", ""), "commandgui.gui." + key);
yamlConfiguration_gui.save(config);
}
} catch (Exception e) {
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
e.printStackTrace();
}
}
}
public static void onSelectFunction() { public static void onSelectFunction() {
Main.functionHashMap.clear(); Cache.functionHashMap.clear();
File f = new File(Main.getPath() + "/Functions/"); File f = new File(Main.getPath() + "/Functions/");
File[] fileArray = f.listFiles(); File[] fileArray = f.listFiles();
@ -118,7 +38,7 @@ public class Obj_Select {
String name = yamlConfiguration.getString("Slots.Function.Item.Name"); String name = yamlConfiguration.getString("Slots.Function.Item.Name");
List<String> lore = yamlConfiguration.getStringList("Slots.Function.Item.Lore"); List<String> lore = yamlConfiguration.getStringList("Slots.Function.Item.Lore");
if (yamlConfiguration.get("Slots.Function.NoPermission") == null) { if (yamlConfiguration.get("Slots.Function.NoPermission") == null) {
ConfigConverterUnderV5.noPermLore(yamlConfiguration, config); ConfigConverterV5.noPermLore(yamlConfiguration, config);
} }
Boolean noPermMessageEnable = yamlConfiguration.getBoolean("Slots.Function.NoPermission.Message.Enable"); Boolean noPermMessageEnable = yamlConfiguration.getBoolean("Slots.Function.NoPermission.Message.Enable");
String customNoPermMessage = yamlConfiguration.getString("Slots.Function.NoPermission.Message.CustomNoPermMessage"); String customNoPermMessage = yamlConfiguration.getString("Slots.Function.NoPermission.Message.CustomNoPermMessage");
@ -200,7 +120,7 @@ public class Obj_Select {
} }
String functionItemItem = yamlConfiguration.getString("Slots.Function.FunctionItem.Item"); String functionItemItem = yamlConfiguration.getString("Slots.Function.FunctionItem.Item");
Function function = new Function(key, empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore, FunctionObject function = new FunctionObject(key, empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore,
noPermMessageEnable, customNoPermMessage, noPermLoreEnable, noPermLore, noPermMessageEnable, customNoPermMessage, noPermLoreEnable, noPermLore,
customSound_Enable, customSound_NoSound, customSound_Sound, cost_Enable, ecoModule, ecoItem, votePoints, price, command_Enable, command_BungeeCommand, customSound_Enable, customSound_NoSound, customSound_Sound, cost_Enable, ecoModule, ecoItem, votePoints, price, command_Enable, command_BungeeCommand,
commandAsConsole, command, serverChange, serverChangeServer, openGUI_Enable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, message_Enable, commandAsConsole, command, serverChange, serverChangeServer, openGUI_Enable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, message_Enable,
@ -208,7 +128,7 @@ public class Obj_Select {
configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight, configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight,
configListValueRight, pluginReloadEnable, pluginReloadCommand, functionVotePoints, functionVotePointsMode, functionVotePointsAmount, configListValueRight, pluginReloadEnable, pluginReloadCommand, functionVotePoints, functionVotePointsMode, functionVotePointsAmount,
functionItem, functionItemMode, functionItemItem); functionItem, functionItemMode, functionItemItem);
Main.functionHashMap.put(key, function); Cache.functionHashMap.put(key, function);
try { try {
yamlConfiguration.save(config); yamlConfiguration.save(config);
@ -218,4 +138,5 @@ public class Obj_Select {
} }
} }
} }
} }

View File

@ -0,0 +1,89 @@
package net.t2code.commandguiv2.Spigot.config.gui;
import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
import net.t2code.commandguiv2.Spigot.objects.SlotObject;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.ArrayList;
public class SelectGui {
public static void onSelectGui() {
Cache.guiHashMap.clear();
Cache.allAliases.clear();
File f = new File(Main.getPath() + "/GUIs/");
File[] fileArray = f.listFiles();
for (File config : fileArray) {
try {
if (config.getName().equals("guiDeclaration.yml")) continue;
String sub = config.getName().substring(config.getName().length() - 4);
if (sub.equals(".yml")) {
String key = config.getName().replace(".yml", "");
Cache.allAliases.add(key);
YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config);
Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable");
Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines");
if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) {
yamlConfiguration_gui.set("GUI.Lines", 6);
}
if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) {
yamlConfiguration_gui.set("GUI.Lines", 1);
}
String guiName = yamlConfiguration_gui.getString("GUI.Name");
Boolean guiFillItemEnable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable");
String guiFillItemItem;
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneColor");
} else guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.Item");
Boolean commandAliasEnable = yamlConfiguration_gui.getBoolean("Command.Alias");
Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
ArrayList<SlotObject> slots = new ArrayList<>();
for (String slotKey : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + slotKey + ".Slot") - 1;
Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Enable");
String function = yamlConfiguration_gui.getString("Slots." + slotKey + ".Function");
FunctionObject functionCheck = Cache.functionHashMap.get(function);
if (functionCheck == null) {
T2Csend.error(Main.getPlugin(), "The Function " + function + " in the GUI " + key + " does not exist!");
}
Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Permission.Required");
String permSee = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.See");
String permUse = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.Use");
SlotObject slot = new SlotObject(slotNumber, enable, function, permRequired,
permSee.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
.replace("[slotname]", slotKey.toLowerCase()),
permUse.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
.replace("[slotname]", slotKey.toLowerCase()));
slots.add(slot);
}
GuiObject gui = new GuiObject(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem,
key, commandAliasEnable, commandPermission, slots);
Cache.guiHashMap.put(key, gui);
CmdExecuter_GUI.arg1.put(config.getName()
.replace(".yml", ""), "commandgui.gui." + key);
yamlConfiguration_gui.save(config);
}
} catch (Exception e) {
Main.sendTryCatch(SelectGui.class, e.getStackTrace()[0]);
e.printStackTrace();
}
}
}
}

View File

@ -43,7 +43,7 @@ public class MSG {
public static String EN_UseItemDisabledInGameMode = "[prefix] &cThe UseItem is disabled in this GameMode!"; public static String EN_UseItemDisabledInGameMode = "[prefix] &cThe UseItem is disabled in this GameMode!";
public static String EN_UseItemDisabledInWorld = "[prefix] &cThe UseItem is disabled in this World!"; public static String EN_UseItemDisabledInWorld = "[prefix] &cThe UseItem is disabled in this World!";
public static String EN_GUInotFound = "[prefix] &cThe GUI chosen by the does not exist."; public static String EN_GUInotFound = "[prefix] &cThe gui [gui] does not exist!";
public static String EN_GUIisDisabled = "[prefix] &cThe GUI [gui] &cis currently Disabled!"; public static String EN_GUIisDisabled = "[prefix] &cThe GUI [gui] &cis currently Disabled!";
public static String EN_GiveSender = "[prefix] &2You have given &6[player] &2an [item] &2!"; public static String EN_GiveSender = "[prefix] &2You have given &6[player] &2an [item] &2!";
@ -113,7 +113,7 @@ public class MSG {
public static String DE_onServerChange = "[prefix] &2Du wirst auf den Server §e[server] §2verbunden."; public static String DE_onServerChange = "[prefix] &2Du wirst auf den Server §e[server] §2verbunden.";
public static String DE_GUInotFound = "[prefix] &cDie von die gew[ae]hlte GUI gibt es nicht."; public static String DE_GUInotFound = "[prefix] &cDie gui [gui] existiert nicht!";
public static String DE_GUIisDisabled = "[prefix] &cDie GUI [gui] &cist derzeit Deaktiviert!"; public static String DE_GUIisDisabled = "[prefix] &cDie GUI [gui] &cist derzeit Deaktiviert!";
public static String DE_GiveSender = "[prefix] &2Du hast &6[player] &2ein [item] &2gegeben!"; public static String DE_GiveSender = "[prefix] &2Du hast &6[player] &2ein [item] &2gegeben!";

View File

@ -1,7 +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.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
@ -87,17 +87,17 @@ public class SelectMessages {
File msg; File msg;
msg = new File(Main.getPath(), "languages/" + SelectConfig.getLanguage() + "_messages.yml"); msg = new File(Main.getPath(), "languages/" + ConfigValues.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" + ConfigValues.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(ConfigValues.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

@ -0,0 +1,113 @@
package net.t2code.commandguiv2.Spigot.config.useItems;
import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.objects.UseItemObject;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class UseItemSelect {
public static void create() {
File config = new File(Main.getPath(), "/UseItems/default.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (UseItemValues value : UseItemValues.values()) {
T2Cconfig.set(value.path, value.value, yamlConfiguration);
}
try {
yamlConfiguration.save(config);
} catch (
IOException e) {
e.printStackTrace();
}
}
public static void onSelect() {
Cache.useItemHash.clear();
File f = new File(Main.getPath() + "/UseItems/");
File[] fileArray = f.listFiles();
for (File config : fileArray) {
if (config.getName().equals("useItemDeclaration.yml")) continue;
String sub = config.getName().substring(config.getName().length() - 4);
if (sub.equals(".yml")) {
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
String key = config.getName().replace(".yml", "");
Boolean enable = yamlConfiguration.getBoolean("useItem.enable");
String openGui = yamlConfiguration.getString("useItem.openGUI");
Boolean allowToggle = yamlConfiguration.getBoolean("useItem.allowToggle");
Boolean allowSetBlock = yamlConfiguration.getBoolean("useItem.allowSetSlot");
Boolean blockMoveAndDrop = yamlConfiguration.getBoolean("useItem.blockMoveAndDrop");
Boolean permBecomeNeeded = yamlConfiguration.getBoolean("useItem.permission.become.needed");
String permBecome = yamlConfiguration.getString("useItem.permission.become.permission");
PermissionDefault permBecomeDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.become.default"));
Boolean permUseNeeded = yamlConfiguration.getBoolean("useItem.permission.use.needed");
String permUse = yamlConfiguration.getString("useItem.permission.use.permission");
PermissionDefault permUseDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.use.default"));
Boolean permToggleNeeded = yamlConfiguration.getBoolean("useItem.permission.toggle.needed");
String permToggle = yamlConfiguration.getString("useItem.permission.toggle.permission");
PermissionDefault permToggleDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.toggle.default"));
Boolean permSetSlotNeeded = yamlConfiguration.getBoolean("useItem.permission.setSlot.needed");
String permSetSlot = yamlConfiguration.getString("useItem.permission.setSlot.permission");
PermissionDefault permSetSlotDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.setSlot.default"));
Boolean keepAtCommandClear = yamlConfiguration.getBoolean("useItem.keepAtCommandClear");
Integer invSlotSlot = yamlConfiguration.getInt("useItem.inventorySlot.slot");
Boolean invSlotEnforce = yamlConfiguration.getBoolean("useItem.inventorySlot.slotEnforce");
Boolean invFreeSlot = yamlConfiguration.getBoolean("useItem.inventorySlot.freeSlot");
String itemMaterial = yamlConfiguration.getString("useItem.item.material");
String itemName = yamlConfiguration.getString("useItem.item.name");
List<String> itemLore = yamlConfiguration.getStringList("useItem.item.lore");
Boolean itemPlayerHeadEnable = yamlConfiguration.getBoolean("useItem.item.playerHead.enable");
Boolean itemPlayerHeadPlayerWhoHasOpenedTheGUI = yamlConfiguration.getBoolean("useItem.item.playerHead.playerWhoHasOpenedTheGUI");
String itemPlayerHeadPlayerName = yamlConfiguration.getString("useItem.item.playerHead.playerName");
Boolean itemPlayerHeadBase64Enable = yamlConfiguration.getBoolean("useItem.item.playerHead.base64.enable");
String itemPlayerHeadBase64Value = yamlConfiguration.getString("useItem.item.playerHead.base64.base64Value");
Boolean joinGiveOnEveryJoin = yamlConfiguration.getBoolean("useItem.join.giveOnEveryJoin");
Boolean joinGiveOnlyOnFirstJoin = yamlConfiguration.getBoolean("useItem.join.giveOnlyOnFirstJoin");
Boolean quitRemoveOnQuit = yamlConfiguration.getBoolean("useItem.quit.removeOnQuit");
Boolean protectGameModeEnable = yamlConfiguration.getBoolean("useItem.protection.gameMode.enable");
Boolean protectGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("useItem.protection.gameMode.removeItemWhenItIsDisabled");
String protectGameModeMode = yamlConfiguration.getString("useItem.protection.gameMode.mode");
List<String> protectGameModeList = yamlConfiguration.getStringList("useItem.protection.gameMode.list");
Boolean protectWorldEnable = yamlConfiguration.getBoolean("useItem.protection.world.enable");
Boolean protectWorldRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("useItem.protection.world.removeItemWhenItIsDisabled");
String protectWorldMode = yamlConfiguration.getString("useItem.protection.world.mode");
List<String> protectWorldList = yamlConfiguration.getStringList("useItem.protection.world.list");
UseItemObject useItem = new UseItemObject(key, enable, openGui, allowToggle, allowSetBlock, blockMoveAndDrop, permBecomeNeeded, permBecome, permBecomeDefault,
permUseNeeded, permUse, permUseDefault, permToggleNeeded, permToggle, permToggleDefault, permSetSlotNeeded, permSetSlot, permSetSlotDefault, keepAtCommandClear,
invSlotSlot, invSlotEnforce, invFreeSlot, itemMaterial, itemName, itemLore, itemPlayerHeadEnable, itemPlayerHeadPlayerWhoHasOpenedTheGUI,
itemPlayerHeadPlayerName, itemPlayerHeadBase64Enable, itemPlayerHeadBase64Value, joinGiveOnEveryJoin, joinGiveOnlyOnFirstJoin, quitRemoveOnQuit,
protectGameModeEnable, protectGameModeRemoveItemWhenItIsDisabled, protectGameModeMode, protectGameModeList, protectWorldEnable,
protectWorldRemoveItemWhenItIsDisabled, protectWorldMode, protectWorldList);
Cache.useItemHash.put(key, useItem);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -0,0 +1,69 @@
package net.t2code.commandguiv2.Spigot.config.useItems;
import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
import net.t2code.commandguiv2.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public enum UseItemValues {
enable("useItem.enable",true),
openGUI("useItem.openGUI","default"),
allowToggle("useItem.allowToggle",true),
allowSetSlot("useItem.allowSetSlot",true),
blockMoveAndDrop("useItem.blockMoveAndDrop",true),
permissionBecomeNeeded("useItem.permission.become.needed",true),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null),
xxxx("useItem.enable",null);
public final String path;
public Object value;
UseItemValues(String path, Object defaultValue) {
this.path = path;
this.value = defaultValue;
}
}

View File

@ -3,7 +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.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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 +24,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://" + ConfigValues.mysqlIp.value + ":" + ConfigValues.mysqlPort.value + "/" + ConfigValues.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=" + ConfigValues.mysqlSSL.value);
config.setUsername(SelectConfig.getMysqlUser()); config.setUsername(String.valueOf(ConfigValues.mysqlUser.value));
config.setPassword(SelectConfig.getMysqlPassword()); config.setPassword(String.valueOf(ConfigValues.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 +39,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) ConfigValues.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

@ -1,6 +1,6 @@
package net.t2code.commandguiv2.Spigot.database; package net.t2code.commandguiv2.Spigot.database;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.function.useItem.Events;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.enums.StorageEnum; import net.t2code.commandguiv2.Spigot.enums.StorageEnum;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -39,7 +39,7 @@ public class SelectDatabase {
} }
} }
public static void setSlot(Player player, Integer slot) { public static void setSlot(Player player, String useItemKey, Integer slot) {
switch (Storage) { switch (Storage) {
case MYSQL: case MYSQL:
try { try {
@ -61,7 +61,7 @@ public class SelectDatabase {
} }
} }
public static void setItemStatusTrue(Player player) { public static void setItemStatusFalse(Player player) {
Events.useItemHashMap.replace(player.getName(), true); Events.useItemHashMap.replace(player.getName(), true);
switch (Storage) { switch (Storage) {
case MYSQL: case MYSQL:
@ -74,7 +74,7 @@ public class SelectDatabase {
} }
break; break;
case YML: case YML:
YML.setGuiitemOn(player); YML.setGuiItem(player, true);
break; break;
case SQLITE: case SQLITE:
default: default:
@ -84,30 +84,34 @@ public class SelectDatabase {
} }
} }
public static void setItemStatusFalse(Player player) { public static void setItemStatus(Player player, String useItemKey, boolean status) {
int i;
if (status) {
i = 1;
} else i = 0;
Events.useItemHashMap.replace(player.getName(), false); Events.useItemHashMap.replace(player.getName(), false);
switch (Storage) { switch (Storage) {
case MYSQL: case MYSQL:
try { try {
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
+ "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';"); + "', '" + i + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '" + i + "';");
} catch (SQLException e) { } catch (SQLException e) {
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]); Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
e.printStackTrace(); e.printStackTrace();
} }
break; break;
case YML: case YML:
YML.setGuiitemOff(player); YML.setGuiItem(player, status);
break; break;
case SQLITE: case SQLITE:
default: default:
SQLITE.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName() SQLITE.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
+ "', '0') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Status` = '0';"); + "', '" + i + "') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Status` = '" + i + "';");
break; break;
} }
} }
public static Boolean selectItemStatus(Player player) { public static Boolean selectItemStatus(Player player,String useItemKey) {
switch (Storage) { switch (Storage) {
case MYSQL: case MYSQL:
String result = MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); String result = MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
@ -127,7 +131,7 @@ public class SelectDatabase {
} }
} }
public static Integer selectSlot(Player player) { public static Integer selectSlot(Player player,String useItemKey) {
switch (Storage) { switch (Storage) {
case MYSQL: case MYSQL:
String result = MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';"); String result = MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");

View File

@ -1,7 +1,6 @@
package net.t2code.commandguiv2.Spigot.database; package net.t2code.commandguiv2.Spigot.database;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.objects.Obj_Select;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -17,20 +16,9 @@ public class YML {
public static File storage = new File(Main.getPath(), "Storage/gui-item.yml"); public static File storage = new File(Main.getPath(), "Storage/gui-item.yml");
public static YamlConfiguration yamlConfigurationStorage = YamlConfiguration.loadConfiguration(storage); public static YamlConfiguration yamlConfigurationStorage = YamlConfiguration.loadConfiguration(storage);
public static void setGuiitemOn(Player player) { public static void setGuiItem(Player player, boolean status) {
yamlConfigurationStorage.set(player.getUniqueId() + ".Playername", player.getName()); yamlConfigurationStorage.set(player.getUniqueId() + ".Playername", player.getName());
yamlConfigurationStorage.set(player.getUniqueId() + ".Status", true); yamlConfigurationStorage.set(player.getUniqueId() + ".Status", status);
try {
yamlConfigurationStorage.save(storage);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void setGuiitemOff(Player player) {
yamlConfigurationStorage.set(player.getUniqueId() + ".Playername", player.getName());
yamlConfigurationStorage.set(player.getUniqueId() + ".Status", false);
try { try {
yamlConfigurationStorage.save(storage); yamlConfigurationStorage.save(storage);
@ -46,12 +34,12 @@ public class YML {
try { try {
yamlConfigurationStorage.save(storage); yamlConfigurationStorage.save(storage);
} catch (IOException e) { } catch (IOException e) {
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]); Main.sendTryCatch(YML.class, e.getStackTrace()[0]);
e.printStackTrace(); e.printStackTrace();
} }
} }
public static Boolean selectGuiitemOn(Player player){ public static Boolean selectGuiitemOn(Player player) {
if (!yamlConfigurationStorage.contains(String.valueOf(player.getUniqueId()))) return true; if (!yamlConfigurationStorage.contains(String.valueOf(player.getUniqueId()))) return true;
return yamlConfigurationStorage.getBoolean(player.getUniqueId() + ".Status"); return yamlConfigurationStorage.getBoolean(player.getUniqueId() + ".Status");
} }

View File

@ -1,23 +1,25 @@
package net.t2code.commandguiv2.Spigot.gui; package net.t2code.commandguiv2.Spigot.function.gui;
import net.t2code.commandguiv2.Spigot.listener.ServerChange; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.function.listener.ServerChange;
import net.t2code.commandguiv2.Spigot.objects.functions.Function; import net.t2code.commandguiv2.Spigot.function.useItem.Events;
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
import net.t2code.commandguiv2.Spigot.cmdManagement.Commands; import net.t2code.commandguiv2.Spigot.cmdManagement.Commands;
import net.t2code.commandguiv2.Spigot.objects.slots.Slot; import net.t2code.commandguiv2.Spigot.objects.SlotObject;
import net.t2code.commandguiv2.Spigot.listener.Bungee_Sender_Reciver; import net.t2code.commandguiv2.Spigot.function.listener.Bungee_Sender_Reciver;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui; import net.t2code.commandguiv2.Spigot.objects.GuiObject;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.system.Placeholder; import net.t2code.commandguiv2.Spigot.system.Placeholder;
import net.t2code.commandguiv2.Spigot.sound.Sound; import net.t2code.commandguiv2.Spigot.sound.PlaySound;
import net.t2code.commandguiv2.Spigot.enums.SoundEnum; import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.eco.T2Ceco; 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;
@ -44,23 +46,23 @@ public class GUIListener implements Listener {
Player player = (Player) e.getWhoClicked(); Player player = (Player) e.getWhoClicked();
if (e.getInventory() == null) return; if (e.getInventory() == null) return;
if (e.getCurrentItem() == null) return; if (e.getCurrentItem() == null) return;
for (Gui gui : Main.guiHashMap.values()) { for (GuiObject gui : Cache.guiHashMap.values()) {
if (player.getOpenInventory().getTitle().equals(T2Creplace.replace(prefix, GUICode + gui.guiName)) if (player.getOpenInventory().getTitle().equals(T2Creplace.replace(prefix, GUICode + gui.guiName))
|| (Main.PaPi && player.getOpenInventory().getTitle().equals(T2Creplace.replace(prefix, player, GUICode + gui.guiName)))) { || (Main.PaPi && player.getOpenInventory().getTitle().equals(T2Creplace.replace(prefix, player, GUICode + gui.guiName)))) {
e.setCancelled(true); e.setCancelled(true);
if (player.getOpenInventory().getTopInventory() != e.getClickedInventory()) { if (player.getOpenInventory().getTopInventory() != e.getClickedInventory()) {
continue; continue;
} }
for (Slot slot : gui.slots) { for (SlotObject slot : gui.slots) {
execute(e, slot, player, gui); execute(e, slot, player, gui);
} }
} }
} }
} }
private static void execute(InventoryClickEvent e, Slot slot, Player player, Gui gui) { private static void execute(InventoryClickEvent e, SlotObject slot, Player player, GuiObject gui) {
if (e.getSlot() != slot.slot) return; if (e.getSlot() != slot.slot) return;
Function function = Main.functionHashMap.get(slot.function); FunctionObject function = Cache.functionHashMap.get(slot.function);
if (slot.permission && !player.hasPermission(slot.permissionToSee)) return; if (slot.permission && !player.hasPermission(slot.permissionToSee)) return;
if (slot.permission && !player.hasPermission(slot.permissionToUse)) { if (slot.permission && !player.hasPermission(slot.permissionToUse)) {
if (function.noPermMessageEnable) { if (function.noPermMessageEnable) {
@ -87,7 +89,7 @@ public class GUIListener implements Listener {
} }
} }
private static boolean functions(Function function) { private static boolean functions(FunctionObject function) {
if (function.togglePermission) return true; if (function.togglePermission) return true;
if (function.toggleUseItem) return true; if (function.toggleUseItem) return true;
if (function.command_Enable) return true; if (function.command_Enable) return true;
@ -99,7 +101,7 @@ public class GUIListener implements Listener {
return function.functionItem; return function.functionItem;
} }
private static void execute(Function function, Slot slot, Player player, InventoryClickEvent e, Gui gui) { private static void execute(FunctionObject function, SlotObject slot, Player player, InventoryClickEvent e, GuiObject gui) {
if (function.togglePermission) togglePerm(function, gui, player); if (function.togglePermission) togglePerm(function, gui, player);
if (function.toggleUseItem) toggleUseItem(player, gui); if (function.toggleUseItem) toggleUseItem(player, gui);
if (function.command_Enable) command(function, player); if (function.command_Enable) command(function, player);
@ -109,16 +111,16 @@ public class GUIListener implements Listener {
if (function.setConfigEnable) setConfig(function, player, e); if (function.setConfigEnable) setConfig(function, player, e);
if (function.functionVotePoints) votePoints(e, function, player); if (function.functionVotePoints) votePoints(e, function, player);
if (function.functionItem) item(function, player); if (function.functionItem) item(function, player);
Sound.play(player, SoundEnum.Click, function, slot, gui); PlaySound.play(player, SoundEnum.Click, function, slot, gui);
} }
private static void command(Function slot, Player player) { private static void command(FunctionObject slot, Player player) {
player.closeInventory(); player.closeInventory();
new BukkitRunnable() { new BukkitRunnable() {
@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);
} }
@ -137,7 +139,7 @@ public class GUIListener implements Listener {
}.runTaskLater(plugin, 2L); }.runTaskLater(plugin, 2L);
} }
private static void openGUI(Function slot, Player player) { private static void openGUI(FunctionObject slot, Player player) {
player.closeInventory(); player.closeInventory();
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
@ -147,22 +149,22 @@ public class GUIListener implements Listener {
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
} }
private static void message(Function slot, Player player) { private static void message(FunctionObject slot, Player player) {
player.closeInventory(); player.closeInventory();
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 + " " + ConfigValues.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 + " " + ConfigValues.currency.value));
} else T2Csend.player(player, T2Creplace.replace(prefix, Placeholder.replace(msg, player))); } else T2Csend.player(player, T2Creplace.replace(prefix, Placeholder.replace(msg, player)));
} }
} }
} }
private static void serverChange(Function slot, Player player) { private static void serverChange(FunctionObject slot, Player player) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -178,7 +180,7 @@ public class GUIListener implements Listener {
}.runTaskLater(Main.getPlugin(), 20L); }.runTaskLater(Main.getPlugin(), 20L);
} }
private static void setConfig(Function slot, Player player, InventoryClickEvent e) { private static void setConfig(FunctionObject slot, Player player, InventoryClickEvent e) {
File config = new File(slot.configFilePath); File config = new File(slot.configFilePath);
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
@ -244,9 +246,9 @@ public class GUIListener implements Listener {
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
} }
private static void togglePerm(Function function, Gui gui, Player player) { private static void togglePerm(FunctionObject function, GuiObject 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(ConfigValues.togglePermFalse.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -255,7 +257,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(ConfigValues.togglePermTrue.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -265,7 +267,7 @@ public class GUIListener implements Listener {
}.runTaskLater(plugin, 4L); }.runTaskLater(plugin, 4L);
} }
private static void toggleUseItem(Player player, Gui gui) { private static void toggleUseItem(Player player, GuiObject gui) {
if (Events.useItemHashMap.get(player.getName())) { if (Events.useItemHashMap.get(player.getName())) {
Commands.itemOff(player); Commands.itemOff(player);
} else { } else {
@ -280,7 +282,7 @@ public class GUIListener implements Listener {
}.runTaskLater(plugin, 2L); }.runTaskLater(plugin, 2L);
} }
private static void votePoints(InventoryClickEvent e, Function function, Player player) { private static void votePoints(InventoryClickEvent e, FunctionObject function, Player player) {
player.closeInventory(); player.closeInventory();
switch (function.functionVotePointsMode) { switch (function.functionVotePointsMode) {
case ADD: case ADD:
@ -295,7 +297,7 @@ public class GUIListener implements Listener {
} }
} }
private static void item(Function function, Player player) { private static void item(FunctionObject function, Player player) {
String[] item = function.functionItemItem.split(";"); String[] item = function.functionItemItem.split(";");
player.closeInventory(); player.closeInventory();
switch (function.functionItemMode) { switch (function.functionItemMode) {
@ -312,7 +314,7 @@ public class GUIListener implements Listener {
} }
} }
private static void eco(InventoryClickEvent e, Slot slot, Player player, Gui gui, Function function) { private static void eco(InventoryClickEvent e, SlotObject slot, Player player, GuiObject gui, FunctionObject function) {
switch (function.ecoModule) { switch (function.ecoModule) {
case ITEM: case ITEM:
String[] item = function.ecoItem.split(";"); String[] item = function.ecoItem.split(";");
@ -324,7 +326,7 @@ public class GUIListener implements Listener {
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
T2Csend.player(player, SelectMessages.noMoneyItem.replace("[item]", item[0]).replace("[amount]", item[1])); T2Csend.player(player, SelectMessages.noMoneyItem.replace("[item]", item[0]).replace("[amount]", item[1]));
Sound.play(player, SoundEnum.NoMoney); PlaySound.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]", item[1] + " " + item[0])); .replace("[price]", item[1] + " " + item[0]));
@ -340,7 +342,7 @@ public class GUIListener implements Listener {
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
T2Csend.player(player, SelectMessages.noMoneyVote.replace("[amount]", function.votePoints.toString())); T2Csend.player(player, SelectMessages.noMoneyVote.replace("[amount]", function.votePoints.toString()));
Sound.play(player, SoundEnum.NoMoney); PlaySound.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.votePoints + " VotePoints")); .replace("[price]", function.votePoints + " VotePoints"));
@ -357,10 +359,10 @@ public class GUIListener implements Listener {
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(plugin, 1L);
T2Csend.player(player, T2Creplace.replacePrice(prefix, SelectMessages.noMoney, String.valueOf(function.price))); T2Csend.player(player, T2Creplace.replacePrice(prefix, SelectMessages.noMoney, String.valueOf(function.price)));
Sound.play(player, SoundEnum.NoMoney); PlaySound.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 + " " + ConfigValues.currency.value));
execute(function, slot, player, e, gui); execute(function, slot, player, e, gui);
} }
break; break;

View File

@ -1,14 +1,15 @@
package net.t2code.commandguiv2.Spigot.gui; package net.t2code.commandguiv2.Spigot.function.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.objects.guis.Gui; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import net.t2code.commandguiv2.Spigot.objects.functions.Function; import net.t2code.commandguiv2.Spigot.objects.GuiObject;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig; import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
import net.t2code.commandguiv2.Spigot.objects.slots.Slot; import net.t2code.commandguiv2.Spigot.objects.SlotObject;
import net.t2code.commandguiv2.Spigot.system.Placeholder; import net.t2code.commandguiv2.Spigot.system.Placeholder;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
import net.t2code.commandguiv2.cache.Cache;
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.minecraftVersion.T2CmcVersion; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
@ -26,8 +27,8 @@ public class GuiBuilder {
private static String prefix = Util.getPrefix(); private static String prefix = Util.getPrefix();
protected static void item(Slot slot, Player player, Inventory inventory) { protected static void item(SlotObject slot, Player player, Inventory inventory) {
Function function = Main.functionHashMap.get(slot.function); FunctionObject function = Cache.functionHashMap.get(slot.function);
ItemStack item; ItemStack item;
if (Main.legacy && function.item.toUpperCase().contains(",")) { if (Main.legacy && function.item.toUpperCase().contains(",")) {
String[] split = function.item.toUpperCase().split(","); String[] split = function.item.toUpperCase().split(",");
@ -44,8 +45,8 @@ public class GuiBuilder {
inventory.setItem(slot.slot, item); inventory.setItem(slot.slot, item);
} }
protected static void item(String material, Slot slot, Player player, Inventory inventory) { protected static void item(String material, SlotObject slot, Player player, Inventory inventory) {
Function function = Main.functionHashMap.get(slot.function); FunctionObject function = Cache.functionHashMap.get(slot.function);
ItemStack item; ItemStack item;
if (Main.legacy && material.contains(",")) { if (Main.legacy && material.contains(",")) {
String[] split = material.split(","); String[] split = material.split(",");
@ -63,23 +64,23 @@ public class GuiBuilder {
} }
private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Slot slot) { private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, SlotObject slot) {
Function function = Main.functionHashMap.get(slot.function); FunctionObject function = Cache.functionHashMap.get(slot.function);
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 + " " + ConfigValues.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 + " " + ConfigValues.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 + " " + ConfigValues.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 + " " + ConfigValues.currency.value));
} }
} }
protected static void base64(String base64Value, Slot slot, Player player, Inventory inventory) { protected static void base64(String base64Value, SlotObject slot, Player player, Inventory inventory) {
Function function = Main.functionHashMap.get(slot.function); FunctionObject function = Cache.functionHashMap.get(slot.function);
ItemStack item = T2CitemVersion.getHeadIS(); ItemStack item = T2CitemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setBase64(itemMeta, base64Value); setBase64(itemMeta, base64Value);
@ -106,13 +107,13 @@ public class GuiBuilder {
} }
} }
protected static void base64(Slot slot, Player player, Inventory inventory) { protected static void base64(SlotObject slot, Player player, Inventory inventory) {
Function function = Main.functionHashMap.get(slot.function); FunctionObject function = Cache.functionHashMap.get(slot.function);
base64(function.base64Value, slot, player, inventory); base64(function.base64Value, slot, player, inventory);
} }
protected static void playerHead(Slot slot, Player player, Inventory inventory, String skullName) { protected static void playerHead(SlotObject slot, Player player, Inventory inventory, String skullName) {
Function function = Main.functionHashMap.get(slot.function); FunctionObject function = Cache.functionHashMap.get(slot.function);
ItemStack item = T2CitemVersion.getHeadIS(); ItemStack item = T2CitemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta(); SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setDisplayNameAndLore(itemMeta, player, slot); setDisplayNameAndLore(itemMeta, player, slot);
@ -126,7 +127,7 @@ public class GuiBuilder {
inventory.setItem(slot.slot, item); inventory.setItem(slot.slot, item);
} }
public static void fillItem(Inventory inventory, Gui gui) { public static void fillItem(Inventory inventory, GuiObject gui) {
ItemStack glass; ItemStack glass;
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()) {
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.parseShort(gui.guiFillItemItem)); glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.parseShort(gui.guiFillItemItem));

View File

@ -1,17 +1,18 @@
package net.t2code.commandguiv2.Spigot.gui; package net.t2code.commandguiv2.Spigot.function.gui;
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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.function.useItem.Events;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.objects.functions.Function; import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui; import net.t2code.commandguiv2.Spigot.objects.GuiObject;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig; import net.t2code.commandguiv2.Spigot.objects.SlotObject;
import net.t2code.commandguiv2.Spigot.objects.slots.Slot; import net.t2code.commandguiv2.Spigot.sound.PlaySound;
import net.t2code.commandguiv2.Spigot.sound.Sound;
import net.t2code.commandguiv2.Spigot.enums.SoundEnum; import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
import net.t2code.commandguiv2.Util; import net.t2code.commandguiv2.Util;
import io.github.solyze.plugmangui.inventories.PluginListGUI; import io.github.solyze.plugmangui.inventories.PluginListGUI;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.luckyBox.api.LuckyBoxAPI; import net.t2code.luckyBox.api.LuckyBoxAPI;
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;
@ -29,7 +30,7 @@ public class OpenGUI {
private static String prefix = Util.getPrefix(); private static String prefix = Util.getPrefix();
public static void openGUI(Player player, String guiString, Boolean sound) { public static void openGUI(Player player, String guiString, Boolean sound) {
Gui gui = Main.guiHashMap.get(guiString); GuiObject gui = Cache.guiHashMap.get(guiString);
Long long_ = Long.valueOf(System.currentTimeMillis()); Long long_ = Long.valueOf(System.currentTimeMillis());
switch (guiString) { switch (guiString) {
//case "plugin.PlotSquaredGUI": //case "plugin.PlotSquaredGUI":
@ -76,9 +77,9 @@ public class OpenGUI {
if (gui.guiFillItemEnable) { if (gui.guiFillItemEnable) {
GuiBuilder.fillItem(inventory, gui); GuiBuilder.fillItem(inventory, gui);
} }
for (Slot slot : gui.slots) { for (SlotObject slot : gui.slots) {
try { try {
Function function = Main.functionHashMap.get(slot.function); FunctionObject function = Cache.functionHashMap.get(slot.function);
if (function == null) { if (function == null) {
T2Csend.error(Main.getPlugin(), "The Function " + slot.function + " in the GUI " + gui.key + " does not exist!"); T2Csend.error(Main.getPlugin(), "The Function " + slot.function + " in the GUI " + gui.key + " does not exist!");
continue; continue;
@ -128,22 +129,22 @@ public class OpenGUI {
} }
if (sound) { if (sound) {
Sound.play(player, SoundEnum.OpenInventory); PlaySound.play(player, SoundEnum.OpenInventory);
} }
player.openInventory(inventory); player.openInventory(inventory);
T2Csend.debug(plugin, "§6" + player.getName() + " §5Open §6" + T2Creplace.replace(prefix, gui.guiName) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); T2Csend.debug(plugin, "§6" + player.getName() + " §5Open §6" + T2Creplace.replace(prefix, gui.guiName) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
} else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", T2Creplace.replace(prefix, gui.guiName))); } else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", T2Creplace.replace(prefix, gui.guiName)));
} }
private static void toggleOn(Function function, Slot slot, Player player, Inventory inventory) { private static void toggleOn(FunctionObject function, SlotObject slot, Player player, Inventory inventory) {
if (SelectConfig.getToggleItemOnOrYesBase64()) { if ((Boolean) ConfigValues.toggleItemOnOrYesBase64.value) {
GuiBuilder.base64(SelectConfig.getToggleItemOnOrYesBase64Value(), slot, player, inventory); GuiBuilder.base64(String.valueOf( ConfigValues.toggleItemOnOrYesBase64Value.value), slot, player, inventory);
} else GuiBuilder.item(SelectConfig.getToggleItemOnOrYesMaterial(), slot, player, inventory); } else GuiBuilder.item(String.valueOf(ConfigValues.toggleItemOnOrYesMaterial.value), slot, player, inventory);
} }
private static void toggleOff(Function function, Slot slot, Player player, Inventory inventory) { private static void toggleOff(FunctionObject function, SlotObject slot, Player player, Inventory inventory) {
if (SelectConfig.getToggleItemOffOrNoBase64()) { if ((Boolean) ConfigValues.toggleItemOffOrNoBase64.value) {
GuiBuilder.base64(SelectConfig.getToggleItemOffOrNoBase64Value(), slot, player, inventory); GuiBuilder.base64(String.valueOf( ConfigValues.toggleItemOffOrNoBase64Value.value), slot, player, inventory);
} else GuiBuilder.item(SelectConfig.getToggleItemOffOrNoMaterial(), slot, player, inventory); } else GuiBuilder.item(String.valueOf(ConfigValues.toggleItemOffOrNoMaterial.value), slot, player, inventory);
} }
} }

View File

@ -1,4 +1,4 @@
package net.t2code.commandguiv2.Spigot.listener; package net.t2code.commandguiv2.Spigot.function.listener;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;

View File

@ -1,6 +1,6 @@
// This claas was created by JaTiTV // This claas was created by JaTiTV
package net.t2code.commandguiv2.Spigot.listener; package net.t2code.commandguiv2.Spigot.function.listener;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.database.SelectDatabase; import net.t2code.commandguiv2.Spigot.database.SelectDatabase;

View File

@ -1,4 +1,4 @@
package net.t2code.commandguiv2.Spigot.listener; package net.t2code.commandguiv2.Spigot.function.listener;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,10 +1,10 @@
package net.t2code.commandguiv2.Spigot.useItem; package net.t2code.commandguiv2.Spigot.function.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.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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.function.gui.OpenGUI;
import net.t2code.commandguiv2.Spigot.database.SelectDatabase; import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
import net.t2code.commandguiv2.api.CGuiAPI; import net.t2code.commandguiv2.api.CGuiAPI;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
@ -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) ConfigValues.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(ConfigValues.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) ConfigValues.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) ConfigValues.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) ConfigValues.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) ConfigValues.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) ConfigValues.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>) ConfigValues.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) ConfigValues.useItemEnable.value) {
if (SelectConfig.getUseItem_PlayerHead_Enable()) { if ((Boolean) ConfigValues.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(ConfigValues.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(ConfigValues.useItemMaterial.value))) {
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { if (e.getItem().getItemMeta().getDisplayName().equals(ConfigValues.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) ConfigValues.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) ConfigValues.useItemGameModeProtection.value) {
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) { if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.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(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.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) ConfigValues.useItemWorldProtection.value) {
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) { if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.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(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.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) ConfigValues.useItemPermission.value || player.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(player, SelectConfig.getUseItem_OpenGUI(), true); OpenGUI.openGUI(player, String.valueOf(ConfigValues.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(ConfigValues.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) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.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(ConfigValues.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) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.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(ConfigValues.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(ConfigValues.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) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.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(ConfigValues.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(ConfigValues.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) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.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(ConfigValues.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) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.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(ConfigValues.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) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.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(ConfigValues.useItemName.value)) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -300,18 +299,18 @@ public class Events implements Listener {
@EventHandler @EventHandler
public void onClearServer(ServerCommandEvent event) { public void onClearServer(ServerCommandEvent event) {
if (SelectConfig.getUseItem_KeepAtCommandClear()) { if ((Boolean) ConfigValues.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
public void run() { public void run() {
try { try {
Player player = Bukkit.getPlayer(event.getCommand().replace("/", "").replace("clear ", "")); Player player = Bukkit.getPlayer(event.getCommand().replace("/", "").replace("clear ", ""));
if (player == null){ if (player == null) {
return; return;
} }
clearGive(player); clearGive(player);
} catch (Exception ex){ } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
return; return;
} }
@ -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) ConfigValues.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.function.useItem;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.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(ConfigValues.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(ConfigValues.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) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.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(ConfigValues.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(ConfigValues.useItemName.value)) {
p.closeInventory(); p.closeInventory();
e.setCancelled(true); e.setCancelled(true);
} }

View File

@ -1,29 +1,33 @@
package net.t2code.commandguiv2.Spigot.useItem; package net.t2code.commandguiv2.Spigot.function.useItem;
import net.t2code.commandguiv2.Spigot.Main; import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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.entity.Player; import org.bukkit.entity.Player;
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) {
T2Csend.debug(Main.getPlugin(), "Join: " + player.getName());
Integer slot; Integer slot;
if (SelectConfig.getUseItem_InventorySlotEnforce()) { if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value) {
slot = SelectConfig.getUseItem_InventorySlot(); slot = (Integer) ConfigValues.useItemInventorySlot.value;
} else { } else {
slot = Events.useItemSlotHashMap.get(player.getName()); slot = Events.useItemSlotHashMap.get(player.getName());
} }
T2Csend.debug(Main.getPlugin(), "Slot " + slot + " for player: " + player.getName());
if (!SelectConfig.getUseItem_Enable()) { if (!(Boolean) ConfigValues.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) ConfigValues.useItemGiveOnlyOnFirstJoin.value) {
if (!SelectConfig.getUseItem_AllowToggle() || Events.useItemHashMap.get(player.getName())) { T2Csend.debug(Main.getPlugin(), "OnlyOnFirstJoin: " + player.getName());
if (!(Boolean) ConfigValues.useItemAllowToggle.value || Events.useItemHashMap.get(player.getName())) {
if (!player.hasPlayedBefore()) { if (!player.hasPlayedBefore()) {
new BukkitRunnable() { Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() { //todo testen
@Override @Override
public void run() { public void run() {
UseItem.giveUseItem(player); UseItem.giveUseItem(player);
@ -31,8 +35,8 @@ public class ItemChange {
setCursor(player, slot); setCursor(player, slot);
} }
} }
}.runTaskLater(Main.getPlugin(), 1L * 1); },1L);
if (SelectConfig.getCursor_ToGUIItem_OnlyOnFirstLogin() || SelectConfig.getCursor_ToGUIItem_OnLogin()) { if ((Boolean) ConfigValues.cursorToGUIItemOnlyOnFirstLogin.value || (Boolean) ConfigValues.cursorToGUIItemOnLogin.value) {
player.getInventory().setHeldItemSlot(slot - 1); player.getInventory().setHeldItemSlot(slot - 1);
} }
} }
@ -40,23 +44,24 @@ 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) ConfigValues.useItemGiveOnEveryJoin.value) {
T2Csend.debug(Main.getPlugin(), "!GiveOnEveryJoin: " + player.getName()); T2Csend.debug(Main.getPlugin(), "!GiveOnEveryJoin: " + player.getName());
return; return;
} }
new BukkitRunnable() {
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() { //todo testen
@Override @Override
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) ConfigValues.useItemAllowToggle.value || pln) {
if (SelectConfig.getUseItem_InventorySlotEnforce() || player.getInventory().getItem(slot - 1) == null) { if ((Boolean) ConfigValues.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) ConfigValues.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) {
@ -67,20 +72,20 @@ public class ItemChange {
if (empty) { if (empty) {
UseItem.addUseItem(player); UseItem.addUseItem(player);
} }
} } else T2Csend.debug(Main.getPlugin(), "give skip [1]: " + player.getName());
} } else T2Csend.debug(Main.getPlugin(), "give skip [2]: " + player.getName());
} }
}.runTaskLater(Main.getPlugin(), 1L * 1); }, 1L);
} }
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) ConfigValues.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) ConfigValues.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 +93,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) ConfigValues.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

@ -1,9 +1,9 @@
package net.t2code.commandguiv2.Spigot.useItem; package net.t2code.commandguiv2.Spigot.function.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.SelectConfig; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
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) ConfigValues.useItemInventorySlotEnforce.value) {
slot = SelectConfig.getUseItem_InventorySlot(); slot = (Integer) ConfigValues.useItemInventorySlot.value;
} else { } else {
slot = Events.useItemSlotHashMap.get(player.getName()); slot = Events.useItemSlotHashMap.get(player.getName());
} }
if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) { if ((Boolean) ConfigValues.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) ConfigValues.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) ConfigValues.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(ConfigValues.useItemName.value));
if (SelectConfig.getUseItem_Base64_Enable()) { if ((Boolean) ConfigValues.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>) ConfigValues.useItemLore.value));
} else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore())); } else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList<String>) ConfigValues.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(ConfigValues.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) ConfigValues.useItemPlayerWhoHasOpenedTheGUI.value) {
p = player.getName(); p = player.getName();
} else p = SelectConfig.getUseItem_PlayerName(); } else p = String.valueOf(ConfigValues.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>) ConfigValues.useItemLore.value));
} else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore())); } else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList<String>) ConfigValues.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(ConfigValues.useItemMaterial.value)));
ItemMeta itemMeta = item.getItemMeta(); ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(SelectConfig.getUseItem_Name()); itemMeta.setDisplayName(String.valueOf(ConfigValues.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>) ConfigValues.useItemLore.value));
} else itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore())); } else itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList<String>) ConfigValues.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) ConfigValues.useItemGameModeProtection.value) {
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) { if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.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) ConfigValues.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player);
return true; return true;
} }
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) { if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.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) ConfigValues.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player);
return true; return true;
} }
} }
if (SelectConfig.getUseItemWorldProtection()) { if ((Boolean) ConfigValues.useItemWorldProtection.value) {
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) { if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.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) ConfigValues.useItemWorldRemoveItemWhenItIsDisabled.value) removeItem(player);
return true; return true;
} }
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) { if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.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) ConfigValues.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(ConfigValues.useItemMaterial.value)) || itm.getType() == T2CitemVersion.getHead()) {
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) { if (itm.getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
player.getInventory().remove(itm); player.getInventory().remove(itm);
player.updateInventory(); player.updateInventory();
break; break;

View File

@ -1,4 +1,4 @@
package net.t2code.commandguiv2.Spigot.objects.functions; package net.t2code.commandguiv2.Spigot.objects;
import net.t2code.commandguiv2.Spigot.enums.EcoEnum; import net.t2code.commandguiv2.Spigot.enums.EcoEnum;
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum; import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
@ -6,7 +6,7 @@ import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
import java.util.List; import java.util.List;
public class Function { public class FunctionObject {
public String key; public String key;
public Boolean empty; public Boolean empty;
@ -71,67 +71,67 @@ public class Function {
public FunctionItemEnum functionItemMode; public FunctionItemEnum functionItemMode;
public String functionItemItem; public String functionItemItem;
public Function(String key, public FunctionObject(String key,
Boolean empty, Boolean empty,
Integer itemAmount, Integer itemAmount,
Boolean playerHead_Enable, Boolean playerHead_Enable,
Boolean base64Value_Enable, Boolean base64Value_Enable,
String base64Value, String base64Value,
Boolean playerWhoHasOpenedTheGUI, Boolean playerWhoHasOpenedTheGUI,
String playerName, String playerName,
String item, String item,
String name, String name,
List<String> lore, List<String> lore,
Boolean noPermMessageEnable, Boolean noPermMessageEnable,
String customNoPermMessage, String customNoPermMessage,
Boolean noPermLoreEnable, Boolean noPermLoreEnable,
List<String> noPermLore, List<String> noPermLore,
Boolean customSound_Enable, Boolean customSound_Enable,
Boolean customSound_NoSound, Boolean customSound_NoSound,
String customSound_Sound, String customSound_Sound,
Boolean cost_Enable, Boolean cost_Enable,
EcoEnum ecoModule, EcoEnum ecoModule,
String ecoItem, String ecoItem,
Integer votePoints, Integer votePoints,
Double price, Double price,
Boolean command_Enable, Boolean command_Enable,
Boolean command_BungeeCommand, Boolean command_BungeeCommand,
Boolean commandAsConsole, Boolean commandAsConsole,
List<String> command, List<String> command,
Boolean serverChange, Boolean serverChange,
String serverChangeServer, String serverChangeServer,
Boolean openGUI_Enable, Boolean openGUI_Enable,
String openGUI, String openGUI,
Boolean togglePermission, Boolean togglePermission,
String togglePermissionPerm, String togglePermissionPerm,
Boolean toggleUseItem, Boolean toggleUseItem,
Boolean message_Enable, Boolean message_Enable,
List<String> message, List<String> message,
Boolean setConfigEnable, Boolean setConfigEnable,
String configFilePath, String configFilePath,
String configOptionPath, String configOptionPath,
String configOptionPremat, String configOptionPremat,
String configStringValueLeft, String configStringValueLeft,
Boolean configBooleanValueLeft, Boolean configBooleanValueLeft,
Integer configIntegerValueLeft, Integer configIntegerValueLeft,
Double configDoubleValueLeft, Double configDoubleValueLeft,
List<String> configListValueLeft, List<String> configListValueLeft,
String configStringValueRight, String configStringValueRight,
Boolean configBooleanValueRight, Boolean configBooleanValueRight,
Integer configIntegerValueRight, Integer configIntegerValueRight,
Double configDoubleValueRight, Double configDoubleValueRight,
List<String> configListValueRight, List<String> configListValueRight,
Boolean pluginReloadEnable, Boolean pluginReloadEnable,
String pluginReloadCommand, String pluginReloadCommand,
Boolean functionVotePoints, Boolean functionVotePoints,
FunctionVoteEnum functionVotePointsMode, FunctionVoteEnum functionVotePointsMode,
Integer functionVotePointsAmount, Integer functionVotePointsAmount,
Boolean functionItem, Boolean functionItem,
FunctionItemEnum functionItemMode, FunctionItemEnum functionItemMode,
String functionItemItem) { String functionItemItem) {
this.key = key; this.key = key;
this.empty = empty; this.empty = empty;
this.itemAmount = itemAmount; this.itemAmount = itemAmount;

View File

@ -1,10 +1,8 @@
package net.t2code.commandguiv2.Spigot.objects.guis; package net.t2code.commandguiv2.Spigot.objects;
import net.t2code.commandguiv2.Spigot.objects.slots.Slot;
import java.util.ArrayList; import java.util.ArrayList;
public class Gui { public class GuiObject {
public Boolean guiEnable; public Boolean guiEnable;
public Integer guiLines; public Integer guiLines;
public String guiName; public String guiName;
@ -14,10 +12,10 @@ public class Gui {
public String key; public String key;
public Boolean commandAliasEnable; public Boolean commandAliasEnable;
public Boolean commandPermissionEnable; public Boolean commandPermissionEnable;
public ArrayList<Slot> slots; public ArrayList<SlotObject> slots;
public Gui(Boolean guiEnable, Integer guiLines, String guiName, Boolean guiFillitemEnable, String guiFillitemItem, public GuiObject(Boolean guiEnable, Integer guiLines, String guiName, Boolean guiFillitemEnable, String guiFillitemItem,
String commandCommand, Boolean commandAliasEnable, Boolean commandPermissionEnable, ArrayList<Slot> slots){ String commandCommand, Boolean commandAliasEnable, Boolean commandPermissionEnable, ArrayList<SlotObject> slots){
this.guiEnable = guiEnable; this.guiEnable = guiEnable;
this.guiLines = guiLines; this.guiLines = guiLines;
this.guiName = guiName; this.guiName = guiName;

View File

@ -1,6 +1,6 @@
package net.t2code.commandguiv2.Spigot.objects.slots; package net.t2code.commandguiv2.Spigot.objects;
public class Slot { public class SlotObject {
public Integer slot; public Integer slot;
public Boolean enable; public Boolean enable;
@ -10,12 +10,12 @@ public class Slot {
public String permissionToUse; public String permissionToUse;
public Slot(Integer slot, public SlotObject(Integer slot,
Boolean enable, Boolean enable,
String function, String function,
Boolean permission, Boolean permission,
String permissionToSee, String permissionToSee,
String permissionToUse String permissionToUse
) { ) {
this.slot = slot; this.slot = slot;
this.enable = enable; this.enable = enable;

View File

@ -0,0 +1,145 @@
package net.t2code.commandguiv2.Spigot.objects;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
public class UseItemObject {
public String key;
public Boolean enable;
public String openGui;
public Boolean allowToggle;
public Boolean allowSetBlock;
public Boolean blockMoveAndDrop;
public Boolean permBecomeNeeded;
public String permBecome;
public PermissionDefault permBecomeDefault;
public Boolean permUseNeeded;
public String permUse;
public PermissionDefault permUseDefault;
public Boolean permToggleNeeded;
public String permToggle;
public PermissionDefault permToggleDefault;
public Boolean permSetSlotNeeded;
public String permSetSlot;
public PermissionDefault permSetSlotDefault;
public Boolean keepAtCommandClear;
public Integer invSlotSlot;
public Boolean invSlotEnforce;
public Boolean invFreeSlot;
public String itemMaterial;
public String itemName;
public List<String> itemLore;
public Boolean itemPlayerHeadEnable;
public Boolean itemPlayerHeadPlayerWhoHasOpenedTheGUI;
public String itemPlayerHeadPlayerName;
public Boolean itemPlayerHeadBase64Enable;
public String itemPlayerHeadBase64Value;
public Boolean joinGiveOnEveryJoin;
public Boolean joinGiveOnlyOnFirstJoin;
public Boolean quitRemoveOnQuit;
public Boolean protectGameModeEnable;
public Boolean protectGameModeRemoveItemWhenItIsDisabled;
public String protectGameModeMode;
public List<String> protectGameModeList;
public Boolean protectWorldEnable;
public Boolean protectWorldRemoveItemWhenItIsDisabled;
public String protectWorldMode;
public List<String> protectWorldList;
public UseItemObject(String key,
Boolean enable,
String openGui,
Boolean allowToggle,
Boolean allowSetBlock,
Boolean blockMoveAndDrop,
Boolean permBecomeNeeded,
String permBecome,
PermissionDefault permBecomeDefault,
Boolean permUseNeeded,
String permUse,
PermissionDefault permUseDefault,
Boolean permToggleNeeded,
String permToggle,
PermissionDefault permToggleDefault,
Boolean permSetSlotNeeded,
String permSetSlot,
PermissionDefault permSetSlotDefault,
Boolean keepAtCommandClear,
Integer invSlotSlot,
Boolean invSlotEnforce,
Boolean invFreeSlot,
String itemMaterial,
String itemName,
List<String> itemLore,
Boolean itemPlayerHeadEnable,
Boolean itemPlayerHeadPlayerWhoHasOpenedTheGUI,
String itemPlayerHeadPlayerName,
Boolean itemPlayerHeadBase64Enable,
String itemPlayerHeadBase64Value,
Boolean joinGiveOnEveryJoin,
Boolean joinGiveOnlyOnFirstJoin,
Boolean quitRemoveOnQuit,
Boolean protectGameModeEnable,
Boolean protectGameModeRemoveItemWhenItIsDisabled,
String protectGameModeMode,
List<String> protectGameModeList,
Boolean protectWorldEnable,
Boolean protectWorldRemoveItemWhenItIsDisabled,
String protectWorldMode,
List<String> protectWorldList) {
this.key = key;
this.enable = enable;
this.openGui = openGui;
this.allowToggle = allowToggle;
this.allowSetBlock = allowSetBlock;
this.blockMoveAndDrop = blockMoveAndDrop;
this.permBecomeNeeded = permBecomeNeeded;
this.permBecome = permBecome;
this.permBecomeDefault = permBecomeDefault;
this.permUseNeeded = permUseNeeded;
this.permUse = permUse;
this.permUseDefault = permUseDefault;
this.permToggleNeeded = permToggleNeeded;
this.permToggle = permToggle;
this.permToggleDefault = permToggleDefault;
this.permSetSlotNeeded = permSetSlotNeeded;
this.permSetSlot = permSetSlot;
this.permSetSlotDefault = permSetSlotDefault;
this.keepAtCommandClear = keepAtCommandClear;
this.invSlotSlot = invSlotSlot;
this.invSlotEnforce = invSlotEnforce;
this.invFreeSlot = invFreeSlot;
this.itemMaterial = itemMaterial;
this.itemName = itemName;
this.itemLore = itemLore;
this.itemPlayerHeadEnable = itemPlayerHeadEnable;
this.itemPlayerHeadPlayerWhoHasOpenedTheGUI = itemPlayerHeadPlayerWhoHasOpenedTheGUI;
this.itemPlayerHeadPlayerName = itemPlayerHeadPlayerName;
this.itemPlayerHeadBase64Enable = itemPlayerHeadBase64Enable;
this.itemPlayerHeadBase64Value = itemPlayerHeadBase64Value;
this.joinGiveOnEveryJoin = joinGiveOnEveryJoin;
this.joinGiveOnlyOnFirstJoin = joinGiveOnlyOnFirstJoin;
this.quitRemoveOnQuit = quitRemoveOnQuit;
this.protectGameModeEnable = protectGameModeEnable;
this.protectGameModeRemoveItemWhenItIsDisabled = protectGameModeRemoveItemWhenItIsDisabled;
this.protectGameModeMode = protectGameModeMode;
this.protectGameModeList = protectGameModeList;
this.protectWorldEnable = protectWorldEnable;
this.protectWorldRemoveItemWhenItIsDisabled = protectWorldRemoveItemWhenItIsDisabled;
this.protectWorldMode = protectWorldMode;
this.protectWorldList = protectWorldList;
}
}

View File

@ -0,0 +1,11 @@
package net.t2code.commandguiv2.Spigot.objects.player;
import java.util.ArrayList;
public class PlayerObject {
public ArrayList<UseItemPlayerObject> useItems;
public PlayerObject(ArrayList<UseItemPlayerObject> useItems) {
this.useItems = useItems;
}
}

View File

@ -0,0 +1,13 @@
package net.t2code.commandguiv2.Spigot.objects.player;
public class UseItemPlayerObject {
public String key;
public Boolean enable;
public Integer slot;
public UseItemPlayerObject(String key, Boolean enable, Integer slot) {
this.key = key;
this.enable = enable;
this.slot = slot;
}
}

View File

@ -0,0 +1,61 @@
package net.t2code.commandguiv2.Spigot.sound;
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
import net.t2code.commandguiv2.Spigot.objects.SlotObject;
import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
import net.t2code.commandguiv2.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.entity.Player;
public class PlaySound {
private static String prefix = Util.getPrefix();
public static void play(Player player, SoundEnum soundEnum) {
play(player, soundEnum, null, null, null);
}
public static void play(Player player, SoundEnum soundEnum, FunctionObject function, SlotObject slot, GuiObject gui) {
if (!(Boolean) ConfigValues.soundEnable.value) return;
switch (soundEnum) {
case OpenInventory:
if (!(Boolean) ConfigValues.soundOpenInventoryEnable.value) return;
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundOpenInventoryInput.value).toUpperCase().replace(".", "_")), 3, 1);
break;
case Click:
if (!(Boolean) ConfigValues.soundClickEnable.value) return;
if (!function.customSound_Enable) {
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundClickInput.value).toUpperCase().replace(".", "_")), 3, 1);
return;
}
if (function.customSound_NoSound) return;
try {
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
} catch (Exception e1) {
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));
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundClickInput.value).toUpperCase().replace(".", "_")), 3, 1);
}
break;
case NoMoney:
if (!(Boolean) ConfigValues.soundNoMoneyEnable.value) return;
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundNoMoneyInput.value).toUpperCase().replace(".", "_")), 3, 1);
break;
case NoInventorySpace:
if (!(Boolean) ConfigValues.soundNoInventorySpaceEnable.value) return;
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundNoInventorySpaceInput.value).toUpperCase().replace(".", "_")), 3, 1);
break;
case Give:
if (!(Boolean) ConfigValues.soundGiveEnable.value) return;
player.playSound(player.getLocation(),org.bukkit.Sound.valueOf(String.valueOf( ConfigValues.soundGiveInput.value).toUpperCase().replace(".", "_")), 3, 1);
break;
case PlayerNotFound:
if (!(Boolean) ConfigValues.soundPlayerNotFoundEnable.value) return;
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundPlayerNotFoundInput.value).toUpperCase().replace(".", "_")), 3, 1);
break;
}
}
}

View File

@ -1,62 +0,0 @@
package net.t2code.commandguiv2.Spigot.sound;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.objects.functions.Function;
import net.t2code.commandguiv2.Spigot.objects.guis.Gui;
import net.t2code.commandguiv2.Spigot.objects.slots.Slot;
import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
import net.t2code.commandguiv2.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.entity.Player;
public class Sound {
private static String prefix = Util.getPrefix();
public static void play(Player player, SoundEnum soundEnum) {
if (!SelectConfig.getSound_Enable()) return;
play(player, soundEnum, null, null, null);
}
public static void play(Player player, SoundEnum soundEnum, Function function, Slot slot, Gui gui) {
if (!SelectConfig.getSound_Enable()) return;
switch (soundEnum) {
case OpenInventory:
if (!SelectConfig.getSound_OpenInventory_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_OpenInventory(), 3, 1);
break;
case Click:
if (!SelectConfig.getSound_Click_Enable()) return;
if (!function.customSound_Enable) {
player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1);
return;
}
if (function.customSound_NoSound) return;
try {
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
} catch (Exception e1) {
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));
player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1);
}
break;
case NoMoney:
if (!SelectConfig.getSound_NoMoney_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_NoMoney(), 3, 1);
break;
case NoInventorySpace:
if (!SelectConfig.getSound_NoInventorySpace_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_NoInventorySpace(), 3, 1);
break;
case Give:
if (!SelectConfig.getSound_Give_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_Give(), 3, 1);
break;
case PlayerNotFound:
if (!SelectConfig.getSound_PlayerNotFound_Enable()) return;
player.playSound(player.getLocation(), SelectConfig.getSound_PlayerNotFound(), 3, 1);
break;
}
}
}

View File

@ -1,9 +1,14 @@
package net.t2code.commandguiv2.Spigot.system; package net.t2code.commandguiv2.Spigot.system;
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import net.t2code.commandguiv2.Spigot.gui.GUIListener; import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect;
import net.t2code.commandguiv2.Spigot.listener.Bungee_Sender_Reciver; import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
import net.t2code.commandguiv2.Spigot.useItem.EventsFrom110; import net.t2code.commandguiv2.Spigot.config.functions.SelectFunctions;
import net.t2code.commandguiv2.Spigot.config.gui.SelectGui;
import net.t2code.commandguiv2.Spigot.config.useItems.UseItemSelect;
import net.t2code.commandguiv2.Spigot.function.gui.GUIListener;
import net.t2code.commandguiv2.Spigot.function.listener.Bungee_Sender_Reciver;
import net.t2code.commandguiv2.Spigot.function.useItem.EventsFrom110;
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI; import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem; import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem;
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help; import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help;
@ -13,12 +18,9 @@ import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI;
import net.t2code.commandguiv2.Spigot.config.languages.LanguagesCreate; import net.t2code.commandguiv2.Spigot.config.languages.LanguagesCreate;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.database.MySQL; import net.t2code.commandguiv2.Spigot.database.MySQL;
import net.t2code.commandguiv2.Spigot.listener.PluginEvent; import net.t2code.commandguiv2.Spigot.function.listener.PluginEvent;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.function.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.config.config.ConfigCreate;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.commandguiv2.Spigot.database.SQLITE; import net.t2code.commandguiv2.Spigot.database.SQLITE;
import net.t2code.commandguiv2.Spigot.database.SelectDatabase; import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
import net.t2code.commandguiv2.Spigot.enums.StorageEnum; import net.t2code.commandguiv2.Spigot.enums.StorageEnum;
@ -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;
@ -49,18 +52,14 @@ public class Load {
T2Csend.console(prefix + " §8-------------------------------"); T2Csend.console(prefix + " §8-------------------------------");
try { try {
ConfigConverterUnderV5.renameMainFolder(); ConfigConverterV5.renameMainFolder();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (!new File(Main.getPath(), "config.yml").exists()) { if (!new File(Main.getPath(), "config.yml").exists()) {
try {
plugin.saveResource("configDeclaration.yml", false);
} catch (Exception e) {
e.printStackTrace();
}
try { try {
CreateGUI.configCreate(); CreateGUI.configCreate();
} catch (Exception e) { } catch (Exception e) {
@ -71,15 +70,21 @@ public class Load {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try {
UseItemSelect.create();
} catch (Exception e) {
e.printStackTrace();
}
} }
try { try {
ConfigCreate.configCreate(); ConfigSelect.selectConfig();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
SelectConfig.onSelect(); plugin.saveResource("configDeclaration.yml", true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -93,10 +98,13 @@ public class Load {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try {
plugin.saveResource("UseItems/useItemDeclaration.yml", true);
} catch (Exception e) {
e.printStackTrace();
}
SelectConfig.setConfigVersion(); if (T2CLibConfig.getBungee()) {
if (SelectConfig.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");
@ -117,7 +125,17 @@ public class Load {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
Obj_Select.onSelect(); SelectFunctions.onSelectFunction();
} catch (Exception e) {
e.printStackTrace();
}
try {
SelectGui.onSelectGui();
} catch (Exception e) {
e.printStackTrace();
}
try {
UseItemSelect.onSelect();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -128,12 +146,12 @@ public class Load {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
SelectConfig.sound(prefix); ConfigValues.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(ConfigValues.adminSubCommand.value), Permissions.admin + ";" + Permissions.giveItemOther + ";" + Permissions.info);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -154,7 +172,7 @@ public class Load {
e.printStackTrace(); e.printStackTrace();
} }
if (SelectConfig.getHelpAlias()) { if ((Boolean) ConfigValues.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");
} }
@ -178,8 +196,8 @@ public class Load {
Bukkit.getServer().getPluginManager().registerEvents(new EventsFrom110(), plugin); Bukkit.getServer().getPluginManager().registerEvents(new EventsFrom110(), plugin);
} }
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(),spigotID,discord T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), spigotID, discord
,SelectConfig.getUpdateCheckOnJoin(),SelectConfig.getUpdateCheckSeePreReleaseUpdates(),SelectConfig.getUpdateCheckTimeInterval()); , (Boolean) ConfigValues.updateCheckOnJoin.value, (Boolean) ConfigValues.updateCheckSeePreReleaseUpdates.value, (Integer) ConfigValues.updateCheckTimeInterval.value);
Metrics.Bstats(); Metrics.Bstats();
Main.addonLoad(); Main.addonLoad();
T2Ctemplate.onLoadFooter(prefix, long_); T2Ctemplate.onLoadFooter(prefix, long_);
@ -187,9 +205,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(ConfigValues.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 '" + ConfigValues.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,8 +1,9 @@
package net.t2code.commandguiv2.Spigot.system; package net.t2code.commandguiv2.Spigot.system;
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.GuiObject;
import net.t2code.commandguiv2.Spigot.objects.slots.Slot; import net.t2code.commandguiv2.Spigot.objects.SlotObject;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister; import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -66,10 +67,10 @@ public class Permissions {
T2Cregister.permissionDescription(admin, "All permissions from T2C-CommandGUI", plugin); T2Cregister.permissionDescription(admin, "All permissions from T2C-CommandGUI", plugin);
for (Gui gui : Main.guiHashMap.values()) { for (GuiObject gui : Cache.guiHashMap.values()) {
T2Cregister.permission(command + "." + gui.key, op, plugin); T2Cregister.permission(command + "." + gui.key, op, plugin);
T2Cregister.permission(admin, op, command + "." + gui.key, true, plugin); T2Cregister.permission(admin, op, command + "." + gui.key, true, plugin);
for (Slot slot : gui.slots) { for (SlotObject slot : gui.slots) {
T2Cregister.permission(slot.permissionToUse, op, plugin); T2Cregister.permission(slot.permissionToUse, op, plugin);
T2Cregister.permission(admin, op, slot.permissionToUse, true, plugin); T2Cregister.permission(admin, op, slot.permissionToUse, true, plugin);
T2Cregister.permission(slot.permissionToSee, op, plugin); T2Cregister.permission(slot.permissionToSee, op, plugin);

View File

@ -1,7 +1,7 @@
package net.t2code.commandguiv2.Spigot.system; package net.t2code.commandguiv2.Spigot.system;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig; import net.t2code.commandguiv2.Spigot.function.useItem.Events;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,8 +10,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 ConfigValues.placeholderTrue.name();
} else return SelectConfig.getPlaceholderFalse(); } else return ConfigValues.placeholderFalse.name();
} }
public static String useitem_boolean(Player p) { public static String useitem_boolean(Player p) {

View File

@ -7,7 +7,7 @@ public class Util {
} }
public static String getRequiredT2CodeLibVersion() { public static String getRequiredT2CodeLibVersion() {
return "13.4"; return "14.2";
} }
public static String getPrefix() { public static String getPrefix() {
@ -34,7 +34,4 @@ public class Util {
return net.t2code.t2codelib.Util.getDiscord(); return net.t2code.t2codelib.Util.getDiscord();
} }
public static Integer getConfigVersion() {
return 5;
}
} }

View File

@ -1,12 +1,12 @@
package net.t2code.commandguiv2.api; package net.t2code.commandguiv2.api;
import net.t2code.commandguiv2.Spigot.useItem.ItemChange; import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import net.t2code.commandguiv2.Spigot.useItem.Events; import net.t2code.commandguiv2.Spigot.function.useItem.ItemChange;
import net.t2code.commandguiv2.Spigot.function.useItem.Events;
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.cmdManagement.Help; import net.t2code.commandguiv2.Spigot.cmdManagement.Help;
import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI; import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI;
import net.t2code.commandguiv2.Spigot.config.config.SelectConfig;
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages; import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
import net.t2code.commandguiv2.Spigot.system.Permissions; import net.t2code.commandguiv2.Spigot.system.Permissions;
import net.t2code.commandguiv2.Spigot.database.SelectDatabase; import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
@ -29,13 +29,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(ConfigValues.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(ConfigValues.useItemName.value));
} }
public static void disableItemGiveOnJoin(Boolean disableItemGiveOnJoin) { public static void disableItemGiveOnJoin(Boolean disableItemGiveOnJoin) {
@ -53,8 +53,8 @@ public class CGuiAPI {
public static void setPlayerItemEnable(Player player, Boolean value) { public static void setPlayerItemEnable(Player player, Boolean value) {
if (value) { if (value) {
SelectDatabase.setItemStatusTrue(player); SelectDatabase.setItemStatus(player, true);
} else SelectDatabase.setItemStatusFalse(player); } else SelectDatabase.setItemStatus(player, true);
} }
public static void setPlayerItemSlot(Player player, Integer value) { public static void setPlayerItemSlot(Player player, Integer value) {

View File

@ -0,0 +1,17 @@
package net.t2code.commandguiv2.cache;
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
import net.t2code.commandguiv2.Spigot.objects.UseItemObject;
import net.t2code.commandguiv2.Spigot.objects.player.PlayerObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
public class Cache {
public static HashMap<String, GuiObject> guiHashMap = new HashMap<>();
public static HashMap<String, UseItemObject> useItemHash = new HashMap<>();
public static ArrayList<String> allAliases = new ArrayList<>();
public static HashMap<String, FunctionObject> functionHashMap = new HashMap<>();
}

View File

@ -0,0 +1,114 @@
useItem:
# enable: Set here if the UseItem is to be used in use
enable: false
# openGUI: Set here which GUI should open the UseItem
openGUI: default
# allowToggle: Set here if players are allowed to enable or disable the UseItem with '/gui-item <useitemname> <on/off>'.
allowToggle: true
# allowSetSlot: Set here if players are allowed to change the slot in the inventory where the UseItem is located with '/gui-item <useitemname> slot <slot>'.
allowSetSlot: true
# blockMoveAndDrop: Set here if the dropping of the UseItem should be blocked
blockMoveAndDrop: true
permission:
become:
# Here you define if and which permission is needed to get the UseItem (for Join etc.).
needed: true
permission: 'commandgui.useitem.[useitemname].use'
# Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP]
default: TRUE
use:
# Here you define if and which permission is needed to use the UseItem
needed: true
permission: 'commandgui.useitem.[useitemname].use'
# Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP]
default: TRUE
toggle:
# Here you define if and which permission is needed to use the command '/gui-item <useitemname> <on/off>' for this UseItem
needed: true
permission: 'commandgui.useitem.[useitemname].toggle'
# Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP]
default: OP
setSlot:
# Here you define if and which permission is needed to use the command '/gui-item <useitemname> slot <slot>' for this UseItem
needed: true
permission: 'commandgui.useitem.[useitemname].setslot'
# Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP]
default: OP
# keepAtCommandClear: Set here if the UseItem should stay in the inventory with the '/clear' command
keepAtCommandClear: true
inventorySlot:
# slot: slot: Set here on which slot the UseItem should be located by default
slot: 1
# slotEnforce: Set here if the slot should be forced even if another item is on this slot (also the set slot of the player).
# NOTE: The item that was on this slot before will be deleted.
slotEnforce: false
# freeSlot: Set here if the UseItem should be placed on another free slot, if the selected slot (also the set slot of the player) is occupied.
freeSlot: false
# Set here the item that should be used as UseItem
item:
# material: Set here which material should be used as UseItem
material: paper
# name: Set the DisplayName of the UseItem here
name: '&6GUI UseItem'
# lore: Set the lore of the UseItem here
lore:
- 'Lore line 1'
- 'Lore line 2'
playerHead:
# enable: This specifies whether a PlayerHead is to be used as a UseItem. If this is set to true, the 'material' option is ignored.
enable: false
# playerWhoHasOpenedTheGUI: Here you can set whether the player head should be used as a UseItem by the player
playerWhoHasOpenedTheGUI: false
# playerName: Here you can set a player name whose head should be used as UseItem
playerName: ''
base64:
# enable: Set here if a Base64 PlayerHead should be used as UseItem
enable: false
# base64Value: Here you can set the Base64 Value.
# You can find the Base64 Value for example on https://minecraft-heads.com.
base64Value: ''
join:
# giveOnEveryJoin: Set here if the UseItem should be given at every server join
giveOnEveryJoin: true
# giveOnlyOnFirstJoin: Set here if the UseItem should only be given to the server at the first join of the player.
giveOnlyOnFirstJoin: false
quit:
# removeOnQuit: Set here if the UseItem should be removed from the inventory when leaving the server
removeOnQuit: false
protection:
gameMode:
# enable: Set here in which gamemode the UseItem may be used
enable: false
# removeItemWhenItIsDisabled: Set here if the UseItem should be removed if you are in a not allowed Gamemode
removeItemWhenItIsDisabled: false
# mode: Set here if a 'blacklist' or 'whitelist' should be used
mode: blacklist
# list: Set the GameMode list here
list:
- CREATIVE
- SPECTATOR
world:
# enable: Set here in which world the UseItem may be used
enable: false
# removeItemWhenItIsDisabled: Here you specify whether the UseItem should be removed if you are in a world that is not permitted
removeItemWhenItIsDisabled: false
# mode: Set here if a 'blacklist' or 'whitelist' should be used
mode: blacklist
# list: Set the worlds here
list:
- World1
- World2
#/useitem <itemname> on/off/slot [slotnumber]

View File

@ -2,210 +2,127 @@
######################################### #########################################
## Please do not change ConfigVersion! ## ## Please do not change ConfigVersion! ##
######################################### #########################################
ConfigVersion: 5 configVersion: 6
Plugin: plugin:
# Here you can set the debug mode of the plugin. # Here you can set the debug mode of the plugin.
# It is recommended not to activate this on productive systems. Only if it is really needed! # It is recommended not to activate this on productive systems. Only if it is really needed!
Debug: false debug: false
# Here you can set whether the Helpalias command (/commandguihelp) should be activated. # Here you can set whether the Helpalias command (/commandguihelp) should be activated.
# If this is changed the server MUST be restarted to change this! # If this is changed the server MUST be restarted to change this!
HelpAlias: true helpAlias: true
# Here you set which subcommand should be for the admin functions. # Here you set which subcommand should be for the admin functions.
# (/commandgui 'admin' reload) # (/commandgui 'admin' reload)
AdminSubCommand: admin adminSubCommand: admin
# here you set the language to be used # here you set the language to be used
language: english language: english
# Here you set the character or word that will be used as currency # Here you set the character or word that will be used as currency
Currency: $ currency: $
# Here you set which GUI should be opened at '/commandgui' / '/gui'. # Here you set which GUI should be opened at '/commandgui' / '/gui'.
DefaultGUI: default defaultGUI: default
Storage: storage:
# Set here if MySQL, SQLITE or YML should be used as storage. # Set here if MySQL, SQLITE or YML should be used as storage.
Type: SQLITE type: SQLITE
# Enter here the access data to the database you want to use, if you use MySQL # Enter here the access data to the database you want to use, if you use MySQL
MySQL: mySQL:
IP: localhost ip: localhost
Port: 3306 port: 3306
Database: database database: database
User: root user: root
Password: password password: password
SSL: false ssl: false
BungeeCord: toggle:
# Set here if the plugin runs in a BungeeCord subserver.
# The plugin file must then be installed on the proxy (BungeeCord, Waterfall) and on the servers.
Enable: false
# Set here the server name of the server
ThisServer: server
UseItem:
# Set here if the UseItem is to be used in use
Enable: true
# Set here if players are allowed to enable or disable the UseItem with '/gui-item <on/off>'.
# Permission 'commandgui.useitem.toggle' is additionally required
AllowToggle: true
# Set here if players are allowed to change the slot in the inventory where the UseItem is located with '/gui-item <slot>'.
# Permission 'commandgui.useitem.toggle' is additionally required
AllowSetSlot: true
# Set here if the dropping of the UseItem should be blocked
BlockMoveAndDrop: true
# Set here which GUI should open the UseItem
OpenGUI: default
Permission:
# Set here if the permission 'commandgui.useitem' is required to use the UseItem
NeededToUse: true
# Set here if the UseItem should stay in the inventory with the '/clear' command
KeepAtCommandClear: true
InventorySlot:
# Set here on which slot the UseItem should be located by default
Slot: 1
# Set here if the slot should be forced even if another item is on this slot (also the set slot of the player).
# NOTE: The item that was on this slot before will be deleted.
SlotEnforce: false
# Set here if the UseItem should be placed on another free slot, if the selected slot (also the set slot of the player) is occupied.
FreeSlot: false
# Set here the item that should be used as UseItem
Item:
# Set here which material should be used as UseItem
Material: paper
PlayerHead:
# Set here if a PlayerHead should be used as UseItem
Enable: false
Base64:
# Set here if a Base64 PlayerHead should be used as UseItem
Enable: false
# Here you can set the Base64 Value.
# You can find the Base64 Value for example on https://minecraft-heads.com.
Base64Value: ''
# Here you can set whether the player head should be used as a UseItem by the player
PlayerWhoHasOpenedTheGUI: false
# Here you can set a player name whose head should be used as UseItem
Playername: ''
# Set the DisplayName of the UseItem here
Name: '&6GUI UseItem'
# Set the lore of the UseItem here
Lore:
- 'Lore line 1'
- 'Lore line 2'
Join:
# Set here if the UseItem should be given at every server join
GiveOnEveryJoin: true
# Set here if the UseItem should only be given to the server at the first join of the player.
GiveOnlyOnFirstJoin: false
Cursor:
ToGUIItem:
OnLogin:
# Here you define whether the UseItem should be selected when joining the server.
Enable: true
Spigot:
# Set here if the UseItem should only be selected at the first join
OnOnlyFirstLogin: true
Bungee:
# Set here if the UseItem should be selected even if you change the server of the bungee network.
# The option BungeeCord must be activated for this!
OnServerChange: false
Toggle:
# Set the items to be used with the Toggle function here # Set the items to be used with the Toggle function here
Items: items:
# Set here the item that should be used if you have the permission or the UseItem is active. # Set here the item that should be used if you have the permission or the UseItem is active.
OnOrYes: onOrYes:
Item: item:
Base64: base64:
# Set here if a Base64 head should be used # Set here if a Base64 head should be used
Enable: false enable: false
# Here you can set the Base64 Value. # Here you can set the Base64 Value.
# You can find the Base64 Value for example on https://minecraft-heads.com. # You can find the Base64 Value for example on https://minecraft-heads.com.
Base64Value: '' base64Value: ''
# Set the material to be used here # Set the material to be used here
Material: GREEN_WOOL material: GREEN_WOOL
# Set here the item to be used if you have the permission or the UseItem is disabled # Set here the item to be used if you have the permission or the UseItem is disabled
OffOrNo: offOrNo:
Item: item:
Base64: base64:
# Set here if a Base64 head should be used # Set here if a Base64 head should be used
Enable: false enable: false
# Here you can set the Base64 Value. # Here you can set the Base64 Value.
# You can find the Base64 Value for example on https://minecraft-heads.com. # You can find the Base64 Value for example on https://minecraft-heads.com.
Base64Value: '' base64Value: ''
# Set the material to be used here # Set the material to be used here
Material: RED_WOOL material: RED_WOOL
Permission: permission:
# Set here the commands to be used for Toggle.Permission # Set here the commands to be used for Toggle.Permission
Commands: commands:
'True': luckperms user [player] permission set [perm] true 'true': luckperms user [player] permission set [perm] true
'False': luckperms user [player] permission set [perm] false 'false': luckperms user [player] permission set [perm] false
# Set the design of the placeholders here # Set the design of the placeholders here
Placeholder: placeholder:
# Placeholder for true / enabled # Placeholder for true / enabled
'True': '&2true' 'true': '&2true'
# Placeholder for false / disabled # Placeholder for false / disabled
'False': '&4false' 'false': '&4false'
Sound: sound:
# Here you can disable all sounds # Here you can disable all sounds
Enable: true enable: true
# Set here At which action which sound should be played or none at all # Set here At which action which sound should be played or none at all
OpenInventory: openInventory:
Enable: true enable: true
Sound: BLOCK_CHEST_OPEN sound: BLOCK_CHEST_OPEN
Click: click:
Enable: true enable: true
Sound: BLOCK_NOTE_BLOCK_HAT sound: BLOCK_NOTE_BLOCK_HAT
NoMoney: noMoney:
Enable: true enable: true
Sound: BLOCK_NOTE_BLOCK_HARP sound: BLOCK_NOTE_BLOCK_HARP
NoInventorySpace: noInventorySpace:
Enable: true enable: true
Sound: BLOCK_NOTE_BLOCK_HARP sound: BLOCK_NOTE_BLOCK_HARP
Give: give:
Enable: true enable: true
Sound: ENTITY_PLAYER_LEVELUP sound: ENTITY_PLAYER_LEVELUP
PlayerNotFound: playerNotFound:
Enable: true enable: true
Sound: BLOCK_NOTE_BLOCK_HARP sound: BLOCK_NOTE_BLOCK_HARP
Advanced: useItemSettings:
UseItem: cursor:
GameMode: toGUIItem:
Change: # useItem: Here you define on which UseItem the cursor should be set.
# Set here if the UseItem should be reset when the GameMode is changed. useItem: default
Enable: true onLogin:
# Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second). # Here you define whether the UseItem should be selected when joining the server.
DelayInTicks: 1 enable: true
Protection: spigot:
# Set here in which gamemode the UseItem may be used # Set here if the UseItem should only be selected at the first join
Enable: false onOnlyFirstLogin: true
# Set here if the UseItem should be removed if you are in a not allowed Gamemode bungee:
RemoveItemWhenItIsDisabled: false # Set here if the UseItem should be selected even if you change the server of the bungee network.
# Set here if a 'blacklist' or 'whitelist' should be used # The option BungeeCord must be activated for this!
Mode: blacklist onServerChange: false
# Set the GameMode list here gameMode:
List: change:
- CREATIVE # Set here if the UseItem should be reset when the GameMode is changed.
- Spectator enable: true
World: # Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second).
Change: delayInTicks: 1
# This specifies whether the UseItem should be reset when the world is changed. world:
Enable: true change:
# Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second). # This specifies whether the UseItem should be reset when the world is changed.
DelayInTicks: 1 enable: true
Protection: # Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second).
# Set here in which world the UseItem may be used delayInTicks: 1
Enable: false # Set here for which blocks the UseItem is blocked and the function of the block you are looking at should be used.
# Here you specify whether the UseItem should be removed if you are in a world that is not permitted itemBlockBlacklist:
RemoveItemWhenItIsDisabled: false
# Set here if a 'blacklist' or 'whitelist' should be used
Mode: blacklist
# Set the worlds here
List:
- World1
- World2
# Set here for which blocks the UseItem is blocked and the function of the block you are looking at should be used.
ItemBlockBlacklist:
- CHEST - CHEST
- CRAFTING_TABLE - CRAFTING_TABLE
- FURNACE - FURNACE