Solved What am I doing wrong?

Discussion in 'Plugin Development' started by coldguy101, Nov 24, 2013.

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

    coldguy101

    Code:java
    1.  
    2. import java.util.List;
    3.  
    4. import org.bukkit.Material;
    5. import org.bukkit.entity.Damageable;
    6. import org.bukkit.entity.Entity;
    7. import org.bukkit.entity.Fireball;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.EventPriority;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.event.block.Action;
    13. import org.bukkit.event.player.PlayerInteractEvent;
    14. import org.bukkit.util.Vector;
    15.  
    16. public class KitPerkListener implements Listener
    17. {
    18. @EventHandler(priority = EventPriority.NORMAL)
    19. public void playerRightClick(PlayerInteractEvent event)
    20. {
    21. if(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
    22. {
    23. Player p = event.getPlayer();
    24.  
    25. if(p.getItemInHand().getType().equals(Material.FIREBALL));
    26. {
    27. Fireball fb = p.launchProjectile(Fireball.class);
    28. fb.setIsIncendiary(true);
    29. // if(p.getInventory().getItemInHand().getAmount() == 1)
    30. // p.getInventory().remove(p.getInventory().getItemInHand()); //TODO MAKE ITEM DISAPPEAR
    31.  
    32. //return;
    33. }
    34. else if(p.getItemInHand().getType().equals(Material.BLAZE_ROD) && KitManager.getKit(p, (byte) 1).equalsIgnoreCase("wizard"))
    35. {
    36. List<Entity> nearby = p.getNearbyEntities(3,3,3);
    37. for (Entity tmp: nearby)
    38. if (tmp instanceof Damageable)
    39. tmp.setVelocity(new Vector(0, 2, 0));
    40. //return;
    41.  
    42. }
    43. }
    44. }
    45. }
    46.  


    When I do that example above, eclipse says p cannot be resolved. When I take out the else, it works.... Somewhat. (It always launches fireballs). When I take out the else and put the return eclipse says that the second if statement is unreachable. Not sure what I'm doing wrong... Could just be because it's late but I figured maybe someone smarter and in a different timezone than I could help. Thanks for your assistance!
     
  2. Offline

    1Rogue

    Remove the semicolon from your if statement:
    Code:java
    1. if(p.getItemInHand().getType().equals(Material.FIREBALL));
     
  3. Offline

    coldguy101


    WOW... TIME TO GO TO BED. Thanks
     
Thread Status:
Not open for further replies.

Share This Page