-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
⚒️ Fix ExprFormatTime CCE + Support non-literals #4664
⚒️ Fix ExprFormatTime CCE + Support non-literals #4664
Conversation
instead of requiring a use of literals here, can we just create the format in |
It's only there to give skript errors on init if the pattern is incorrect and an exception was thrown tho in this class it wasn't throwing exceptions as in #4663 I will be doing some tests on this to try if I can make it throw an exception if so will have to use try/catch otherwise I think we can do what you said EDIT: |
@Pikachu920 The reason it was initially required to be a literal is because that way the format can be checked for errors. If we were to parse it as a format at runtime, we could either error at runtime (which I don't think is great, people don't look at console often), or exit silently (which isn't helpful to the user). |
I think that returning null silently is the best option. It's nice to have the format checking for literals, but I don't think limiting to only literals is necessary. |
Though should we check in init if exprs[1] is literal and simple VariableString then we can check for format exceptions otherwise will leave it to runtime and silent the errors, what do you think? Also, what about leaving warning at runtime for format errors so that at least if a good skripter checks the console would know what's going on/why it isn't working (tho it might spam their console but that's a user error) |
Totally agree. Check for format exceptions when possible, otherwise silently ignore. |
Co-authored-by: TPGamesNL <29547183+TPGamesNL@users.noreply.github.com>
…o fix/formatted-date-cce
Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
Co-authored-by: TPGamesNL <29547183+TPGamesNL@users.noreply.github.com>
…prFormatTime CCE + Support non-literals (SkriptLang#4664)" from 58081ab
* 🚀 Add number format expression * Little changes * Prevent variables usage * Support variables as custom format * Make it return null if format is invalid * Add test script * Update test script * Update test script * Changes * Fix class to use same technique as #4664 * Apply suggestions from code review Co-authored-by: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com> * Add helpful comments and use lambda * Update src/main/java/ch/njol/skript/expressions/ExprFormatNumber.java Co-authored-by: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com> * Change expression to function * Remove unused imports * Refactoring and merge base, updating examples * return null instead of empty string * Update examples * Warn instead of erroring, but probably better to remove * Address reviews * better variable naming * init commit * update file name --------- Co-authored-by: Ayham Al-Ali <alali_ayham@yahoo.com> Co-authored-by: Ayham Al-Ali <20037329+AyhamAl-Ali@users.noreply.github.com> Co-authored-by: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com> Co-authored-by: Moderocky <admin@moderocky.com>
Description
broadcast now formatted as {_someVar}
Date
instead ofTime
Before PR (CCE)
After PR
Target Minecraft Versions: Any
Requirements: None
Related Issues: None