-
- Notifications
You must be signed in to change notification settings - Fork 414
Player Statistics #7568
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
Player Statistics #7568
Conversation
src/main/java/ch/njol/skript/events/EvtPlayerStatisticIncrease.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/expressions/ExprNewStatisticValue.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/expressions/ExprPlayerStatistics.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/events/EvtPlayerStatisticIncrease.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/events/EvtPlayerStatisticIncrease.java Outdated Show resolved Hide resolved
| I think the strings should be parsed into actual Statistics whenever possible, for faster comparison and to allow proper errors. |
I have made them actual enums now. My initial thought was that they should be strings, because there's a lot of enums. But I've looked at the default lang file and I saw that there are even more (of other enums) compared to statistics. |
src/main/java/ch/njol/skript/expressions/ExprPlayerStatistics.java Outdated Show resolved Hide resolved
src/main/java/ch/njol/skript/expressions/ExprPlayerStatistics.java Outdated Show resolved Hide resolved
| | ||
| static { | ||
| Skript.registerExpression(ExprNewStatisticValue.class, Number.class, ExpressionType.SIMPLE, | ||
| "(future|new) statistic [value]", "(past|previous) statistic [value]"); |
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.
This whole class should be an EventValueExpression. What you do is register the numbers as event values TIME_FUTURE and TIME_PAST then the EventValueExpression will automatically be able to grab the future and past values. This is because there is already a syntax for future and past in ExprEventValue
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've already tried that (if you specifically mean registering the event value within the event), but it didn't work.
I registered the event value for an integer, a number and neither past/future event-integer or event-number worked
edit: I also prefer this expression over event-number because just by looking at event-number i cannot know what it is
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'd like to re-open this a bit because Lime is correct that a EVE would be more appropriate, since then you use setTime to control past/future automatically. However, I think that would leave the syntax as statistic [value] which would interfere with the classinfo itself. That said, statistic value is a less ambiguous name and doesn't conflict at all, which I think I would prefer to see.
| i have no clue what happened to tests |
d2556c8 to 986470e Compare | | ||
| static { | ||
| Skript.registerEvent("Player Statistic Change", EvtPlayerStatisticChange.class, PlayerStatisticIncrementEvent.class, | ||
| "player statistic (change|increase|increment) [of %-statistics% statistic[s]]", |
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.
| "player statistic (change|increase|increment) [of %-statistics% statistic[s]]", | |
| "player statistic (change|increase|increment) [of %-statistics% statistic[s]]", |
| | ||
| static { | ||
| Skript.registerExpression(ExprNewStatisticValue.class, Number.class, ExpressionType.SIMPLE, | ||
| "(future|new) statistic [value]", "(past|previous) statistic [value]"); |
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'd like to re-open this a bit because Lime is correct that a EVE would be more appropriate, since then you use setTime to control past/future automatically. However, I think that would leave the syntax as statistic [value] which would interfere with the classinfo itself. That said, statistic value is a less ambiguous name and doesn't conflict at all, which I think I would prefer to see.
| } | ||
| } | ||
| | ||
| private boolean shouldStop(Statistic statistic, Object ofType) { |
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.
| private boolean shouldStop(Statistic statistic, Object ofType) { | |
| private boolean checkTyping(Statistic statistic, Object ofType) { |
some short javadocs for this method and the others would be nice
| Do you still intend to work on this? |
Description
This PR aims to add player statistics and closes the beloved and old issue #4687! Here's a slight glimpse of how statistics will look like:
Target Minecraft Versions: any
Requirements: none
Related Issues: #4687