Solved The method getAction() is undefined for the type PlayerInteractEvent

Discussion in 'Plugin Development' started by GamerzKing, Dec 5, 2015.

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

    GamerzKing

    Hey guys! I just got an error, that I have never gotten before, and I have no clue why. I am trying to create a normal PlayerInteractEvent, but when I do, it gives me an error. I have tried copy pasting the codes from other class files of mine that actually work, however for some reason, it continues to throw me errors, and I was wondering if anyone had any idea why.

    Code:

    Code:
    package com.GamerzKing.build.events;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    
    import com.GamerzKing.build.core.Main;
    
    public class PlayerInteractEvent implements Listener {
    
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event) {
    
            Player player = event.getPlayer();
            Action action = event.getAction();
    
            if (player.getInventory().getItemInHand().getType().equals(Material.NETHER_STAR)) {
                if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
                   
                   
                }
            }
        }
    }
    Image:
    [​IMG]
     
  2. You called your class for PlayerInteractEvent. That's kinda stupid :) but if you want to keep that, then you need to prefix the argument of the method with the package for the bukkit event.
    Code:
     @EventHandler
        public void onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event)
     
    EmeraldRailsMC likes this.
Thread Status:
Not open for further replies.

Share This Page