Replacing Items in Inventory.

Discussion in 'Plugin Development' started by Digbywood, Jan 15, 2015.

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

    Digbywood

    Hey I'm having trouble with my code. I want it to replace the item that the player clicked on with the original Item so it will never run out. Here is my code:
    Code:
    @EventHandler
        public void itemInteract(InventoryClickEvent event){
            if(event.getInventory().getTitle().equals(BuildingTools.NAME_SUCCESS)){
                Bukkit.broadcastMessage("WORKED");
                Bukkit.broadcastMessage(event.getSlot() + "");
                event.getInventory().setItem(event.getSlot(), event.getCurrentItem());
            }
        }
    The 2 Bukkit.broardcastMessages() I have is for debugging. It works up until replacing it; I use Bukkit.createInventory for a gui and I set the title to BuildingTools.NAME_SUCCESS, then I open it in game and when click on the item it will say 'WORKED' in chat along with the slot number but it won't replace it back.
    Any Help please?
     
  2. Offline

    PreFiXAUT

    @Digbywood Sorry, I'ld really like to help you, but I realy dont get it what you want to do, maybe I'm just retarded but that doesn't give allot of info.
     
  3. Offline

    Digbywood

    Oh Okay sorry @PreFiXAUT basically what I want to happen is when I take out an item in my gui I created, I want it to let the user take the item out and put it in their inventory but replace the item in the gui back to the item they took sort of like how to take out an item in the Creative Inventory. Hope that helps :D
     
Thread Status:
Not open for further replies.

Share This Page