T2C-CommandGUI/CommandGUI V2/src/main/java/de/jatitv/commandguiv2/api/CGuiAPI.java

98 lines
3.9 KiB
Java
Raw Normal View History

2021-12-21 04:57:29 +00:00
package de.jatitv.commandguiv2.api;
import de.jatitv.commandguiv2.Spigot.Listener.ItemChange;
2022-04-16 12:32:22 +00:00
import de.jatitv.commandguiv2.Spigot.Listener.UseItem_Listener.Events;
2021-12-21 04:57:29 +00:00
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands;
import de.jatitv.commandguiv2.Spigot.cmdManagement.Help;
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
2022-01-16 02:03:04 +00:00
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
2022-01-06 01:21:27 +00:00
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
2022-04-22 17:05:34 +00:00
import de.jatitv.commandguiv2.Spigot.system.Permissions;
import de.jatitv.commandguiv2.Spigot.system.database.SelectDatabase;
2022-01-11 01:44:36 +00:00
import net.t2code.lib.Spigot.Lib.messages.send;
2021-12-21 04:57:29 +00:00
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
2022-01-16 02:03:04 +00:00
import org.bukkit.inventory.ItemStack;
2021-12-21 04:57:29 +00:00
public class CGuiAPI {
public static Boolean JoinDisable = false;
public static void onItemChange(Player player) {
ItemChange.itemChange(player, false);
}
2022-01-16 02:03:04 +00:00
public static boolean hasUseItemInMainHand(Player player) {
ItemStack item = player.getInventory().getItemInMainHand();
return item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name);
}
public static boolean hasUseItemInOffHand(Player player) {
ItemStack item = player.getInventory().getItemInOffHand();
return item.hasItemMeta() && item.getItemMeta().hasDisplayName()
&& item.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name);
}
public static void onItemChange(Player player, Boolean setCursor) {
ItemChange.itemChange(player, setCursor);
2021-12-21 04:57:29 +00:00
}
public static void disableItemGiveOnJoin(Boolean disableItemGiveOnJoin) {
2022-01-16 02:03:04 +00:00
send.debug(Main.plugin, "CGuiAPI: " + disableItemGiveOnJoin);
2021-12-21 04:57:29 +00:00
JoinDisable = disableItemGiveOnJoin;
}
public static Boolean selectPlayerItemEnable(Player player) {
return Events.useItemHashMap.get(player.getName());
2021-12-21 04:57:29 +00:00
}
public static Integer selectPlayerItemSlot(Player player) {
return Events.useItemSlotHashMap.get(player.getName());
2021-12-21 04:57:29 +00:00
}
public static void setPlayerItemEnable(Player player, Boolean value) {
if (value) {
SelectDatabase.setItemStatusTrue(player);
} else SelectDatabase.setItemStatusFalse(player);
2021-12-21 04:57:29 +00:00
}
public static void setPlayerItemSlot(Player player, Integer value) {
SelectDatabase.setSlot(player, value);
2021-12-21 04:57:29 +00:00
}
public static void openDefaultGUI(Player player) {
Commands.gui(player);
}
public static void openGUI(Player player, String GUI_CommandName) {
Commands.gui(player, GUI_CommandName);
}
public static void sendHelp(CommandSender sender) {
Help.sendHelp(sender, Main.prefix);
}
public static void sendPluginInfo(CommandSender sender) {
2022-04-22 17:05:34 +00:00
if (sender.hasPermission(Permissions.info)) {
2021-12-21 04:57:29 +00:00
Commands.info(sender);
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
2022-04-22 17:05:34 +00:00
.replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.info));
2021-12-21 04:57:29 +00:00
}
public static void createDefaultGUI(CommandSender sender) {
2022-04-22 17:05:34 +00:00
if (sender.hasPermission(Permissions.admin)) {
2.7.0 Snapshot 1 In this update some functions were rewritten, changed and added. Also some minor bugs have been fixed. The GUIs files have been split into GUI files and function files, this provides more clarity in the complete plugin structure and offers the possibility to access a function from multiple GUIs. Thus, for example, you can create a back button as a function and open it from 3 GUIs, the item, the function can also be in different places, because the slot is set in the GUI file. In the GUI files is thus specified on which slot which function should be located. In addition, the permission for See and for Use of the functions can now be set individually in the GUI Config. In the functions also 2 new functions were added, with which players can switch permissions on and off and an option to switch the UseItem on and off. Placeholders have been added. This update includes a converter that builds the new structure from the old config structure. Your options should be taken over. For security reasons your old GUI files are saved under the path 'plugins/CommandGUI/OldConfig/GUIs/Version4'. Bug fixes: - Fixed a bug that prevented GUIs from opening. - The OpenGUI option, the command '/cgui <guiname>' did not work. The GUI that was set as default GUI in UseItem was always opened. This was fixed New features: - Placeholders - %commandgui_useitem% - Shows if you have activated or deactivated the UseItem (in color, customizable in config.yml) - %commandgui_useitem_boolean% - Shows if you have enabled or disabled the UseItem - %commandgui_useitem_slot% - shows on which slot you have set the UseItem - ToggleUseItem as new option for slots - TogglePermission as new option for slots Changes: - The config structure has been revised.
2022-04-19 05:08:33 +00:00
CreateGUI.configCreate();
2021-12-21 04:57:29 +00:00
sender.sendMessage(SelectMessages.DefaultGUIcreate.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
2022-04-22 17:05:34 +00:00
.replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.admin));
2021-12-21 04:57:29 +00:00
}
public static void reload(CommandSender sender) {
2022-04-22 17:05:34 +00:00
if (sender.hasPermission(Permissions.admin)) {
2021-12-21 04:57:29 +00:00
Commands.reload(sender);
} else sender.sendMessage(SelectMessages.NoPermissionForCommand
2022-04-22 17:05:34 +00:00
.replace("[cmd]", "/commandgui admin").replace("[perm]", Permissions.admin));
2021-12-21 04:57:29 +00:00
}
}