Skip to content

Commit

Permalink
Clear the tree instead of creating new ones
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Dec 20, 2022
1 parent 3ce4c54 commit d819ae9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/net/citizensnpcs/api/LocationLookup.java
Expand Up @@ -26,13 +26,12 @@ public Iterable<Player> getNearbyPlayers(Location base, double dist) {

@Override
public void run() {
worlds.clear();
for (World world : Bukkit.getServer().getWorlds()) {
List<Player> players = world.getPlayers();
if (players.isEmpty())
continue;
PhTreeF<Player> tree = PhTreeF.create(3);
worlds.put(world.getUID(), tree);
PhTreeF<Player> tree = worlds.computeIfAbsent(world.getUID(), uid -> PhTreeF.create(3));
tree.clear();
Location loc = new Location(null, 0, 0, 0);
for (Player player : players) {
if (player.hasMetadata("NPC"))
Expand Down

0 comments on commit d819ae9

Please sign in to comment.