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