-
-
Notifications
You must be signed in to change notification settings - Fork 453
Statistics #8694
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
Open
AnOwlBe
wants to merge
41
commits into
SkriptLang:dev/feature
Choose a base branch
from
AnOwlBe:Statistics
base: dev/feature
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Statistics #8694
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
3a5700b
Update Gradle wrapper to 9.5.0
github-actions[bot] 2b381b2
Update Gradle wrapper to 9.5.1
github-actions[bot] 252e5cb
Merge branch 'SkriptLang:master' into master
AnOwlBe cf609fe
Statistics!
AnOwlBe 6eb7279
Removes left over debug line
AnOwlBe adf6c03
Merge branch 'dev/feature' into Statistics
AnOwlBe 0c44d17
Forgot description for javadocs for `checkTyping`
AnOwlBe 52f19ca
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe d017cb0
Resolves suggested changes
AnOwlBe 99f9d59
Apply suggestions from code review
AnOwlBe 944cc5f
Resolves suggested changes that didn't come through last time for som…
AnOwlBe 0c601c7
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe 51812a0
Update src/main/java/org/skriptlang/skript/bukkit/entity/player/eleme…
AnOwlBe 67a7691
Adds tests and implements requested changes
AnOwlBe bd1edba
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe 2f6111f
Fixes parseresult & changes tests to use last caught errors
AnOwlBe b34b509
Adds the last caught error for one of the catch runtime errors
AnOwlBe e485d8f
Fixes more stuff (who knew it was possible to find this many flaws in…
AnOwlBe 7efabfd
Too lazy to commit a 1 line change
AnOwlBe 6f772f0
More runtime error catching
AnOwlBe 9892190
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe c828e5e
Merge branch 'dev/feature' into Statistics
AnOwlBe da6391a
Github decided to not implement the `,` needed on line before..
AnOwlBe 3b4a317
Merge branch 'dev/feature' into Statistics
AnOwlBe 872217e
Removes unused imports
AnOwlBe d1b94ce
Merge branch 'dev/feature' into Statistics
AnOwlBe f650c45
fixes issue before it is detected :)
AnOwlBe f530074
fixes issue before it is detected :)
AnOwlBe 944a699
Merge branch 'dev/feature' into Statistics
AnOwlBe 84b68a5
requested changes + things pickle didn't notice
AnOwlBe 8f73b25
Merge branch 'dev/feature' into Statistics
AnOwlBe b3a59c8
requested changes [2x]
AnOwlBe 98b8d1b
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe 147ae72
Apply suggestions from code review
AnOwlBe c03becf
requested changes [4x]
AnOwlBe b8298c4
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe d251399
Apply suggestions from code review
AnOwlBe 133b30e
Merge branch 'dev/feature' into Statistics
AnOwlBe 6be9e13
Merge branch 'dev/feature' into Statistics
AnOwlBe 0e4826b
conflicts
AnOwlBe 892fa19
Merge branch 'dev/feature' into Statistics
AnOwlBe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
.../org/skriptlang/skript/bukkit/entity/player/elements/events/EvtPlayerStatisticChange.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| package org.skriptlang.skript.bukkit.entity.player.elements.events; | ||
|
|
||
| import ch.njol.skript.aliases.ItemType; | ||
| import ch.njol.skript.entity.EntityData; | ||
| import ch.njol.skript.lang.Literal; | ||
| import ch.njol.skript.lang.SkriptEvent; | ||
| import ch.njol.skript.lang.SkriptParser.ParseResult; | ||
| import ch.njol.skript.lang.SyntaxStringBuilder; | ||
| import org.bukkit.Statistic; | ||
| import org.bukkit.event.Event; | ||
| import org.bukkit.event.player.PlayerStatisticIncrementEvent; | ||
| import org.jetbrains.annotations.Nullable; | ||
| import org.skriptlang.skript.bukkit.lang.eventvalue.EventValue; | ||
| import org.skriptlang.skript.bukkit.lang.eventvalue.EventValue.Time; | ||
| import org.skriptlang.skript.bukkit.lang.eventvalue.EventValueRegistry; | ||
| import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos; | ||
| import org.skriptlang.skript.registration.SyntaxRegistry; | ||
|
|
||
| import static ch.njol.skript.bukkitutil.EntityUtils.toSkriptEntityData; | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| public class EvtPlayerStatisticChange extends SkriptEvent { | ||
|
|
||
| public static void register(SyntaxRegistry syntaxRegistry, EventValueRegistry registry) { | ||
| syntaxRegistry.register(BukkitSyntaxInfos.Event.KEY, BukkitSyntaxInfos.Event.builder(EvtPlayerStatisticChange.class, "Player Statistic Change") | ||
| .supplier(EvtPlayerStatisticChange::new) | ||
| .addEvent(PlayerStatisticIncrementEvent.class) | ||
| .addPatterns("player statistic (change|increase|increment) [of %-statistics% stat[istic][s]]") | ||
| .addDescription(""" | ||
| Called when a player's statistic changes. | ||
| Some statistics like 'play one minute' do not call this event, because they get called too often. | ||
| This event is only called when the server updates a statistic and as such does not call if the statistic expression is used. | ||
| """) | ||
| .addExample(""" | ||
| on player statistic increase: | ||
| broadcast "%player%'s statistic '%event-statistic%' increased! It is now %event-number%! | ||
| """) | ||
| .addExample(""" | ||
| on player statistic increase of leave game: | ||
| broadcast "%player% has now left the game %event-number% times!" | ||
| """) | ||
| .addSince("INSERT VERSION") | ||
| .build()); | ||
|
|
||
| registry.register(EventValue.builder(PlayerStatisticIncrementEvent.class, Integer.class) | ||
| .getter(PlayerStatisticIncrementEvent::getNewValue) | ||
| .build()); | ||
|
|
||
| registry.register(EventValue.builder(PlayerStatisticIncrementEvent.class, Integer.class) | ||
| .getter(PlayerStatisticIncrementEvent::getPreviousValue) | ||
| .time(Time.PAST) | ||
| .build()); | ||
|
|
||
| registry.register(EventValue.builder(PlayerStatisticIncrementEvent.class, Statistic.class) | ||
| .getter(PlayerStatisticIncrementEvent::getStatistic) | ||
| .build()); | ||
|
|
||
| registry.register(EventValue.builder(PlayerStatisticIncrementEvent.class, ItemType.class) | ||
| .getter(event -> new ItemType(event.getMaterial())) | ||
| .build()); | ||
|
|
||
| registry.register(EventValue.builder(PlayerStatisticIncrementEvent.class, EntityData.class) | ||
| .getter(event -> toSkriptEntityData(event.getEntityType())) | ||
| .build()); | ||
| } | ||
|
|
||
| private Literal<Statistic> statistics; | ||
|
|
||
| @Override | ||
| public boolean init(Literal<?>[] literals, int i, ParseResult parseResult) { | ||
| statistics = (Literal<Statistic>) literals[0]; | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean check(Event event) { | ||
| if (statistics == null) | ||
| return true; | ||
| Statistic statistic = ((PlayerStatisticIncrementEvent) event).getStatistic(); | ||
| for (Statistic value : this.statistics.getAll(event)) { | ||
| if (statistic.equals(value)) | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| return new SyntaxStringBuilder(event, debug) | ||
| .append("player statistic change") | ||
| .appendIf(statistics != null, "of", statistics) | ||
| .toString(); | ||
| } | ||
|
|
||
| } | ||
|
AnOwlBe marked this conversation as resolved.
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.