Statistics
Statistics allow minecraft-like statistics for players, in implementation it is very similar to Entity Attributes.
Getting player Statistics and Modifying them
PlayerStatistics statistics = PlayerStatistics.of(Player);
FloatStatistic stat = (FloatStatistic) statistics.get(Identifier.of("my_plugin", "my_stat"));
stat.setValue(1.2f);
statistics.set(stat);
Below you will see what FloatStatistic is (and other types will be shown too).
Adding custom statistics
public static MyStats {
public static final DeferredRegistry<Statistic> STATS = DeferredRegistry.create(Registries.STATISTICS, "my_plugin");
public static final Holder<Statistic> MY_STAT = STATS.register("my_stat", id -> Statistic.of(id, 1.2f));
}
Knowledge of DeferredRegistry and Holder is expected from topics before this.
Types of Statistics:
Name | Created By |
|---|---|
FloatStatistic | Created by passing a float value in Statistic.of |
IntStatistic | Created by passing an int value in Statistic.of |
BooleanStatistic | Created by passing a boolean value in Statistic.of |
23 November 2025