Solved Bukkit If Statement Problems

Discussion in 'Plugin Development' started by martin0leung, Nov 1, 2014.

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

    martin0leung

    So here's my code:
    Code:java
    1. public void onPlayerInteract(PlayerInteractEvent event) {
    2. if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    3. final Player e = event.getPlayer();
    4. if (event.getItem().getType() == Material.ARROW) {
    5. Function1(e);
    6. }
    7. if (event.getItem().getType() == Material.BONE) {
    8. Function2(e);
    9. }
    10. }

    That doesn't work, I put a send message inside the if statements e.sendMessage("HI") but it doesn't send the message, please help!
     
  2. Offline

    Orange Tabby

    Code:java
    1. if (p.getiteminhand.gettype == material.bone) {
    2. // DO STUFF
    3. }
    4.  

    try
     
  3. Orange Tabby That's basically the same thing except invalid

    martin0leung Try putting a print statement as the first line in the method. If it doesn't print, then your listener isn't being executed. Two common causes include not registering your listener, and forgetting the @EventHandler annotation above the method.
     
  4. Offline

    martin0leung

    AdamQpzm oh... ehh forgot... WATEVER! thanks for reminding me to put that!
    Orange Tabby also thanks for that, (e.getItemInHand().getType() == Material.BONE) works better than before!


    Changed to solved!
     
    Orange Tabby likes this.
  5. Offline

    Orange Tabby

    martin0leung
    ยง1No Problem
    I hope the color coding thing works :)
     
Thread Status:
Not open for further replies.

Share This Page