Skip to content
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

Shortened Timespans (again) #7001

Merged
merged 13 commits into from
Oct 13, 2024

Conversation

Asleeepp
Copy link
Contributor

Description

This PR aims to add an option to provide a shortened version of a Timespan.
Unlike my previous PR of this exact thing, this uses the lang file, and does not require the Command context, as I felt making this exclusive to commands was a bit silly.
Not sure if this will require a test, or how I could even make a test for this. If it does, please tell me, (and some guidance would be helpful). and I will make one.


Target Minecraft Versions: any
Requirements: none
Related Issues: none

@Asleeepp
Copy link
Contributor Author

Oh, lovely, the tests are failing, guess i screwed something up

src/main/java/ch/njol/skript/util/Timespan.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/util/Timespan.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/util/Timespan.java Outdated Show resolved Hide resolved
src/main/resources/lang/default.lang Outdated Show resolved Hide resolved
@Asleeepp Asleeepp requested review from sovdeeth and Moderocky August 29, 2024 16:02
src/test/skript/tests/misc/timespans.sk Outdated Show resolved Hide resolved
src/test/skript/tests/misc/timespans.sk Outdated Show resolved Hide resolved
@Asleeepp Asleeepp requested a review from sovdeeth August 30, 2024 16:22
Copy link
Member

@Moderocky Moderocky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks ok, but I'm a bit concerned about allowing this outside commands because it feels like it could be weird and ambiguous in code.
My concern is mainly that m is the international standard abbreviation for metres (a unit of measurement for any americans out there), I can guarantee this will trip up some beginners doing things like the block 20m in front of player and wondering why it's not working.
I think it's also worth noting that Minecraft uses d and s as number type tokens in its stringified NBT format (and in fact some real languages use D as a double token) so I can see somebody getting confused by 0.5d or whatever, but I think that's a much lesser concern.

If the others are happy with this then I'm fine with it, but if it was me I would probably just restrict this to commands or text -> timespan parsing where a shorthand (e.g. 1h30m, 3d2y) feels more appropriate.

@Asleeepp
Copy link
Contributor Author

Asleeepp commented Sep 9, 2024

The code looks ok, but I'm a bit concerned about allowing this outside commands because it feels like it could be weird and ambiguous in code. My concern is mainly that m is the international standard abbreviation for metres (a unit of measurement for any americans out there), I can guarantee this will trip up some beginners doing things like the block 20m in front of player and wondering why it's not working. I think it's also worth noting that Minecraft uses d and s as number type tokens in its stringified NBT format (and in fact some real languages use D as a double token) so I can see somebody getting confused by 0.5d or whatever, but I think that's a much lesser concern.

If the others are happy with this then I'm fine with it, but if it was me I would probably just restrict this to commands or text -> timespan parsing where a shorthand (e.g. 1h30m, 3d2y) feels more appropriate.

The original PR was locked behind command context, but i removed that requirement with this new PR, as I personally felt that locking this behind just commands felt a little bit silly, but you do have some valid arguments, if anyone else agrees with Kenzie on this, i'll lock it behind commands only

@Moderocky
Copy link
Member

if anyone else agrees with Kenzie on this, i'll lock it behind commands only

I'm not like totally against it, I just feel like it's the sort of thing that might bite us down the line, would be interested to see others' opinions 😄

@sovdeeth
Copy link
Member

if anyone else agrees with Kenzie on this, i'll lock it behind commands only

I'm not like totally against it, I just feel like it's the sort of thing that might bite us down the line, would be interested to see others' opinions 😄

Yes i think it'd be better as command context only. I understand the need for brevity in commands (and it's less likely to cause issues there), but in actual code i think writing out the units makes much more sense, makes code more readable, prevents possible future conflicts, etc.

@Asleeepp Asleeepp requested a review from Moderocky September 15, 2024 16:00
Copy link
Contributor Author

@Asleeepp Asleeepp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont really feel like going back into intellij to fix this

src/test/skript/tests/misc/timespans.sk Outdated Show resolved Hide resolved
Copy link
Member

@Moderocky Moderocky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good :)

@Efnilite Efnilite added enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. labels Sep 16, 2024
@sovdeeth sovdeeth merged commit 8166f1e into SkriptLang:dev/feature Oct 13, 2024
5 checks passed
@Efnilite Efnilite mentioned this pull request Nov 1, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants