feat: cloop interval units (now we can loop at 1 chomeNS and crash the server :D)

feat: show possible values of the enum in the command context's `getEnum`
This commit is contained in:
ChomeNS
2025-03-16 12:53:27 +07:00
parent fb8dd58de1
commit c86e2714e6
5 changed files with 30 additions and 16 deletions

View File

@@ -232,7 +232,15 @@ public class CommandContext {
try {
return Enum.valueOf(enumClass, string.toUpperCase());
} catch (IllegalArgumentException | NullPointerException e) {
throw new CommandException(Component.text("Invalid enum"));
final T[] values = enumClass.getEnumConstants();
throw new CommandException(
Component.translatable(
"Invalid %s. Possible values are: %s",
Component.text(enumClass.getSimpleName()),
Component.text(Arrays.toString(values))
)
);
}
}