Skip to content

Commit

Permalink
fix: when creating tags, prefer minecraft: namespace over skills:
Browse files Browse the repository at this point in the history
  • Loading branch information
impleri committed Mar 2, 2023
1 parent 099f51f commit 7850f2c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ public class RegistrationType<T> {
private final TagKey<T> tag;

public RegistrationType(String value, ResourceKey<Registry<T>> registryKey) {
if (value.trim().endsWith(":*")) {
namespace = value.substring(0, value.indexOf(":"));
name = null;
tag = null;
} else if (value.trim().startsWith("@")) {
if (value.trim().startsWith("@")) {
namespace = value.substring(1);
name = null;
tag = null;
} else if (value.trim().startsWith("#")) {
var tagKey = value.substring(1);

tag = TagKey.create(registryKey, SkillResourceLocation.of(tagKey));
tag = TagKey.create(registryKey, SkillResourceLocation.ofMinecraft(tagKey));
namespace = null;
name = null;
} else if (value.trim().endsWith(":*")) {
namespace = value.substring(0, value.indexOf(":"));
name = null;
tag = null;
} else {
name = SkillResourceLocation.of(value);
name = SkillResourceLocation.ofMinecraft(value);
namespace = null;
tag = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ public static ResourceLocation of(String path) {
return of(elements[0], elements[1]);
}

/**
* ofMinecraft
* <p>
* Attempt to parse the string into a minecraft-default ResourceLocation and fallback to skills namespace if some error
*/
public static ResourceLocation ofMinecraft(String value) {
var mcResource = ResourceLocation.tryParse(value);

return mcResource == null ? of(value) : mcResource;
}

private static final String DEFAULT_NAMESPACE = "skills";

private static String[] decompose(String string) {
Expand Down

0 comments on commit 7850f2c

Please sign in to comment.