Interact on a player HELP (newbie java question)

Discussion in 'Plugin Development' started by 1sasafras1, Feb 25, 2014.

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

    1sasafras1

    Right now I have
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent event){
    3. if(event.isCancelled())
    4. return;
    5. if(!event.getPlayer().hasPermission("cop.drunktest"))
    6. return;
    7. if(!event.getAction().equals(Action.))

    I am having the problem at (Action.<Idk>) because I want the event to return if the player does not right click on a player what is the thingy (sorry I don't know what its called a method or something) I know there is a
    Code:java
    1. (Action.RIGHT_CLICK_BLOCK)
    but is there a
    Code:java
    1. RIGHT_CLICK_PLAYER
    or something


    (I am extremely sorry for anyone trying to help me. I am new at plugins[and sort of new at java] and am looking to start doing some more. )
     
  2. Offline

    Konkz

    If you're checking if they clicked an entity (Entities are mobs & players) you'd have to use PlayerInteractEntityEvent and make your code similar to this:

    Code:
     @EventHandler
        public void PlayerRightClick(PlayerInteractEntityEvent event) {
            if(event.getRightClicked() instanceof Player){
                Entity entity = event.getRightClicked(); {
                        //code
                }
          }
    }
    ^ raw on phone code, may contain mistakes.
     
    1sasafras1 likes this.
  3. Offline

    1sasafras1

    Thanks bro your amazing :)
     
    Konkz likes this.
Thread Status:
Not open for further replies.

Share This Page