Why does this not detect activity?

Discussion in 'Plugin Development' started by OnePoundPiglet, Apr 9, 2016.

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

    OnePoundPiglet

    So basically I have this individual void in my main class for the plugin - I am not using multiple classes yet, I'm new and I'm still learning. But either way, I should still be able to check for an activity in the main class.
    Here is my void for the player event:

    Code:
        @EventHandler
        public void onPlayerEvent(PlayerInteractEvent event){
            Player player = event.getPlayer();
            if(player.getItemInHand().equals(stack)){
                if(event.getAction() == org.bukkit.event.block.Action.LEFT_CLICK_BLOCK){
                    Location pos1 = event.getClickedBlock().getLocation();
                    String location = pos1.toString();
                    FileConfiguration config = this.getConfig();
                    config.set(arenaname + "Pos1:", location);
                    saveConfig();
                    player.sendMessage(ChatColor.GREEN + "Position 1 successfully set!");
                }
                else if (event.getAction()== org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK){
                    Location pos2 = event.getClickedBlock().getLocation();
                    String location = pos2.toString();
                    FileConfiguration config = this.getConfig();
                    config.set(arenaname + "Pos2:", location);
                    saveConfig();
                    player.sendMessage(ChatColor.GREEN + "Position 2 successfully set!");                           
                }
            }
            player.sendMessage("Detects Activity");
        }
    Basically, when left or right clicking with the item "stack", a blaze rod that is given by another part of the code upon a command (the item stack also has its meta defined globally so there is no problem there) I get no response. It should detect me left/right clicking a block with the blaze rod and get the coordinates of the block and save it to the config, but it doesn't even detect any activity.
    I know it detects no activity because I have a line sending the player a message to see if ANY ACTIVITY AT ALL was detected and no message is received.

    Whats wrong with the code? Any help appreciated :)

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Apr 10, 2016
  2. Online

    timtower Administrator Administrator Moderator

    Moved to plugin development.
    @OnePoundPiglet Did you register the event?
     
  3. Offline

    MasterDoctor

    Did you add
    Code:
    implements Listener
    after
    Code:
    extends JavaPlugin
    ?
     
  4. Offline

    mcdorli

    That's not a void, it's a method wich doesn't return anything.
     
    MasterDoctor likes this.
Thread Status:
Not open for further replies.

Share This Page