Player Listener Won't Work!

Discussion in 'Bukkit Help' started by Lawton, Jun 15, 2013.

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

    Lawton

    So I am trying to make an event happen when a player uses an item

    Code for when the player interacts with blocks:
    Code:java
    1. @EventHandler(priority=EventPriority.HIGH)
    2. public void onPlayerUse(PlayerInteractEvent event){
    3. Player p = event.getPlayer();
    4. if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    5. event.getClickedBlock();
    6. if(event.getClickedBlock().equals(Material.EMERALD_BLOCK)){
    7. p.playSound(p.getLocation(), Sound.IRONGOLEM_HIT, 7, 12);
    8. p.sendMessage(ChatColor.GREEN + "Success!");
    9. }



    and for when the player interacts with items::
    Code:java
    1. if(p.getItemInHand().getType() == Material.BLAZE_POWDER){
    2. Fireball fire = p.getWorld().spawn(event.getPlayer().getLocation(), Fireball.class);
    3. fire.setShooter(p);
    4. }



    It would be much appreciated if you guys could help me make this work :)
     
Thread Status:
Not open for further replies.

Share This Page