-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid NPE by defaulting to enum name when no language node available in EnumUtil's toString. #6375
Avoid NPE by defaulting to enum name when no language node available in EnumUtil's toString. #6375
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have a slight concern about users thinking that these names may be supported in syntax (when they aren't). Do you think it would be better to just display <none>
? Or maybe that isn't a big deal and we should format it to be more readable (e.g. MY_ENUMERATOR
-> my enumerator
LMK what you think :)
I considered that but I thought the all caps might be a clue that it's not usable in Skript. I think it would be confusing if it was formatted to be readable, though. None would work, but feels too limiting imo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be okay as is. I realize <none>
would not work as it would not actually be "none", but just a string containing "none"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it have some kind of debug log message that a language node is missing
this is done at startup, it got kind of spammy in the past when it was each time it encountered a missing entry |
…in EnumUtil's toString. (SkriptLang#6375)
Description
If there isn't a language node available for an enum value, EnumUtil#toString() will return null. This is used in EnumClassInfo's Parser, which requires the toString to be non-null. Since we can pretty easily return null, this leads to an NPE later down the line when you attempt to
send <some expression that returns that enum value>
.I've chosen to replace it with the enum value's name, so the user can still understand what it is, even if there's no lang node for them to use. Since this is fixing something that should only occur when we haven't yet updated to a newer minecraft version, I think this is an appropriate bandaid.
Prior to change: (creative has been manually removed from default.lang)
After change:
Target Minecraft Versions: any
Requirements: none
Related Issues: #6370