[SIMPLEQUESTION] How to get "player" resolved?

Discussion in 'Plugin Development' started by Yudaz, Jan 19, 2012.

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

    Yudaz

    Question is in the topic as you've probably seen. My problem is that I want to make an "if" with the enity "player" in. Simple as:
    Code:
    if(player.hasPermission("permission.player"))
    - But the problem here is that I get an error:
    Code:
    player cannot be resolved
    
    So how do I get it work?
     
  2. Offline

    ArcheCane

    You need to define player. Define it by typing Player player = event.getPlayer;
    if you're wanting to use player in a command executor, use Player player = (Player) sender;
     
  3. Offline

    wwsean08

    however if you are doing this in an event where it doesn't have a player (but has an entity) you'll want to do:

    Code:java
    1.  
    2. if(event.getEntity() instanceof Player){
    3. Player player = (Player) event.getEntity();
    4. player.hasPermission("some.permission");
    5. }else{
    6. return;
    7. }
    8.  
     
Thread Status:
Not open for further replies.

Share This Page