Fixed error when setting race without specifying a namespace

This commit is contained in:
Sollace 2024-04-09 11:56:20 +01:00
parent 59d20f9e0f
commit ca935ce224
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 6 additions and 2 deletions

View file

@ -227,7 +227,11 @@ public record Race (
public static Race fromArgument(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
Identifier id = context.getArgument(name, RegistryKey.class).getValue();
return REGISTRY.getOrEmpty(id).orElseThrow(() -> UNKNOWN_RACE_EXCEPTION.create(id));
final Identifier idf = id;
if (id.getNamespace() == Identifier.DEFAULT_NAMESPACE && !REGISTRY.containsId(id)) {
id = Unicopia.id(id.getPath());
}
return REGISTRY.getOrEmpty(id).orElseThrow(() -> UNKNOWN_RACE_EXCEPTION.create(idf));
}
public static Set<Race> allPermitted(PlayerEntity player) {

View file

@ -43,7 +43,7 @@ public class UCommandSuggestion {
}
public static <T> void forEachMatching(Iterable<T> candidates, String input, Function<T, Identifier> idFunc, Consumer<T> consumer, String defaultNamespace) {
final boolean hasNamespaceDelimiter = input.indexOf(58) > -1;
final boolean hasNamespaceDelimiter = input.indexOf(':') > -1;
for (T object : candidates) {
final Identifier id = idFunc.apply(object);
if (hasNamespaceDelimiter) {