From 6fce004fa246cb984c2c491579838b2d25316504 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sun, 17 Feb 2019 12:55:01 +1000 Subject: [PATCH] Added a method to get a list of tags --- .../org/bukkit/craftbukkit/CraftServer.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index ba8fd38926..0e1fc8fc09 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1868,6 +1868,25 @@ public final class CraftServer implements Server { } } + @Override + @SuppressWarnings("unchecked") + public Iterable> getTags(String registry, Class clazz) { + switch (registry) { + case org.bukkit.Tag.REGISTRY_BLOCKS: + Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type"); + + TagsServer blockTags = console.getTagRegistry().a(); // PAIL: getBlockTags + return blockTags.c().keySet().stream().map(key -> (org.bukkit.Tag) new CraftBlockTag(blockTags, key)).collect(ImmutableList.toImmutableList()); + case org.bukkit.Tag.REGISTRY_ITEMS: + Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type"); + + TagsServer itemTags = console.getTagRegistry().b(); // PAIL: getItemTags + return itemTags.c().keySet().stream().map(key -> (org.bukkit.Tag) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList()); + default: + throw new IllegalArgumentException(); + } + } + public LootTable getLootTable(NamespacedKey key) { Validate.notNull(key, "NamespacedKey cannot be null");