Skip to content
Open
Show file tree
Hide file tree
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] May 3, 2026
2b381b2
Update Gradle wrapper to 9.5.1
github-actions[bot] May 17, 2026
252e5cb
Merge branch 'SkriptLang:master' into master
AnOwlBe Jun 8, 2026
cf609fe
Statistics!
AnOwlBe Jun 9, 2026
6eb7279
Removes left over debug line
AnOwlBe Jun 9, 2026
adf6c03
Merge branch 'dev/feature' into Statistics
AnOwlBe Jun 9, 2026
0c44d17
Forgot description for javadocs for `checkTyping`
AnOwlBe Jun 9, 2026
52f19ca
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe Jun 9, 2026
d017cb0
Resolves suggested changes
AnOwlBe Jun 9, 2026
99f9d59
Apply suggestions from code review
AnOwlBe Jun 9, 2026
944cc5f
Resolves suggested changes that didn't come through last time for som…
AnOwlBe Jun 9, 2026
0c601c7
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe Jun 9, 2026
51812a0
Update src/main/java/org/skriptlang/skript/bukkit/entity/player/eleme…
AnOwlBe Jun 9, 2026
67a7691
Adds tests and implements requested changes
AnOwlBe Jun 9, 2026
bd1edba
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe Jun 9, 2026
2f6111f
Fixes parseresult & changes tests to use last caught errors
AnOwlBe Jun 10, 2026
b34b509
Adds the last caught error for one of the catch runtime errors
AnOwlBe Jun 10, 2026
e485d8f
Fixes more stuff (who knew it was possible to find this many flaws in…
AnOwlBe Jun 10, 2026
7efabfd
Too lazy to commit a 1 line change
AnOwlBe Jun 10, 2026
6f772f0
More runtime error catching
AnOwlBe Jun 10, 2026
9892190
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe Jun 10, 2026
c828e5e
Merge branch 'dev/feature' into Statistics
AnOwlBe Jun 11, 2026
da6391a
Github decided to not implement the `,` needed on line before..
AnOwlBe Jun 11, 2026
3b4a317
Merge branch 'dev/feature' into Statistics
AnOwlBe Jun 13, 2026
872217e
Removes unused imports
AnOwlBe Jun 14, 2026
d1b94ce
Merge branch 'dev/feature' into Statistics
AnOwlBe Jun 18, 2026
f650c45
fixes issue before it is detected :)
AnOwlBe Jun 22, 2026
f530074
fixes issue before it is detected :)
AnOwlBe Jun 22, 2026
944a699
Merge branch 'dev/feature' into Statistics
AnOwlBe Jun 22, 2026
84b68a5
requested changes + things pickle didn't notice
AnOwlBe Jun 30, 2026
8f73b25
Merge branch 'dev/feature' into Statistics
AnOwlBe Jun 30, 2026
b3a59c8
requested changes [2x]
AnOwlBe Jun 30, 2026
98b8d1b
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe Jun 30, 2026
147ae72
Apply suggestions from code review
AnOwlBe Jun 30, 2026
c03becf
requested changes [4x]
AnOwlBe Jul 1, 2026
b8298c4
Merge remote-tracking branch 'origin/Statistics' into Statistics
AnOwlBe Jul 1, 2026
d251399
Apply suggestions from code review
AnOwlBe Jul 1, 2026
133b30e
Merge branch 'dev/feature' into Statistics
AnOwlBe Jul 2, 2026
6be9e13
Merge branch 'dev/feature' into Statistics
AnOwlBe Jul 15, 2026
0e4826b
conflicts
AnOwlBe Jul 15, 2026
892fa19
Merge branch 'dev/feature' into Statistics
AnOwlBe Jul 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 82 additions & 82 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.skriptlang.skript.bukkit.entity.player;

import ch.njol.skript.Skript;
import ch.njol.skript.classes.EnumClassInfo;
import ch.njol.skript.lang.util.SimpleEvent;
import ch.njol.skript.registrations.Classes;
import io.papermc.paper.event.player.AsyncChatEvent;
import org.bukkit.Statistic;
import org.skriptlang.skript.addon.AddonModule;
import org.skriptlang.skript.addon.HierarchicalAddonModule;
import org.skriptlang.skript.addon.SkriptAddon;
Expand All @@ -19,11 +22,24 @@ public PlayerModule(AddonModule parentModule) {
super(parentModule);
}

@Override
protected void initSelf(SkriptAddon addon) {
Classes.registerClass(new EnumClassInfo<>(Statistic.class, "statistic", "statistics")
.user("statistics?")
.name("Statistic")
.description(
"Represents a countable statistic, which is tracked by the server. "
+ "For the list of all available statistics, "
+ "see <a href='https://minecraft.wiki/w/Statistics'>the Minecraft wiki</a>.")
.since("INSERT VERSION"));
}

@Override
protected void loadSelf(SkriptAddon addon) {
EventValueRegistry eventValueRegistry = addon.registry(EventValueRegistry.class);

register(addon,
syntaxRegistry -> EvtPlayerStatisticChange.register(syntaxRegistry, eventValueRegistry),
EffBan::register,
EffKick::register,
syntaxRegistry -> EvtPlayerGameModeChange.register(syntaxRegistry, eventValueRegistry),
Expand All @@ -37,7 +53,8 @@ protected void loadSelf(SkriptAddon addon) {
ExprPlayerListHeaderFooter::register,
ExprPlayerListName::register,
ExprPlayerListPriority::register,
ExprQuitMessage::register
ExprQuitMessage::register,
ExprStatistic::register
);
if (Skript.classExists("io.papermc.paper.event.player.PlayerPickBlockEvent")) {
register(addon,
Expand Down
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!"
Comment thread
AnOwlBe marked this conversation as resolved.
""")
.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();
}

}
Comment thread
AnOwlBe marked this conversation as resolved.
Loading
Loading