Skip to content

Commit

Permalink
maybe fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aabssmc committed Sep 30, 2024
1 parent 0fbd5ab commit ada696e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/lol/aabss/skuishy/other/RegistryClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import ch.njol.util.StringUtils;
import ch.njol.yggdrasil.Fields;
import com.google.common.base.Preconditions;
import lol.aabss.skuishy.Skuishy;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
Expand Down Expand Up @@ -216,9 +215,22 @@ private T parse(String string) {
}
string = string.trim();

NamespacedKey key = Skuishy.namespacedKeyFromObject(string);
NamespacedKey key = getNamespacedKey(string);
if (key == null) return null;
return this.registry.get(key);
}

@Nullable
private static NamespacedKey getNamespacedKey(@NotNull String key) {
if (!key.contains(":")) key = "minecraft:" + key;
if (key.length() > 255) {
return null;
}
key = key.toLowerCase();
if (key.contains(" ")) {
key = key.replace(" ", "_");
}
return NamespacedKey.fromString(key);
}

}

0 comments on commit ada696e

Please sign in to comment.