Discussion in 'Spigot Help' started by Elijah, May 1, 2015.

  1. Hey,
    I am trying to figure out how to use the InventoryClickEvent when a player is in a certain gamemode, like Adventure. Can anyone help?
  2. The InventoryClickEvent is use when you click on you're inventory it's the same for all gamemode but if you want to know the gamemode of player from this event just use getGameMode()

    Code (Text):
    public void Inventoryclick(InventoryClickEvent e)

        Player p = e.getPlayer();
        if(p.getGameMode() == GameMode.CREATIVE)
       //Do some actions
    }else if (p.getGameMode() == GameMode.SURVIVAL){

  3. Ah but thing is I cannot use getPlayer(); it's red when I do it
  4. Call event.getWhoClicked() and cast that to Player.
  5. Hmm I'll try that
  6. event.getPlayer() doesn't even exist for InventoryClickEvent so I don't know why @Cheesypoof said to use that. Just do something like this:
    Code (Text):
    Player player = (Player) event.getWhoClicked();
  7. This should be in Spigot Plugin Development, instead of 'Spigot Help' this is meant for main help using spigot only, not plugins.
  8. @Latouth Yes, sorry well anyways I solved the problem.