How to check players in specify radius

Discussion in 'Spigot Plugin Help' started by F1xer, Jun 6, 2017.

  1. I looking for plugin, or something which can help me define how many players are in cartain radius around another player.
     
  2. getNearbyEntities(x y z) then check if its a player
     
  3. Sad, but i don't know how to code :[

    Maybe there are existing something like plugin, which can transfer a placeholder with "players in radius" value, and supported by PlaceholderAPI ??
     
  4. Code (Text):
            int players = 0;
           
            List<Entity> entities = player.getNearbyEntities(20,20,20);
           
            //Iterate through the list and check if the entity is a player
            for(Entity entity : entities) {
                if(entity instanceof Player) {
                    players++;
                }
            }
    This little code should say everything.
    You get a List<Entity> and then you can do what you want with it.
    In this case i checked how many entites in this list are instance of Player.

    I hope I could help you :)
     
  5. He said he cant code ;/
     
    • Agree Agree x 1
  6. Is it hard to start code feature, like this ??
     
  7. What exactly are you planning on doing with it?

    Are you just trying to make a command where it will show you the players within a given radius? If so, Essentials has that command. (/near)
     
  8. command "/near" plugins : Essentials
     
  9. Sorry, I thought he doesn't know how to code that with the getNearbyEntities method
     
  10. '/Near' is not exactly what i need.

    I try to explain:
    There is one plugin, which i use - called ReActions This plugin have basic logical operators (IF(or, and), THEN, ELSE...) so u can setup the special conditions in this plugin, in which will be perform corresponding action. (if:1 - then:X. if:2 - then:Y. Else:Q)
    I hope somehow to get value about amount of players in certain radius around another player (or just: yes/no players around)... And the transfer this value to ReActions condition. But dont know how to get, and dont know how to transfer (maybe from MySQL, or as a placeholder, is there existing plugin which can check players around and which supported the PlaceholderAPI).