Skip to content

Commit adb72c7

Browse files
committed
generate
1 parent 2dd35d1 commit adb72c7

File tree

18 files changed

+271
-112
lines changed

18 files changed

+271
-112
lines changed

paper-api/src/main/java/io/papermc/paper/event/player/PlayerRequestStatisticsEvent.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,11 @@ public class PlayerRequestStatisticsEvent extends PlayerEvent implements Cancell
2121
private boolean cancelled;
2222

2323
@ApiStatus.Internal
24-
public PlayerRequestStatisticsEvent(final Player who, final Object2IntMap<Statistic<?>> statisticMap) {
25-
super(who);
24+
public PlayerRequestStatisticsEvent(final Player player, final Object2IntMap<Statistic<?>> statisticMap) {
25+
super(player);
2626
this.statisticMap = statisticMap;
2727
}
2828

29-
public static HandlerList getHandlerList() {
30-
return HANDLER_LIST;
31-
}
32-
3329
/**
3430
* Gets the statistic map to be sent to the player.
3531
*
@@ -53,4 +49,8 @@ public void setCancelled(final boolean cancel) {
5349
public HandlerList getHandlers() {
5450
return HANDLER_LIST;
5551
}
52+
53+
public static HandlerList getHandlerList() {
54+
return HANDLER_LIST;
55+
}
5656
}

paper-api/src/main/java/io/papermc/paper/statistic/CustomStatistic.java

Lines changed: 136 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,81 +13,160 @@
1313
@ApiStatus.NonExtendable
1414
public interface CustomStatistic extends Keyed, Translatable {
1515

16-
CustomStatistic LEAVE_GAME = get("leave_game");
17-
CustomStatistic PLAY_TIME = get("play_time");
18-
CustomStatistic TOTAL_WORLD_TIME = get("total_world_time");
19-
CustomStatistic TIME_SINCE_DEATH = get("time_since_death");
20-
CustomStatistic TIME_SINCE_REST = get("time_since_rest");
21-
CustomStatistic SNEAK_TIME = get("sneak_time");
22-
CustomStatistic WALK_ONE_CM = get("walk_one_cm");
23-
CustomStatistic CROUCH_ONE_CM = get("crouch_one_cm");
24-
CustomStatistic SPRINT_ONE_CM = get("sprint_one_cm");
25-
CustomStatistic WALK_ON_WATER_ONE_CM = get("walk_on_water_one_cm");
26-
CustomStatistic FALL_ONE_CM = get("fall_one_cm");
27-
CustomStatistic CLIMB_ONE_CM = get("climb_one_cm");
28-
CustomStatistic FLY_ONE_CM = get("fly_one_cm");
29-
CustomStatistic WALK_UNDER_WATER_ONE_CM = get("walk_under_water_one_cm");
30-
CustomStatistic MINECART_ONE_CM = get("minecart_one_cm");
31-
CustomStatistic BOAT_ONE_CM = get("boat_one_cm");
32-
CustomStatistic PIG_ONE_CM = get("pig_one_cm");
33-
CustomStatistic HORSE_ONE_CM = get("horse_one_cm");
16+
// Start generate - CustomStatistic
17+
// @GeneratedFrom 1.21.6-rc1
18+
CustomStatistic ANIMALS_BRED = get("animals_bred");
19+
3420
CustomStatistic AVIATE_ONE_CM = get("aviate_one_cm");
35-
CustomStatistic SWIM_ONE_CM = get("swim_one_cm");
36-
CustomStatistic STRIDER_ONE_CM = get("strider_one_cm");
37-
CustomStatistic JUMP = get("jump");
38-
CustomStatistic DROP = get("drop");
21+
22+
CustomStatistic BELL_RING = get("bell_ring");
23+
24+
CustomStatistic BOAT_ONE_CM = get("boat_one_cm");
25+
26+
CustomStatistic CLEAN_ARMOR = get("clean_armor");
27+
28+
CustomStatistic CLEAN_BANNER = get("clean_banner");
29+
30+
CustomStatistic CLEAN_SHULKER_BOX = get("clean_shulker_box");
31+
32+
CustomStatistic CLIMB_ONE_CM = get("climb_one_cm");
33+
34+
CustomStatistic CROUCH_ONE_CM = get("crouch_one_cm");
35+
36+
CustomStatistic DAMAGE_ABSORBED = get("damage_absorbed");
37+
38+
CustomStatistic DAMAGE_BLOCKED_BY_SHIELD = get("damage_blocked_by_shield");
39+
3940
CustomStatistic DAMAGE_DEALT = get("damage_dealt");
41+
4042
CustomStatistic DAMAGE_DEALT_ABSORBED = get("damage_dealt_absorbed");
43+
4144
CustomStatistic DAMAGE_DEALT_RESISTED = get("damage_dealt_resisted");
42-
CustomStatistic DAMAGE_TAKEN = get("damage_taken");
43-
CustomStatistic DAMAGE_BLOCKED_BY_SHIELD = get("damage_blocked_by_shield");
44-
CustomStatistic DAMAGE_ABSORBED = get("damage_absorbed");
45+
4546
CustomStatistic DAMAGE_RESISTED = get("damage_resisted");
47+
48+
CustomStatistic DAMAGE_TAKEN = get("damage_taken");
49+
4650
CustomStatistic DEATHS = get("deaths");
47-
CustomStatistic MOB_KILLS = get("mob_kills");
48-
CustomStatistic ANIMALS_BRED = get("animals_bred");
49-
CustomStatistic PLAYER_KILLS = get("player_kills");
50-
CustomStatistic FISH_CAUGHT = get("fish_caught");
51-
CustomStatistic TALKED_TO_VILLAGER = get("talked_to_villager");
52-
CustomStatistic TRADED_WITH_VILLAGER = get("traded_with_villager");
51+
52+
CustomStatistic DROP = get("drop");
53+
5354
CustomStatistic EAT_CAKE_SLICE = get("eat_cake_slice");
55+
56+
CustomStatistic ENCHANT_ITEM = get("enchant_item");
57+
58+
CustomStatistic FALL_ONE_CM = get("fall_one_cm");
59+
5460
CustomStatistic FILL_CAULDRON = get("fill_cauldron");
55-
CustomStatistic USE_CAULDRON = get("use_cauldron");
56-
CustomStatistic CLEAN_ARMOR = get("clean_armor");
57-
CustomStatistic CLEAN_BANNER = get("clean_banner");
58-
CustomStatistic CLEAN_SHULKER_BOX = get("clean_shulker_box");
59-
CustomStatistic INTERACT_WITH_BREWINGSTAND = get("interact_with_brewingstand");
60-
CustomStatistic INTERACT_WITH_BEACON = get("interact_with_beacon");
61+
62+
CustomStatistic FISH_CAUGHT = get("fish_caught");
63+
64+
CustomStatistic FLY_ONE_CM = get("fly_one_cm");
65+
66+
CustomStatistic HAPPY_GHAST_ONE_CM = get("happy_ghast_one_cm");
67+
68+
CustomStatistic HORSE_ONE_CM = get("horse_one_cm");
69+
70+
CustomStatistic INSPECT_DISPENSER = get("inspect_dispenser");
71+
6172
CustomStatistic INSPECT_DROPPER = get("inspect_dropper");
73+
6274
CustomStatistic INSPECT_HOPPER = get("inspect_hopper");
63-
CustomStatistic INSPECT_DISPENSER = get("inspect_dispenser");
64-
CustomStatistic PLAY_NOTEBLOCK = get("play_noteblock");
65-
CustomStatistic TUNE_NOTEBLOCK = get("tune_noteblock");
66-
CustomStatistic POT_FLOWER = get("pot_flower");
67-
CustomStatistic TRIGGER_TRAPPED_CHEST = get("trigger_trapped_chest");
68-
CustomStatistic OPEN_ENDERCHEST = get("open_enderchest");
69-
CustomStatistic ENCHANT_ITEM = get("enchant_item");
70-
CustomStatistic PLAY_RECORD = get("play_record");
71-
CustomStatistic INTERACT_WITH_FURNACE = get("interact_with_furnace");
72-
CustomStatistic INTERACT_WITH_CRAFTING_TABLE = get("interact_with_crafting_table");
73-
CustomStatistic OPEN_CHEST = get("open_chest");
74-
CustomStatistic SLEEP_IN_BED = get("sleep_in_bed");
75-
CustomStatistic OPEN_SHULKER_BOX = get("open_shulker_box");
76-
CustomStatistic OPEN_BARREL = get("open_barrel");
75+
76+
CustomStatistic INTERACT_WITH_ANVIL = get("interact_with_anvil");
77+
78+
CustomStatistic INTERACT_WITH_BEACON = get("interact_with_beacon");
79+
7780
CustomStatistic INTERACT_WITH_BLAST_FURNACE = get("interact_with_blast_furnace");
78-
CustomStatistic INTERACT_WITH_SMOKER = get("interact_with_smoker");
79-
CustomStatistic INTERACT_WITH_LECTERN = get("interact_with_lectern");
81+
82+
CustomStatistic INTERACT_WITH_BREWINGSTAND = get("interact_with_brewingstand");
83+
8084
CustomStatistic INTERACT_WITH_CAMPFIRE = get("interact_with_campfire");
85+
8186
CustomStatistic INTERACT_WITH_CARTOGRAPHY_TABLE = get("interact_with_cartography_table");
87+
88+
CustomStatistic INTERACT_WITH_CRAFTING_TABLE = get("interact_with_crafting_table");
89+
90+
CustomStatistic INTERACT_WITH_FURNACE = get("interact_with_furnace");
91+
92+
CustomStatistic INTERACT_WITH_GRINDSTONE = get("interact_with_grindstone");
93+
94+
CustomStatistic INTERACT_WITH_LECTERN = get("interact_with_lectern");
95+
8296
CustomStatistic INTERACT_WITH_LOOM = get("interact_with_loom");
97+
98+
CustomStatistic INTERACT_WITH_SMITHING_TABLE = get("interact_with_smithing_table");
99+
100+
CustomStatistic INTERACT_WITH_SMOKER = get("interact_with_smoker");
101+
83102
CustomStatistic INTERACT_WITH_STONECUTTER = get("interact_with_stonecutter");
84-
CustomStatistic BELL_RING = get("bell_ring");
103+
104+
CustomStatistic JUMP = get("jump");
105+
106+
CustomStatistic LEAVE_GAME = get("leave_game");
107+
108+
CustomStatistic MINECART_ONE_CM = get("minecart_one_cm");
109+
110+
CustomStatistic MOB_KILLS = get("mob_kills");
111+
112+
CustomStatistic OPEN_BARREL = get("open_barrel");
113+
114+
CustomStatistic OPEN_CHEST = get("open_chest");
115+
116+
CustomStatistic OPEN_ENDERCHEST = get("open_enderchest");
117+
118+
CustomStatistic OPEN_SHULKER_BOX = get("open_shulker_box");
119+
120+
CustomStatistic PIG_ONE_CM = get("pig_one_cm");
121+
122+
CustomStatistic PLAY_NOTEBLOCK = get("play_noteblock");
123+
124+
CustomStatistic PLAY_RECORD = get("play_record");
125+
126+
CustomStatistic PLAY_TIME = get("play_time");
127+
128+
CustomStatistic PLAYER_KILLS = get("player_kills");
129+
130+
CustomStatistic POT_FLOWER = get("pot_flower");
131+
85132
CustomStatistic RAID_TRIGGER = get("raid_trigger");
133+
86134
CustomStatistic RAID_WIN = get("raid_win");
87-
CustomStatistic INTERACT_WITH_ANVIL = get("interact_with_anvil");
88-
CustomStatistic INTERACT_WITH_GRINDSTONE = get("interact_with_grindstone");
135+
136+
CustomStatistic SLEEP_IN_BED = get("sleep_in_bed");
137+
138+
CustomStatistic SNEAK_TIME = get("sneak_time");
139+
140+
CustomStatistic SPRINT_ONE_CM = get("sprint_one_cm");
141+
142+
CustomStatistic STRIDER_ONE_CM = get("strider_one_cm");
143+
144+
CustomStatistic SWIM_ONE_CM = get("swim_one_cm");
145+
146+
CustomStatistic TALKED_TO_VILLAGER = get("talked_to_villager");
147+
89148
CustomStatistic TARGET_HIT = get("target_hit");
90-
CustomStatistic INTERACT_WITH_SMITHING_TABLE = get("interact_with_smithing_table");
149+
150+
CustomStatistic TIME_SINCE_DEATH = get("time_since_death");
151+
152+
CustomStatistic TIME_SINCE_REST = get("time_since_rest");
153+
154+
CustomStatistic TOTAL_WORLD_TIME = get("total_world_time");
155+
156+
CustomStatistic TRADED_WITH_VILLAGER = get("traded_with_villager");
157+
158+
CustomStatistic TRIGGER_TRAPPED_CHEST = get("trigger_trapped_chest");
159+
160+
CustomStatistic TUNE_NOTEBLOCK = get("tune_noteblock");
161+
162+
CustomStatistic USE_CAULDRON = get("use_cauldron");
163+
164+
CustomStatistic WALK_ON_WATER_ONE_CM = get("walk_on_water_one_cm");
165+
166+
CustomStatistic WALK_ONE_CM = get("walk_one_cm");
167+
168+
CustomStatistic WALK_UNDER_WATER_ONE_CM = get("walk_under_water_one_cm");
169+
// End generate - CustomStatistic
91170

92171
/**
93172
* Gets the statistic with the given custom stat.

paper-api/src/main/java/io/papermc/paper/statistic/Statistic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public interface Statistic<S> extends Criteria {
2020
S value();
2121

2222
/**
23-
* Get the stat type.
23+
* Gets the stat type.
2424
*
2525
* @return the stat type
2626
*/

paper-api/src/main/java/io/papermc/paper/statistic/StatisticType.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,26 @@
1414
@ApiStatus.NonExtendable
1515
public interface StatisticType<S> extends Keyed, Translatable {
1616

17+
// Start generate - StatisticType
18+
// @GeneratedFrom 1.21.6-rc1
1719
StatisticType<BlockType> BLOCK_MINED = get("mined");
18-
StatisticType<ItemType> ITEM_CRAFTED = get("crafted");
19-
StatisticType<ItemType> ITEM_USED = get("used");
20-
StatisticType<ItemType> ITEM_BROKEN = get("broken");
21-
StatisticType<ItemType> ITEM_PICKED_UP = get("picked_up");
22-
StatisticType<ItemType> ITEM_DROPPED = get("dropped");
20+
21+
StatisticType<CustomStatistic> CUSTOM = get("custom");
22+
2323
StatisticType<EntityType> ENTITY_KILLED = get("killed");
24+
2425
StatisticType<EntityType> ENTITY_KILLED_BY = get("killed_by");
25-
StatisticType<CustomStatistic> CUSTOM = get("custom");
26+
27+
StatisticType<ItemType> ITEM_BROKEN = get("broken");
28+
29+
StatisticType<ItemType> ITEM_CRAFTED = get("crafted");
30+
31+
StatisticType<ItemType> ITEM_DROPPED = get("dropped");
32+
33+
StatisticType<ItemType> ITEM_PICKED_UP = get("picked_up");
34+
35+
StatisticType<ItemType> ITEM_USED = get("used");
36+
// End generate - StatisticType
2637

2738
@SuppressWarnings("unchecked")
2839
private static <S> StatisticType<S> get(@KeyPattern.Value final String key) {
@@ -50,6 +61,7 @@ private static <S> StatisticType<S> get(@KeyPattern.Value final String key) {
5061
* <p>
5162
* {@link StatisticType#CUSTOM} does <b>NOT</b> have a
5263
* translation key.
64+
*
5365
* @throws IllegalArgumentException if used with {@link StatisticType#CUSTOM}
5466
* @see CustomStatistic#translationKey()
5567
*/

paper-api/src/main/java/org/bukkit/Registry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private static <A extends Keyed> Registry<A> registryFor(final RegistryKey<A> re
6464
}
6565

6666
@SuppressWarnings("removal")
67-
@Deprecated(forRemoval = true, since = "1.21.4")
67+
@Deprecated(since = "1.21.4", forRemoval = true)
6868
private static <A extends Keyed> Registry<A> legacyRegistryFor(final Class<A> clazz) {
6969
return Objects.requireNonNull(RegistryAccess.registryAccess().getRegistry(clazz), () -> "No registry present for " + clazz.getSimpleName() + ". This is a bug.");
7070
}
@@ -226,7 +226,7 @@ public Iterator<KeyedBossBar> iterator() {
226226
* @see Statistic
227227
* @deprecated use {@link #CUSTOM_STAT} and {@link #STAT_TYPE}
228228
*/
229-
@Deprecated(forRemoval = true, since = "1.21.6")
229+
@Deprecated(since = "1.21.6", forRemoval = true)
230230
Registry<Statistic> STATISTIC = new SimpleRegistry<>(Statistic.class);
231231
/**
232232
* Server structures.

paper-api/src/main/java/org/bukkit/Statistic.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@
66
import java.util.Locale;
77
import java.util.Objects;
88
import org.bukkit.entity.EntityType;
9+
import org.jetbrains.annotations.ApiStatus;
910
import org.jetbrains.annotations.NotNull;
1011
import org.jspecify.annotations.Nullable;
1112

1213
/**
1314
* Represents a countable statistic, which is tracked by the server.
15+
*
1416
* @deprecated use {@link io.papermc.paper.statistic.StatisticType} and {@link io.papermc.paper.statistic.Statistic}
1517
*/
16-
@Deprecated(since = "1.21.6") // Paper
18+
@Deprecated(since = "1.21.6")
1719
public enum Statistic implements Keyed {
1820
// Start generate - StatisticCustom
1921
// @GeneratedFrom 1.21.6-rc1
@@ -166,7 +168,7 @@ public NamespacedKey getKey() {
166168
*
167169
* @deprecated use {@link io.papermc.paper.statistic.StatisticType}
168170
*/
169-
@Deprecated(since = "1.21.6") // Paper
171+
@Deprecated(since = "1.21.6")
170172
public enum Type {
171173
/**
172174
* Statistics of this type do not require a qualifier.
@@ -188,9 +190,9 @@ public enum Type {
188190
*/
189191
ENTITY;
190192
}
191-
// Paper start - add legacy conversion methods
193+
192194
@Deprecated(forRemoval = true)
193-
@org.jetbrains.annotations.ApiStatus.Internal
195+
@ApiStatus.Internal
194196
public static Statistic toLegacy(final io.papermc.paper.statistic.Statistic<?> stat) {
195197
if (stat.type() == StatisticType.CUSTOM && stat.value() instanceof final CustomStatistic customStatistic) {
196198
if (customStatistic == CustomStatistic.PLAY_TIME) { // special case cause upstream is wrong
@@ -219,7 +221,7 @@ public static Statistic toLegacy(final io.papermc.paper.statistic.Statistic<?> s
219221
}
220222

221223
@Deprecated(forRemoval = true)
222-
@org.jetbrains.annotations.ApiStatus.Internal
224+
@ApiStatus.Internal
223225
public io.papermc.paper.statistic.Statistic<?> toModern(@Nullable EntityType entityType, @Nullable Material material) {
224226
Preconditions.checkArgument(entityType == null || material == null, "No stat has an entity type and material value at the same time");
225227
Preconditions.checkArgument(this.type != Type.UNTYPED || (entityType == null && material == null), "no value needed for untyped stats");
@@ -250,5 +252,4 @@ public io.papermc.paper.statistic.Statistic<?> toModern(@Nullable EntityType ent
250252
};
251253
};
252254
}
253-
// Paper end
254255
}

paper-api/src/main/java/org/bukkit/scoreboard/Criteria.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public static Criteria statistic(@NotNull Statistic statistic, @NotNull Material
303303
* @deprecated use {@link io.papermc.paper.statistic.Statistic}
304304
*/
305305
@NotNull
306-
@Deprecated(since = "1.21.6") // Paper
306+
@Deprecated(since = "1.21.6")
307307
public static Criteria statistic(@NotNull Statistic statistic, @NotNull EntityType entityType) {
308308
Preconditions.checkArgument(statistic != null, "statistic must not be null");
309309
Preconditions.checkArgument(entityType != null, "entityType must not be null");

paper-generator/src/main/java/io/papermc/generator/Rewriters.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
import io.papermc.generator.rewriter.types.simple.MaterialRewriter;
2020
import io.papermc.generator.rewriter.types.simple.MemoryKeyRewriter;
2121
import io.papermc.generator.rewriter.types.simple.StatisticRewriter;
22+
import io.papermc.generator.rewriter.types.simple.StatisticTypeRewriter;
2223
import io.papermc.generator.rewriter.types.simple.trial.VillagerProfessionRewriter;
2324
import io.papermc.generator.types.goal.MobGoalNames;
2425
import io.papermc.generator.utils.Formatting;
2526
import io.papermc.paper.datacomponent.item.consumable.ItemUseAnimation;
27+
import io.papermc.paper.statistic.CustomStatistic;
28+
import io.papermc.paper.statistic.StatisticType;
2629
import io.papermc.typewriter.preset.EnumCloneRewriter;
2730
import io.papermc.typewriter.preset.model.EnumValue;
2831
import io.papermc.typewriter.replace.SearchMetadata;
@@ -184,6 +187,8 @@ protected String rewriteFieldName(Holder.Reference<net.minecraft.world.item.Juke
184187
.register("ChickenVariant", Chicken.Variant.class, new RegistryFieldRewriter<>(Registries.CHICKEN_VARIANT, "getVariant"))
185188
.register("CowVariant", Cow.Variant.class, new RegistryFieldRewriter<>(Registries.COW_VARIANT, "getVariant"))
186189
.register("PigVariant", Pig.Variant.class, new RegistryFieldRewriter<>(Registries.PIG_VARIANT, "getVariant"))
190+
.register("CustomStatistic", CustomStatistic.class, new RegistryFieldRewriter<>(Registries.CUSTOM_STAT, "get"))
191+
.register("StatisticType", StatisticType.class, new StatisticTypeRewriter())
187192
.register("MemoryKey", MemoryKey.class, new MemoryKeyRewriter())
188193
// .register("ItemType", ItemType.class, new ItemTypeRewriter()) - disable for now, lynx want the generic type
189194
.register("BlockType", BlockType.class, new BlockTypeRewriter())

0 commit comments

Comments
 (0)