2021-12-21 04:57:29 +00:00
|
|
|
package de.jatitv.commandguiv2.Spigot.cmdManagement.register;
|
|
|
|
|
|
|
|
|
|
|
|
import de.jatitv.commandguiv2.Spigot.Main;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
|
2022-01-06 01:21:27 +00:00
|
|
|
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
|
|
|
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
2021-12-21 04:57:29 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
public class RegisterCommand extends Command {
|
|
|
|
private String alias;
|
|
|
|
|
|
|
|
public RegisterCommand(String alias) {
|
|
|
|
super(alias);
|
|
|
|
this.alias = alias;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
|
|
|
|
|
|
|
if (sender instanceof Player) {
|
|
|
|
Player player = (Player) sender;
|
|
|
|
Object gui = Main.guiHashMap.get(alias);
|
|
|
|
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
|
|
|
|
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) {
|
|
|
|
OpenGUI.openGUI(player, gui, alias);
|
|
|
|
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 " + alias)
|
|
|
|
.replace("[perm]", "commandgui.command." + alias));
|
|
|
|
} else player.sendMessage(SelectMessages.GUIIsDisabled.replace("[gui]", gui.GUI_Name));
|
|
|
|
} else sender.sendMessage("§8[§6Command§9GUI§8] §cThis command is only for players!");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|