View item in gui

Discussion in 'Plugin Development' started by TwinedBroom, Jun 9, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    TwinedBroom

    Hi! I have this code, but can someone help me changing something?

    When the player takes the command, he/she opens a GUI with items, but he/she can get the items, how can i disable to give the item, just viewing them?

    The code i have now: http://hastebin.com/idorebucec.avrasm
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    TwinedBroom

    This one?
    ItemMeta meta1 = i1.getItemMeta();
     
  4. Offline

    Caedus

    No, you want to listen for InventoryInteractEvent and cancel it if the inventory name equals the name of your GUI.

    Also, you don't need your onDisable(), and you don't need to log that the plugin has started in onEnable(), bukkit does this automatically.

    You also want to return true at the end of the "kit" command, else it will show in chat that you typed "/kit"

    Also don't name your class "main", this can cause problems I believe.

    Also what's this?
    Code:
    public ItemStack itemlayout(Material)public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
     
  5. Offline

    TwinedBroom

  6. Offline

    timtower Administrator Administrator Moderator

    @TwinedBroom You add a listener for InventoryInteractEvent, you check if it is your inventory, if so: cancel it.
     
Thread Status:
Not open for further replies.

Share This Page