filter npcs in same world only for near command. fixes #69
This commit is contained in:
parent
43376c2732
commit
b3475db944
1 changed files with 4 additions and 3 deletions
|
@ -25,9 +25,10 @@ public class NearCommand implements CommandHandler {
|
||||||
double radius = Math.pow(raw, 2);
|
double radius = Math.pow(raw, 2);
|
||||||
|
|
||||||
String npcs = npcRegistry.getAllModifiable().stream()
|
String npcs = npcRegistry.getAllModifiable().stream()
|
||||||
.filter(entry -> entry.getNpc().getBukkitLocation().distanceSquared(player.getLocation()) < radius)
|
.filter(entry -> entry.getNpc().getWorld().equals(player.getWorld()))
|
||||||
.map(NpcEntryImpl::getId)
|
.filter(entry -> entry.getNpc().getBukkitLocation().distanceSquared(player.getLocation()) < radius)
|
||||||
.collect(Collectors.joining(", "));
|
.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));
|
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()
|
context.send(Component.text("All NPCs that are within " + raw + " blocks from you:", NamedTextColor.GREEN).appendNewline()
|
||||||
|
|
Loading…
Reference in a new issue