mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Fixed error when setting race without specifying a namespace
This commit is contained in:
parent
59d20f9e0f
commit
ca935ce224
2 changed files with 6 additions and 2 deletions
|
@ -227,7 +227,11 @@ public record Race (
|
||||||
|
|
||||||
public static Race fromArgument(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
|
public static Race fromArgument(CommandContext<ServerCommandSource> context, String name) throws CommandSyntaxException {
|
||||||
Identifier id = context.getArgument(name, RegistryKey.class).getValue();
|
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) {
|
public static Set<Race> allPermitted(PlayerEntity player) {
|
||||||
|
|
|
@ -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) {
|
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) {
|
for (T object : candidates) {
|
||||||
final Identifier id = idFunc.apply(object);
|
final Identifier id = idFunc.apply(object);
|
||||||
if (hasNamespaceDelimiter) {
|
if (hasNamespaceDelimiter) {
|
||||||
|
|
Loading…
Reference in a new issue