Solved How do i check if there is a player at a location

Discussion in 'Plugin Development' started by Duuckky, May 14, 2014.

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

    Duuckky

    I've added all the locations to an ArrayList called arenaArea which is working fine, then I try to check if a player is at one of the locations in arenaArea, I'm using this to check:

    Code:
    if(plugin.arenaArea.contains(player.getLocation())) {
         plugin.m.sendMessage(player, "You are in the arena.");
    }
    can't seem to find the problem.
     
  2. Offline

    Jaaakee224

    Duuckky
    Since you are using an ArrayList, why not add the player to the ArrayList when the join the arena, and remove them from the ArrayList when the leave the arena.

    And then, to tell if they are in the arena, just check if they are in the ArrayList.
     
  3. Offline

    Duuckky

    Yes, I am using an ArrayList to check the players in the area, but I'm having trouble checking when they walk into the arena
     
  4. Offline

    Jaaakee224

    Duuckky walk into the arena? joining the arena you mean?
     
  5. Offline

    Lecrayen

    You could always use the PlayerMoveEvent
     
  6. Offline

    Duuckky

    Okay, so what I'm doing is creating a plugin that randomly selects a region on the map, then broadcasts it to all the players. Then after 10 minutes a battle starts at that location, to join the battle you just walk into it. I don't have a command like /join <arena name>

    That code I posted is in a PlayerMoveEvent but it still isn't adding the player.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  7. Offline

    Lecrayen

    Is your event listener registered in your plugin's main class?
     
  8. Offline

    Duuckky

    Yes, kk so just ignore all the other things I've said, all I need to know is how to check if I'm at a location. When i have the location save in an arrayList

    Nvm solved it

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
Thread Status:
Not open for further replies.

Share This Page