SPIGOT-4276: Fix untyped statistics causing client errors

This commit is contained in:
BlackHole 2018-08-15 23:51:10 +02:00 committed by md_5
parent 5bf0abb3ae
commit 375bc637bd

View File

@ -17,66 +17,66 @@ import net.minecraft.server.RegistryMaterials;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public enum CraftStatistic {
DAMAGE_DEALT("damage_dealt"),
DAMAGE_TAKEN("damage_taken"),
DEATHS("deaths"),
MOB_KILLS("mob_kills"),
PLAYER_KILLS("player_kills"),
FISH_CAUGHT("fish_caught"),
ANIMALS_BRED("animals_bred"),
LEAVE_GAME("leave_game"),
JUMP("jump"),
DROP_COUNT("drop"),
DROP("dropped"),
PICKUP("picked_up"),
PLAY_ONE_MINUTE("play_one_minute"),
WALK_ONE_CM("walk_one_cm"),
WALK_ON_WATER_ONE_CM("walk_on_water_one_cm"),
FALL_ONE_CM("fall_one_cm"),
SNEAK_TIME("sneak_time"),
CLIMB_ONE_CM("climb_one_cm"),
FLY_ONE_CM("fly_one_cm"),
WALK_UNDER_WATER_ONE_CM("walk_under_water_one_cm"),
MINECART_ONE_CM("minecart_one_cm"),
BOAT_ONE_CM("boat_one_cm"),
PIG_ONE_CM("pig_one_cm"),
HORSE_ONE_CM("horse_one_cm"),
SPRINT_ONE_CM("sprint_one_cm"),
CROUCH_ONE_CM("crouch_one_cm"),
AVIATE_ONE_CM("aviate_one_cm"),
MINE_BLOCK("mined"),
USE_ITEM("used"),
BREAK_ITEM("broken"),
CRAFT_ITEM("crafted"),
KILL_ENTITY("killed"),
ENTITY_KILLED_BY("killed_by"),
TIME_SINCE_DEATH("time_since_death"),
TALKED_TO_VILLAGER("talked_to_villager"),
TRADED_WITH_VILLAGER("traded_with_villager"),
CAKE_SLICES_EATEN("eat_cake_slice"),
CAULDRON_FILLED("fill_cauldron"),
CAULDRON_USED("use_cauldron"),
ARMOR_CLEANED("clean_armor"),
BANNER_CLEANED("clean_banner"),
BREWINGSTAND_INTERACTION("interact_with_brewingstand"),
BEACON_INTERACTION("interact_with_beacon"),
DROPPER_INSPECTED("inspect_dropper"),
HOPPER_INSPECTED("inspect_hopper"),
DISPENSER_INSPECTED("inspect_dispenser"),
NOTEBLOCK_PLAYED("play_noteblock"),
NOTEBLOCK_TUNED("tune_noteblock"),
FLOWER_POTTED("pot_flower"),
TRAPPED_CHEST_TRIGGERED("trigger_trapped_chest"),
ENDERCHEST_OPENED("open_enderchest"),
ITEM_ENCHANTED("enchant_item"),
RECORD_PLAYED("play_record"),
FURNACE_INTERACTION("interact_with_furnace"),
CRAFTING_TABLE_INTERACTION("interact_with_crafting_table"),
CHEST_OPENED("open_chest"),
SLEEP_IN_BED("sleep_in_bed"),
SHULKER_BOX_OPENED("open_shulker_box"),
TIME_SINCE_REST("time_since_rest"),
SWIM_ONE_CM("swim_one_cm");
DAMAGE_DEALT(StatisticList.DAMAGE_DEALT),
DAMAGE_TAKEN(StatisticList.DAMAGE_TAKEN),
DEATHS(StatisticList.DEATHS),
MOB_KILLS(StatisticList.MOB_KILLS),
PLAYER_KILLS(StatisticList.PLAYER_KILLS),
FISH_CAUGHT(StatisticList.FISH_CAUGHT),
ANIMALS_BRED(StatisticList.ANIMALS_BRED),
LEAVE_GAME(StatisticList.LEAVE_GAME),
JUMP(StatisticList.JUMP),
DROP_COUNT(StatisticList.DROP),
DROP(new MinecraftKey("dropped")),
PICKUP(new MinecraftKey("picked_up")),
PLAY_ONE_MINUTE(StatisticList.PLAY_ONE_MINUTE),
WALK_ONE_CM(StatisticList.WALK_ONE_CM),
WALK_ON_WATER_ONE_CM(StatisticList.WALK_ON_WATER_ONE_CM),
FALL_ONE_CM(StatisticList.FALL_ONE_CM),
SNEAK_TIME(StatisticList.SNEAK_TIME),
CLIMB_ONE_CM(StatisticList.CLIMB_ONE_CM),
FLY_ONE_CM(StatisticList.FLY_ONE_CM),
WALK_UNDER_WATER_ONE_CM(StatisticList.WALK_UNDER_WATER_ONE_CM),
MINECART_ONE_CM(StatisticList.MINECART_ONE_CM),
BOAT_ONE_CM(StatisticList.BOAT_ONE_CM),
PIG_ONE_CM(StatisticList.PIG_ONE_CM),
HORSE_ONE_CM(StatisticList.HORSE_ONE_CM),
SPRINT_ONE_CM(StatisticList.SPRINT_ONE_CM),
CROUCH_ONE_CM(StatisticList.CROUCH_ONE_CM),
AVIATE_ONE_CM(StatisticList.AVIATE_ONE_CM),
MINE_BLOCK(new MinecraftKey("mined")),
USE_ITEM(new MinecraftKey("used")),
BREAK_ITEM(new MinecraftKey("broken")),
CRAFT_ITEM(new MinecraftKey("crafted")),
KILL_ENTITY(new MinecraftKey("killed")),
ENTITY_KILLED_BY(new MinecraftKey("killed_by")),
TIME_SINCE_DEATH(StatisticList.TIME_SINCE_DEATH),
TALKED_TO_VILLAGER(StatisticList.TALKED_TO_VILLAGER),
TRADED_WITH_VILLAGER(StatisticList.TRADED_WITH_VILLAGER),
CAKE_SLICES_EATEN(StatisticList.EAT_CAKE_SLICE),
CAULDRON_FILLED(StatisticList.FILL_CAULDRON),
CAULDRON_USED(StatisticList.USE_CAULDRON),
ARMOR_CLEANED(StatisticList.CLEAN_ARMOR),
BANNER_CLEANED(StatisticList.CLEAN_BANNER),
BREWINGSTAND_INTERACTION(StatisticList.INTERACT_WITH_BREWINGSTAND),
BEACON_INTERACTION(StatisticList.INTERACT_WITH_BEACON),
DROPPER_INSPECTED(StatisticList.INSPECT_DROPPER),
HOPPER_INSPECTED(StatisticList.INSPECT_HOPPER),
DISPENSER_INSPECTED(StatisticList.INSPECT_DISPENSER),
NOTEBLOCK_PLAYED(StatisticList.PLAY_NOTEBLOCK),
NOTEBLOCK_TUNED(StatisticList.TUNE_NOTEBLOCK),
FLOWER_POTTED(StatisticList.POT_FLOWER),
TRAPPED_CHEST_TRIGGERED(StatisticList.TRIGGER_TRAPPED_CHEST),
ENDERCHEST_OPENED(StatisticList.OPEN_ENDERCHEST),
ITEM_ENCHANTED(StatisticList.ENCHANT_ITEM),
RECORD_PLAYED(StatisticList.PLAY_RECORD),
FURNACE_INTERACTION(StatisticList.INTERACT_WITH_FURNACE),
CRAFTING_TABLE_INTERACTION(StatisticList.INTERACT_WITH_CRAFTING_TABLE),
CHEST_OPENED(StatisticList.OPEN_CHEST),
SLEEP_IN_BED(StatisticList.SLEEP_IN_BED),
SHULKER_BOX_OPENED(StatisticList.OPEN_SHULKER_BOX),
TIME_SINCE_REST(StatisticList.n),
SWIM_ONE_CM(StatisticList.SWIM_ONE_CM);
private final MinecraftKey minecraftKey;
private final org.bukkit.Statistic bukkit;
private static final BiMap<MinecraftKey, org.bukkit.Statistic> statistics;
@ -90,8 +90,8 @@ public enum CraftStatistic {
statistics = statisticBuilder.build();
}
private CraftStatistic(String minecraftKey) {
this.minecraftKey = new MinecraftKey(minecraftKey);
private CraftStatistic(MinecraftKey minecraftKey) {
this.minecraftKey = minecraftKey;
this.bukkit = org.bukkit.Statistic.valueOf(this.name());
Preconditions.checkState(bukkit != null, "Bukkit statistic %s does not exist", this.name());