Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tag lookup for "skript" and "paper" #7450

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,36 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
String[] names = this.names.getArray(event);
List<Tag<?>> tags = new ArrayList<>();

String namespace = switch (origin) {
case ANY, BUKKIT -> "minecraft";
case PAPER -> "paper";
case SKRIPT -> "skript";
String[] namespaces = switch (origin) {
case ANY -> new String[]{"minecraft", "paper", "skript"};
case BUKKIT -> new String[]{"minecraft"};
case PAPER -> new String[]{"paper"};
case SKRIPT -> new String[]{"skript"};
};

nextName: for (String name : names) {
// get key
NamespacedKey key;
if (name.contains(":")) {
key = NamespacedKey.fromString(name);
} else {
// populate namespace if not provided
key = new NamespacedKey(namespace, name);
}
if (key == null)
continue;
for (String namespace : namespaces) {
if (name.contains(":")) {
key = NamespacedKey.fromString(name);
} else {
// populate namespace if not provided
key = new NamespacedKey(namespace, name);
}
if (key == null)
continue;

Tag<?> tag;
for (TagType<?> type : types) {
tag = TagModule.tagRegistry.getTag(origin, type, key);
if (tag != null
// ensures that only datapack/minecraft tags are sent when specifically requested
&& (origin != TagOrigin.BUKKIT || (datapackOnly ^ tag.getKey().getNamespace().equals("minecraft")))
) {
tags.add(tag);
continue nextName; // ensure 1:1
Tag<?> tag;
for (TagType<?> type : types) {
tag = TagModule.tagRegistry.getTag(origin, type, key);
if (tag != null
// ensures that only datapack/minecraft tags are sent when specifically requested
&& (origin != TagOrigin.BUKKIT || (datapackOnly ^ tag.getKey().getNamespace().equals("minecraft")))
) {
tags.add(tag);
continue nextName; // ensure 1:1
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test "77449 - Tag Lookup Only does Minecraft":
Fusezion marked this conversation as resolved.
Show resolved Hide resolved
register an item tag named "my_favorite_blocks" using oak log, stone, and podzol
assert tag "my_favorite_blocks" is tag "skript:my_favorite_blocks" with "Tag lookup didn't find a skript tag ""helmets"" namespace"
assert tag "helmets" is tag "paper:helmets" with "Tag lookup didn't find a paper tag ""helmets"" namespace"
assert tag "dirt" is tag "minecraft:dirt" with "Tag lookup didn't find a minecraft tag ""dirt"" namespace"
Loading