dokato Posted April 3, 2015 Posted April 3, 2015 (edited) Is it possible to determin wether ANOTHER player (someone you dont know the name of) is in a certain area with like a boolean? (for example the area where u are in). Is there a method for that or do u have to create something urself? for example: final Area YOUR_AREA = new Area(bla,bla,bla,bla); if(YOUR_AREA.contains(/*a player*/)){ //... } Edited April 3, 2015 by dokato
Precise Posted April 3, 2015 Posted April 3, 2015 Is it possible to determin wether another player is in a certain area with like a boolean? (for example the area where u are in). Is there a method for that or do u have to create something urself? for example: final Area YOUR_AREA = new Area(bla,bla,bla,bla); if(YOUR_AREA.contains(/*a player*/)){ //... } yes you can
dokato Posted April 3, 2015 Author Posted April 3, 2015 yes you can fuck Obama But i can't, plz tell me how then spoonfeed me a bit
FrostBug Posted April 3, 2015 Posted April 3, 2015 (edited) Player otherPlayer = getPlayers().closest("OtherPlayerName"); if(YOUR_AREA.contains(otherPlayer.getPosition()) { //Interesting things happen } EDIT: to get a list of players in your area, you can do: List<Player> playersInArea = getPlayers().filter(new AreaFilter<Player>(YOUR_AREA)); Edited April 3, 2015 by FrostBug 2
Precise Posted April 3, 2015 Posted April 3, 2015 fuck Obama But i can't, plz tell me how then spoonfeed me a bit Player otherPlayer = getPlayers().closest("OtherPlayerName"); if(YOUR_AREA.contains(otherPlayer.getPosition()) { //Interesting things happen } EDIT: to get a list of players in your area, you can do: List<Player> playersInArea = getPlayers().filter(new AreaFilter<Player>(YOUR_AREA)); what Frostbug said ^_^ i forgot to post code lmao xD 1
dokato Posted April 3, 2015 Author Posted April 3, 2015 (edited) Ow sry my bad, i meant if that player is a random player who u dont know the name of, but just happens to be in that area. What to do then? Edited April 3, 2015 by dokato
Precise Posted April 3, 2015 Posted April 3, 2015 Ow sry my bad, i meant if that player is a random player who u dont know the name of, but just happens to be in that area. What to do then? like frostbug said: List<Player> playersInArea = getPlayers().filter(new AreaFilter<Player>(YOUR_AREA)); this will return a list of all the players in the area. 1
Joseph Posted April 3, 2015 Posted April 3, 2015 Ow sry my bad, i meant if that player is a random player who u dont know the name of, but just happens to be in that area. What to do then? you create the list and do a simple list#isEmpty() boolean check. empty == what you want 1
7331337 Posted April 3, 2015 Posted April 3, 2015 if (boatArea.contains(myPlayer().getPosition())){ //dostuff } 1