How to get nearby entities?

WinnerWinnerTen

New Member
Solved
Code:
Java:
List<Player> nearPlayers = new ArrayList<>();

this.nearPlayers.clear();
            for (Player all : getServer().getOnlinePlayers().values()) {
              if (all.getPosition().distance(new Vector3(p.getX(), p.getY(), p.getZ())) < cfg.getInt("chats.local.radius"))
                this.nearPlayers.add(all);
            }
            String trueMsg = cfg.getString("chats.local.syntax").replace("#msg#", msg).replace("#player#", p.getName());
            for (Player near : this.nearPlayers) {
                near.sendMessage(TextFormat.colorize('&', trueMsg));
            }
 
Top