Solved How to fix my code for inventory menu.

Discussion in 'Plugin Development' started by euller12, Jan 5, 2014.

?

How to fix my code for inventory menu.

  1. How to fix it

    0 vote(s)
    0.0%
  2. Can fix it

    1 vote(s)
    100.0%
Thread Status:
Not open for further replies.
  1. Offline

    euller12

    When ever I click on the block it doesn't work. I can take the block also.

    Code:java
    1. @EventHandler
    2. public void onInventoryClick(InventoryClickEvent e){
    3.  
    4. ItemStack comp = new ItemStack(Material.NETHER_STAR);
    5.  
    6. if (!e.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
    7. if (e.getCurrentItem().getType() != null){
    8. return;
    9. }
    10. if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Vote")) {
    11. e.setCancelled(true);
    12. e.getWhoClicked().damage(1);
    13. e.getWhoClicked().closeInventory();
    14. //e.getWhoClicked().openInventory(vote);
    15. }
    16. }
     
  2. Offline

    Derpiee

    I'm going to assume it's because
    Code:java
    1.  
    2. if (e.getCurrentItem().getType() != null){
    3. return;
    4. }
    5.  

    Are you sure you don't mean
    Code:java
    1.  
    2. if (e.getCurrentItem().getType() == null){
    3. return;
    4. }
    5.  
     
  3. Offline

    Xephiro

    How have a little problem.

    Code:java
    1. if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Vote")) {
    2. e.setCancelled(true);
    3. e.getWhoClicked().damage(1);
    4. e.getWhoClicked().closeInventory();
    5. //e.getWhoClicked().openInventory(vote);
    6. }

    This condition never enter because...

    Code:java
    1. if (e.getCurrentItem().getType() != null){
    2. return;
    3. }

    This condition es allways accepted.

    If i'm not wrong all the items have a type.
     
  4. Offline

    leimekiller

    Registered events?
     
  5. Offline

    euller12

    ?

    Xephiro thanks it worked!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page