Solved Why this no work :(

Discussion in 'Plugin Development' started by vhbob, Dec 4, 2015.

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

    vhbob

    Hello again hahaha..... i made this code that is supposed to not allow you to take items out of a certain inventory but it wont work, please tell me what is wrong ;( code:
    Code:
    public void onInventoryClick(InventoryClickEvent e) {
            if (e.getWhoClicked() instanceof Player) {
                if(e.getInventory().getTitle().contains("shop")) {
                    e.setCancelled(true);
                }
            }
        }
     
  2. Offline

    TheNewTao

    try using getName().equals("something") instead of that.
     
  3. Offline

    mcdorli

    Please, tell me one occasion, where a zombie clicks an item inside a chest.
    Please create a picture of the inventory
     
  4. Offline

    vhbob

    @mcdorli thanks for the input xD heres the inv http://imgur.com/6KXusv1

    @mcdorli @TheNewTao this is my code and is still dont work:
    Code:
    public void onInvClick(InventoryClickEvent e) {
                if(e.getInventory().getName().equalsIgnoreCase("Shop")) {
                    e.setCancelled(true);
                }
            }
     
    Last edited by a moderator: Dec 4, 2015
  5. Offline

    mcdorli

    The first code wasn't actually wrong, you just wrote "shop" instead of "Shop", try chagning that.
     
  6. Offline

    vhbob

    @mcdorli this still dont work >:\
    Code:
    public void onInventoryClick(InventoryClickEvent e) {
                if(e.getInventory().getTitle().contains("Shop")) {
                    e.setCancelled(true);
                }
        }
     
  7. Offline

    mcdorli

    Just a wild guess, bit do you register the event amd do you have the @EventHandler right vefore that?
     
  8. Offline

    vhbob

    @mcdorli omg im soo stupid, i didnt put the @eventhandler :mad:
     
  9. Offline

    mcdorli

    Mark the thread as solved. No problem man, a lot of people do that.
     
  10. Offline

    vhbob

Thread Status:
Not open for further replies.

Share This Page