diff --git a/src/main/java/com/lovetropics/extras/collectible/CollectibleCommand.java b/src/main/java/com/lovetropics/extras/collectible/CollectibleCommand.java index e7cd862..5bcab99 100644 --- a/src/main/java/com/lovetropics/extras/collectible/CollectibleCommand.java +++ b/src/main/java/com/lovetropics/extras/collectible/CollectibleCommand.java @@ -92,9 +92,12 @@ public static void register(CommandDispatcher dispatcher, Co .then(literal("countdisguises").executes(CollectibleCommand::countDisguises)) .then(literal("find") .executes(context -> findCollectibles(context.getSource(), stack -> true)) + .then(argument("collectible", resourceOrTag(buildContext, ExtraRegistries.COLLECTIBLE)) + .executes(context -> findCollectibles(context.getSource(), getResourceOrTag(context, "collectible", ExtraRegistries.COLLECTIBLE))) + ) .then(literal("item") .then(argument("item", itemPredicate(buildContext)) - .executes(context -> findCollectibles(context.getSource(), getItemPredicate(context, "item"))) + .executes(context -> findCollectibles(context.getSource(), itemToCollectiblePredicate(getItemPredicate(context, "item")))) ) ) ) @@ -224,10 +227,10 @@ private static int setLocked(CommandContext context, boolean return 1; } - private static int findCollectibles(CommandSourceStack source, Predicate item) { + private static int findCollectibles(CommandSourceStack source, Predicate> predicate) { MinecraftServer server = source.getServer(); GameProfileCache profileCache = server.getProfileCache(); - CollectibleLister.listPlayersWithItem(server, item) + CollectibleLister.listPlayersWithItem(server, predicate) .thenApplyAsync( profileIds -> profileIds.stream().map(profileCache::get).flatMap(Optional::stream).toList(), Util.backgroundExecutor() diff --git a/src/main/java/com/lovetropics/extras/collectible/CollectibleLister.java b/src/main/java/com/lovetropics/extras/collectible/CollectibleLister.java index c5d99c1..3baab84 100644 --- a/src/main/java/com/lovetropics/extras/collectible/CollectibleLister.java +++ b/src/main/java/com/lovetropics/extras/collectible/CollectibleLister.java @@ -35,13 +35,12 @@ public class CollectibleLister { private static final String PLAYER_DATA_SUFFIX = ".dat"; private static final Logger LOGGER = LogUtils.getLogger(); - public static CompletableFuture> listPlayersWithItem(MinecraftServer server, Predicate item) { + public static CompletableFuture> listPlayersWithItem(MinecraftServer server, Predicate> predicate) { return list(server).thenApplyAsync(entries -> { List profileIds = new ArrayList<>(); for (CollectibleLister.Entry entry : entries) { for (Holder collectible : entry.data().collectibles()) { - ItemStack stack = Collectible.createItemStack(collectible, entry.profileId()); - if (item.test(stack)) { + if (predicate.test(collectible)) { profileIds.add(entry.profileId()); } }