From 1b98a65869ffddd13e3f4ee3e8b489e8599dfd37 Mon Sep 17 00:00:00 2001 From: TheMode Date: Tue, 13 Apr 2021 02:08:09 +0200 Subject: [PATCH] Get entities from all instances when none is specified in an entity query --- .../minestom/server/utils/entity/EntityFinder.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minestom/server/utils/entity/EntityFinder.java b/src/main/java/net/minestom/server/utils/entity/EntityFinder.java index 0a2452a19..8dc9daf60 100644 --- a/src/main/java/net/minestom/server/utils/entity/EntityFinder.java +++ b/src/main/java/net/minestom/server/utils/entity/EntityFinder.java @@ -363,7 +363,17 @@ public class EntityFinder { return new ArrayList<>(instance != null ? instance.getPlayers() : MinecraftServer.getConnectionManager().getOnlinePlayers()); } else if (targetSelector == TargetSelector.ALL_ENTITIES) { - return new ArrayList<>(instance.getEntities()); + if (instance != null) { + return new ArrayList<>(instance.getEntities()); + } else { + // Get entities from every instance + var instances = MinecraftServer.getInstanceManager().getInstances(); + List entities = new LinkedList<>(); + for (Instance inst : instances) { + entities.addAll(inst.getEntities()); + } + return entities; + } } else if (targetSelector == TargetSelector.SELF) { return Collections.singletonList(self); }