2021-12-21 04:57:29 +00:00
|
|
|
package de.jatitv.commandguiv2.Spigot.cmdManagement;
|
|
|
|
|
|
|
|
import de.jatitv.commandguiv2.Spigot.Main;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.Objekte.Obj_Select;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.system.Give_UseItem;
|
2022-01-06 01:21:27 +00:00
|
|
|
import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
2021-12-21 04:57:29 +00:00
|
|
|
import de.jatitv.commandguiv2.Spigot.system.database.Select_Database;
|
|
|
|
import de.jatitv.commandguiv2.Util;
|
|
|
|
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
|
|
|
|
import net.t2code.lib.Spigot.Lib.messages.send;
|
|
|
|
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
|
|
public class Commands {
|
|
|
|
public static void info(CommandSender sender) {
|
|
|
|
if (sender instanceof Player) {
|
|
|
|
Player player = (Player) sender;
|
2022-01-01 02:40:54 +00:00
|
|
|
send.player(player, Util.getPrefix() + "§4======= §8[§4Command§9GUI§8] §4=======");
|
2022-02-09 21:53:18 +00:00
|
|
|
send.player(player, Util.getPrefix() + " §2Autor: §6" + String.valueOf(Main.autor).replace("[", "").replace("]", ""));
|
2021-12-21 04:57:29 +00:00
|
|
|
|
2022-01-01 02:40:54 +00:00
|
|
|
if (UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion.equalsIgnoreCase(Main.version)) {
|
|
|
|
send.player(player, Util.getPrefix() + " §2Version: §6" + Main.version);
|
2021-12-21 04:57:29 +00:00
|
|
|
} else {
|
2022-01-01 02:40:54 +00:00
|
|
|
UpdateAPI.sendUpdateMsg(Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion, player);
|
2021-12-21 04:57:29 +00:00
|
|
|
}
|
|
|
|
|
2022-01-01 02:40:54 +00:00
|
|
|
send.player(player, Util.getPrefix() + " §2Spigot: §6" + Util.getSpigot());
|
|
|
|
send.player(player, Util.getPrefix() + " §2Discord: §6" + Util.getDiscord());
|
|
|
|
send.player(player, Util.getPrefix() + "§4======= §8[§4Command§9GUI§8] §4=======");
|
2021-12-21 04:57:29 +00:00
|
|
|
} else {
|
2022-01-01 02:40:54 +00:00
|
|
|
send.sender(sender, Util.getPrefix() + "§4======= §8[§4Command§9GUI§8] §4=======");
|
|
|
|
send.sender(sender, Util.getPrefix() + " §2String.valueOf(Main.autor): §6" + String.valueOf(String.valueOf(Main.autor)).replace("[", "").replace("]", ""));
|
2021-12-21 04:57:29 +00:00
|
|
|
|
2022-01-01 02:40:54 +00:00
|
|
|
if (UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion.equalsIgnoreCase(Main.version)) {
|
|
|
|
send.sender(sender, Util.getPrefix() + " §2Version: §6" + Main.version);
|
2021-12-21 04:57:29 +00:00
|
|
|
} else {
|
2022-01-01 02:40:54 +00:00
|
|
|
UpdateAPI.sendUpdateMsg(Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion);
|
2021-12-21 04:57:29 +00:00
|
|
|
}
|
|
|
|
|
2022-01-01 02:40:54 +00:00
|
|
|
send.sender(sender, Util.getPrefix() + " §2Spigot: §6" + Util.getSpigot());
|
|
|
|
send.sender(sender, Util.getPrefix() + " §2Discord: §6" + Util.getDiscord());
|
|
|
|
send.sender(sender, Util.getPrefix() + "§4======= §8[§4Command§9GUI§8] §4=======");
|
2021-12-21 04:57:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void reload(CommandSender sender) {
|
|
|
|
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadStart);
|
2022-01-01 02:40:54 +00:00
|
|
|
send.console(Util.getPrefix() + "§8-------------------------------");
|
|
|
|
send.console(Util.getPrefix() + " §6Plugin reload...");
|
|
|
|
send.console(Util.getPrefix() + "§8-------------------------------");
|
2021-12-21 04:57:29 +00:00
|
|
|
|
2021-12-22 18:52:19 +00:00
|
|
|
CmdExecuter_GUI.arg1.clear();
|
|
|
|
CmdExecuter_GUI.arg1.put("admin", "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
|
2021-12-21 04:57:29 +00:00
|
|
|
ConfigCreate.configCreate();
|
|
|
|
SelectConfig.onSelect();
|
2022-01-01 02:40:54 +00:00
|
|
|
Main.plugin.reloadConfig();
|
2021-12-21 04:57:29 +00:00
|
|
|
|
|
|
|
LanguagesCreate.langCreate();
|
|
|
|
|
|
|
|
Obj_Select.onSelect();
|
2022-01-01 02:40:54 +00:00
|
|
|
SelectMessages.onSelect(Util.getPrefix());
|
|
|
|
SelectConfig.sound(Util.getPrefix());
|
2021-12-21 04:57:29 +00:00
|
|
|
try {
|
|
|
|
AliasRegister.onRegister();
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2022-01-01 02:40:54 +00:00
|
|
|
if (SelectConfig.Bungee) {
|
2021-12-21 04:57:29 +00:00
|
|
|
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "commandgui:bungee");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadEnd);
|
2022-01-01 02:40:54 +00:00
|
|
|
send.console(Util.getPrefix() + "§8-------------------------------");
|
|
|
|
send.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
|
|
|
|
send.console(Util.getPrefix() + "§8-------------------------------");
|
2021-12-21 04:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void give(CommandSender sender, Player target) {
|
|
|
|
if (Bukkit.getPlayer(target.getName()) != null) {
|
|
|
|
Give_UseItem.onGive(target);
|
|
|
|
send.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", SelectConfig.UseItem_Name));
|
|
|
|
send.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", SelectConfig.UseItem_Name));
|
|
|
|
if (SelectConfig.Sound_Give_Enable && SelectConfig.Sound_Enable) {
|
|
|
|
target.playSound(target.getLocation(), SelectConfig.Sound_Give, 3, 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
sender.sendMessage(SelectMessages.PlayerNotFond.replace("[player]", target.getName()));
|
|
|
|
if (SelectConfig.Sound_PlayerNotFound_Enable && SelectConfig.Sound_Enable) {
|
|
|
|
if (sender instanceof Player)
|
|
|
|
((Player) sender).playSound(((Player) sender).getLocation(), SelectConfig.Sound_PlayerNotFound, 3, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void itemOn(Player player) {
|
|
|
|
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
|
|
|
ItemStack itm = player.getInventory().getItem(iam);
|
|
|
|
if (itm != null) {
|
2021-12-22 19:18:50 +00:00
|
|
|
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
|
2021-12-21 04:57:29 +00:00
|
|
|
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
|
|
|
player.getInventory().remove(itm);
|
|
|
|
player.updateInventory();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Integer slot = null;
|
2022-01-01 02:40:54 +00:00
|
|
|
if (SelectConfig.UseItem_InventorySlotEnforce) {
|
2021-12-21 04:57:29 +00:00
|
|
|
slot = SelectConfig.UseItem_InventorySlot;
|
|
|
|
} else {
|
2021-12-29 05:34:29 +00:00
|
|
|
if (Select_Database.selectSlot(player) == null) {
|
|
|
|
slot = SelectConfig.UseItem_InventorySlot;
|
|
|
|
} else {
|
|
|
|
slot = Select_Database.selectSlot(player);
|
|
|
|
}
|
2021-12-21 04:57:29 +00:00
|
|
|
}
|
2022-01-01 02:40:54 +00:00
|
|
|
send.debug(Main.plugin, String.valueOf(slot));
|
2021-12-21 04:57:29 +00:00
|
|
|
if (player.getInventory().getItem(slot - 1) == null) {
|
|
|
|
Select_Database.setItemStatusTrue(player);
|
|
|
|
Give_UseItem.onGive(player);
|
|
|
|
} else {
|
|
|
|
boolean empty = false;
|
|
|
|
for (int i = 0; i < 9; i++) {
|
|
|
|
if (player.getInventory().getItem(i) == null) {
|
|
|
|
empty = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (empty) {
|
|
|
|
Select_Database.setItemStatusTrue(player);
|
|
|
|
Give_UseItem.onGiveADD(player);
|
|
|
|
send.player(player, SelectMessages.ItemON);
|
|
|
|
} else {
|
|
|
|
player.sendMessage(SelectMessages.NoInventorySpace);
|
|
|
|
if (SelectConfig.Sound_NoInventorySpace_Enable && SelectConfig.Sound_Enable) {
|
|
|
|
player.playSound(player.getLocation(), SelectConfig.Sound_NoInventorySpace, 3, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void itemOff(Player player) {
|
|
|
|
Select_Database.setItemStatusFalse(player);
|
|
|
|
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
|
|
|
ItemStack itm = player.getInventory().getItem(iam);
|
|
|
|
if (itm != null) {
|
2021-12-22 19:18:50 +00:00
|
|
|
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
|
2021-12-21 04:57:29 +00:00
|
|
|
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
|
|
|
player.getInventory().remove(itm);
|
|
|
|
player.updateInventory();
|
|
|
|
send.player(player, SelectMessages.ItemOFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void onSetSlot(Player player, Integer setSlot) {
|
|
|
|
if (SelectConfig.UseItem_AllowSetSlot) {
|
|
|
|
if (setSlot < 1) {
|
|
|
|
send.player(player, SelectMessages.ItemSlot_wrongValue);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (setSlot > 9) {
|
|
|
|
send.player(player, SelectMessages.ItemSlot_wrongValue);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ItemStack itm1 = player.getInventory().getItem(setSlot - 1);
|
|
|
|
if (itm1 != null) {
|
2021-12-22 19:18:50 +00:00
|
|
|
if (itm1.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm1.getType() == ItemVersion.getHead()) {
|
2021-12-21 04:57:29 +00:00
|
|
|
if (itm1.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
|
|
|
player.sendMessage(SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(setSlot - 1) != null) {
|
|
|
|
send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
|
|
|
ItemStack itm = player.getInventory().getItem(iam);
|
|
|
|
if (itm != null) {
|
2021-12-22 19:18:50 +00:00
|
|
|
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
|
2021-12-21 04:57:29 +00:00
|
|
|
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
|
|
|
player.getInventory().remove(itm);
|
|
|
|
player.updateInventory();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Select_Database.setSlot(player, setSlot);
|
|
|
|
if (Select_Database.selectItemStatus(player)) {
|
|
|
|
Give_UseItem.onGive(player);
|
|
|
|
}
|
|
|
|
send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString()));
|
2022-01-01 02:40:54 +00:00
|
|
|
} else player.sendMessage(Util.getPrefix() + " §4Function disabled");
|
2021-12-21 04:57:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void gui(Player player) {
|
|
|
|
if (Main.guiHashMap.containsKey(SelectConfig.DefaultGUI)) {
|
|
|
|
Object gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
|
|
|
|
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
|
|
|
|
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
|
|
|
|
OpenGUI.openGUI(player, gui, SelectConfig.DefaultGUI);
|
|
|
|
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
|
|
|
|
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
|
|
|
|
}
|
|
|
|
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui")
|
|
|
|
.replace("[perm]", "commandgui.command"));
|
|
|
|
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name));
|
|
|
|
}
|
|
|
|
}
|
2022-01-01 02:40:54 +00:00
|
|
|
|
|
|
|
public static void gui(Player player, String arg) {
|
2021-12-21 04:57:29 +00:00
|
|
|
if (Main.guiHashMap.containsKey(arg)) {
|
|
|
|
Object gui = Main.guiHashMap.get(arg);
|
|
|
|
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
|
|
|
|
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) {
|
|
|
|
OpenGUI.openGUI(player, gui, arg);
|
|
|
|
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
|
|
|
|
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
|
|
|
|
}
|
|
|
|
} else player.sendMessage(SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.Command_Command)
|
|
|
|
.replace("[perm]", "commandgui.command." + arg.toLowerCase()));
|
|
|
|
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.Command_Command));
|
|
|
|
} else player.sendMessage(SelectMessages.GUInotFound);
|
|
|
|
}
|
|
|
|
}
|