From befa81f902ddf5cb22bcb2c7bcf7dd9bcf2a4896 Mon Sep 17 00:00:00 2001 From: Shane Bee Date: Mon, 1 Jul 2024 13:04:49 -0700 Subject: [PATCH] RegistryParser - strip out minecraft namespaces from docs (#6844) * RegistryParser - strip out minecraft namespaces from docs * RegistryParser - Stream#toList() not available on older java versions --------- Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> --- .../java/ch/njol/skript/classes/data/BukkitClasses.java | 9 ++++++--- .../ch/njol/skript/classes/registry/RegistryParser.java | 6 ++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java b/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java index 7ff72f27e69..b48c69149d7 100644 --- a/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java +++ b/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java @@ -990,7 +990,8 @@ public String toVariableNameString(final ItemStack i) { Classes.registerClass(biomeClassInfo .user("biomes?") .name("Biome") - .description("All possible biomes Minecraft uses to generate a world.") + .description("All possible biomes Minecraft uses to generate a world.", + "NOTE: Minecraft namespaces are supported, ex: 'minecraft:basalt_deltas'.") .examples("biome at the player is desert") .since("1.4.4") .after("damagecause")); @@ -1465,7 +1466,8 @@ public String toVariableNameString(FireworkEffect effect) { Classes.registerClass(catTypeClassInfo .user("cat ?(type|race)s?") .name("Cat Type") - .description("Represents the race/type of a cat entity.") + .description("Represents the race/type of a cat entity.", + "NOTE: Minecraft namespaces are supported, ex: 'minecraft:british_shorthair'.") .since("2.4") .requiredPlugins("Minecraft 1.14 or newer") .documentationId("CatType")); @@ -1533,7 +1535,8 @@ public String toVariableNameString(EnchantmentOffer eo) { .user("attribute ?types?") .name("Attribute Type") .description("Represents the type of an attribute. Note that this type does not contain any numerical values." - + "See attribute types for more info.") + + "See attribute types for more info.", + "NOTE: Minecraft namespaces are supported, ex: 'minecraft:generic.attack_damage'.") .since("2.5")); Classes.registerClass(new EnumClassInfo<>(Environment.class, "environment", "environments") diff --git a/src/main/java/ch/njol/skript/classes/registry/RegistryParser.java b/src/main/java/ch/njol/skript/classes/registry/RegistryParser.java index 51cb4637434..dc9bf9f00b7 100644 --- a/src/main/java/ch/njol/skript/classes/registry/RegistryParser.java +++ b/src/main/java/ch/njol/skript/classes/registry/RegistryParser.java @@ -30,12 +30,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.stream.Collectors; /** * A parser based on a {@link Registry} used to parse data from a string or turn data into a string. @@ -147,8 +146,7 @@ private void refresh() { * Note that some entries may represent the same registry object. */ public String getAllNames() { - List strings = new ArrayList<>(parseMap.keySet()); - Collections.sort(strings); + List strings = parseMap.keySet().stream().filter(s -> !s.startsWith("minecraft:")).sorted().collect(Collectors.toList()); return StringUtils.join(strings, ", "); }