Solved Gui stuff

Discussion in 'Spigot Plugin Development' started by OfficialAndy, Jun 25, 2016.

  1. Im doing a gui plugin and cant seem to get Player player = (player) sender; to work. Help

    Code (Text):

        public void onInventoryClick(InventoryClickEvent e) {
            Player player = (Player) sender;
            if (!e.getInventory().getName().equalsIgnoreCase(GUI.getName())) return;
            if (e.getCurrentItem().getItemMeta() == null) return;
            if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Spawn")){
    I need player to send a command.
  2. It should be
    Code (Text):
    Player player = (Player) e.getWhoClicked();
    EDIT: for a command to open the gui it would need to be something like:
    Code (Text):
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player player = ((Player) sender);
            if (command.getName().equalsIgnoreCase("thing")) {

            return false;


  3. Code (Text):

    Player player = (Player) sender;
    Is usually used in the onCommand method.
  4. Thanks, please close this :)
  5. You can go to edit title and mark it as solved :)