From b3475db94424185ed26bc0e9e08f782fc9d2e134 Mon Sep 17 00:00:00 2001 From: D3v1s0m <49519439+D3v1s0m@users.noreply.github.com> Date: Sun, 2 Jul 2023 15:35:36 +0530 Subject: [PATCH] filter npcs in same world only for near command. fixes #69 --- .../main/java/lol/pyr/znpcsplus/commands/NearCommand.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/commands/NearCommand.java b/plugin/src/main/java/lol/pyr/znpcsplus/commands/NearCommand.java index 863e8a8..f9588cc 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/commands/NearCommand.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/commands/NearCommand.java @@ -25,9 +25,10 @@ public class NearCommand implements CommandHandler { double radius = Math.pow(raw, 2); String npcs = npcRegistry.getAllModifiable().stream() - .filter(entry -> entry.getNpc().getBukkitLocation().distanceSquared(player.getLocation()) < radius) - .map(NpcEntryImpl::getId) - .collect(Collectors.joining(", ")); + .filter(entry -> entry.getNpc().getWorld().equals(player.getWorld())) + .filter(entry -> entry.getNpc().getBukkitLocation().distanceSquared(player.getLocation()) < radius) + .map(NpcEntryImpl::getId) + .collect(Collectors.joining(", ")); if (npcs.length() == 0) context.halt(Component.text("There are no npcs within " + raw + " blocks around you.", NamedTextColor.RED)); context.send(Component.text("All NPCs that are within " + raw + " blocks from you:", NamedTextColor.GREEN).appendNewline()