Inventory

Discussion in 'Plugin Development' started by Echo, Oct 6, 2014.

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

    Echo

    Hey, I'm trying to make it say something when I click a block in the inventory.

    Code:java
    1. @EventHandler
    2. public void onInventoryClick(InventoryClickEvent event){
    3. if(event.getInventory().getName().equalsIgnoreCase("This_Inventory")){
    4. if(event.getCurrentItem().getType().equals(Material.DIRT)){
    5. event.setCancelled(true);
    6. event.getWhoClicked().closeInventory();
    7. Player p = (Player)event.getWhoClicked();
    8. p.sendMessage("§a§oWOOP! IT WORKS!");
    9. if(event.getSlot() == 1){
    10. event.getWhoClicked().getInventory().addItem(new ItemStack(Material.CHEST));
    11. event.setCancelled(true);
    12. event.getWhoClicked().closeInventory();


    Does anybody know why this dosen't work?
     
  2. Offline

    SmooshCakez

    Registered your listeners?
     
  3. Offline

    Echo

    Yup
    Code:java
    1. getServer().getPluginManager().registerEvents(this, this);
     
  4. Offline

    fireblast709

    Echo have you debugged your code? I.e. checked the inventory name?
     
  5. Online

    CraftCreeper6

    Echo
    You do know that get clicked slot one will return the second slot?
     
  6. Offline

    Echo

    Uhh fairly new to this:p. Sorry if this comes across rude, but would you be able to give examples please?:)
     
  7. Offline

    MordorKing78

    What are you trying to make? If a guy/girly Right-Clicks. Or clicks in his inventory ("E").
     
  8. Offline

    ChipDev

    Do you Have any Errors?
     
  9. Offline

    Echo

    No errors, just returns the command. Eg /ef. I'm trying to make it output that simple message when they click the block.
     
Thread Status:
Not open for further replies.

Share This Page