diff options
Diffstat (limited to 'src/WorldStorage')
-rw-r--r-- | src/WorldStorage/NamespaceSerializer.cpp | 442 | ||||
-rw-r--r-- | src/WorldStorage/NamespaceSerializer.h | 4 | ||||
-rw-r--r-- | src/WorldStorage/StatSerializer.cpp | 201 | ||||
-rw-r--r-- | src/WorldStorage/StatSerializer.h | 7 |
4 files changed, 325 insertions, 329 deletions
diff --git a/src/WorldStorage/NamespaceSerializer.cpp b/src/WorldStorage/NamespaceSerializer.cpp index 8a4c9ea9b..2e2e9302e 100644 --- a/src/WorldStorage/NamespaceSerializer.cpp +++ b/src/WorldStorage/NamespaceSerializer.cpp @@ -15,123 +15,123 @@ unsigned NamespaceSerializer::DataVersion() -std::string_view NamespaceSerializer::From(const Statistic a_ID) +std::string_view NamespaceSerializer::From(const CustomStatistic a_ID) { switch (a_ID) { - case Statistic::AnimalsBred: return "animals_bred"; - case Statistic::AviateOneCm: return "aviate_one_cm"; - case Statistic::BellRing: return "bell_ring"; - case Statistic::BoatOneCm: return "boat_one_cm"; - case Statistic::CleanArmor: return "clean_armor"; - case Statistic::CleanBanner: return "clean_banner"; - case Statistic::CleanShulkerBox: return "clean_shulker_box"; - case Statistic::ClimbOneCm: return "climb_one_cm"; - case Statistic::CrouchOneCm: return "crouch_one_cm"; - case Statistic::DamageAbsorbed: return "damage_absorbed"; - case Statistic::DamageBlockedByShield: return "damage_blocked_by_shield"; - case Statistic::DamageDealt: return "damage_dealt"; - case Statistic::DamageDealtAbsorbed: return "damage_dealt_absorbed"; - case Statistic::DamageDealtResisted: return "damage_dealt_resisted"; - case Statistic::DamageResisted: return "damage_resisted"; - case Statistic::DamageTaken: return "damage_taken"; - case Statistic::Deaths: return "deaths"; - case Statistic::Drop: return "drop"; - case Statistic::EatCakeSlice: return "eat_cake_slice"; - case Statistic::EnchantItem: return "enchant_item"; - case Statistic::FallOneCm: return "fall_one_cm"; - case Statistic::FillCauldron: return "fill_cauldron"; - case Statistic::FishCaught: return "fish_caught"; - case Statistic::FlyOneCm: return "fly_one_cm"; - case Statistic::HorseOneCm: return "horse_one_cm"; - case Statistic::InspectDispenser: return "inspect_dispenser"; - case Statistic::InspectDropper: return "inspect_dropper"; - case Statistic::InspectHopper: return "inspect_hopper"; - case Statistic::InteractWithAnvil: return "interact_with_anvil"; - case Statistic::InteractWithBeacon: return "interact_with_beacon"; - case Statistic::InteractWithBlastFurnace: return "interact_with_blast_furnace"; - case Statistic::InteractWithBrewingstand: return "interact_with_brewingstand"; - case Statistic::InteractWithCampfire: return "interact_with_campfire"; - case Statistic::InteractWithCartographyTable: return "interact_with_cartography_table"; - case Statistic::InteractWithCraftingTable: return "interact_with_crafting_table"; - case Statistic::InteractWithFurnace: return "interact_with_furnace"; - case Statistic::InteractWithGrindstone: return "interact_with_grindstone"; - case Statistic::InteractWithLectern: return "interact_with_lectern"; - case Statistic::InteractWithLoom: return "interact_with_loom"; - case Statistic::InteractWithSmithingTable: return "interact_with_smithing_table"; - case Statistic::InteractWithSmoker: return "interact_with_smoker"; - case Statistic::InteractWithStonecutter: return "interact_with_stonecutter"; - case Statistic::Jump: return "jump"; - case Statistic::LeaveGame: return "leave_game"; - case Statistic::MinecartOneCm: return "minecart_one_cm"; - case Statistic::MobKills: return "mob_kills"; - case Statistic::OpenBarrel: return "open_barrel"; - case Statistic::OpenChest: return "open_chest"; - case Statistic::OpenEnderchest: return "open_enderchest"; - case Statistic::OpenShulkerBox: return "open_shulker_box"; - case Statistic::PigOneCm: return "pig_one_cm"; - case Statistic::PlayNoteblock: return "play_noteblock"; - case Statistic::PlayOneMinute: return "play_one_minute"; - case Statistic::PlayRecord: return "play_record"; - case Statistic::PlayerKills: return "player_kills"; - case Statistic::PotFlower: return "pot_flower"; - case Statistic::RaidTrigger: return "raid_trigger"; - case Statistic::RaidWin: return "raid_win"; - case Statistic::SleepInBed: return "sleep_in_bed"; - case Statistic::SneakTime: return "sneak_time"; - case Statistic::SprintOneCm: return "sprint_one_cm"; - case Statistic::StriderOneCm: return "strider_one_cm"; - case Statistic::SwimOneCm: return "swim_one_cm"; - case Statistic::TalkedToVillager: return "talked_to_villager"; - case Statistic::TargetHit: return "target_hit"; - case Statistic::TimeSinceDeath: return "time_since_death"; - case Statistic::TimeSinceRest: return "time_since_rest"; - case Statistic::TradedWithVillager: return "traded_with_villager"; - case Statistic::TriggerTrappedChest: return "trigger_trapped_chest"; - case Statistic::TuneNoteblock: return "tune_noteblock"; - case Statistic::UseCauldron: return "use_cauldron"; - case Statistic::WalkOnWaterOneCm: return "walk_on_water_one_cm"; - case Statistic::WalkOneCm: return "walk_one_cm"; - case Statistic::WalkUnderWaterOneCm: return "walk_under_water_one_cm"; + case CustomStatistic::AnimalsBred: return "animals_bred"; + case CustomStatistic::AviateOneCm: return "aviate_one_cm"; + case CustomStatistic::BellRing: return "bell_ring"; + case CustomStatistic::BoatOneCm: return "boat_one_cm"; + case CustomStatistic::CleanArmor: return "clean_armor"; + case CustomStatistic::CleanBanner: return "clean_banner"; + case CustomStatistic::CleanShulkerBox: return "clean_shulker_box"; + case CustomStatistic::ClimbOneCm: return "climb_one_cm"; + case CustomStatistic::CrouchOneCm: return "crouch_one_cm"; + case CustomStatistic::DamageAbsorbed: return "damage_absorbed"; + case CustomStatistic::DamageBlockedByShield: return "damage_blocked_by_shield"; + case CustomStatistic::DamageDealt: return "damage_dealt"; + case CustomStatistic::DamageDealtAbsorbed: return "damage_dealt_absorbed"; + case CustomStatistic::DamageDealtResisted: return "damage_dealt_resisted"; + case CustomStatistic::DamageResisted: return "damage_resisted"; + case CustomStatistic::DamageTaken: return "damage_taken"; + case CustomStatistic::Deaths: return "deaths"; + case CustomStatistic::Drop: return "drop"; + case CustomStatistic::EatCakeSlice: return "eat_cake_slice"; + case CustomStatistic::EnchantItem: return "enchant_item"; + case CustomStatistic::FallOneCm: return "fall_one_cm"; + case CustomStatistic::FillCauldron: return "fill_cauldron"; + case CustomStatistic::FishCaught: return "fish_caught"; + case CustomStatistic::FlyOneCm: return "fly_one_cm"; + case CustomStatistic::HorseOneCm: return "horse_one_cm"; + case CustomStatistic::InspectDispenser: return "inspect_dispenser"; + case CustomStatistic::InspectDropper: return "inspect_dropper"; + case CustomStatistic::InspectHopper: return "inspect_hopper"; + case CustomStatistic::InteractWithAnvil: return "interact_with_anvil"; + case CustomStatistic::InteractWithBeacon: return "interact_with_beacon"; + case CustomStatistic::InteractWithBlastFurnace: return "interact_with_blast_furnace"; + case CustomStatistic::InteractWithBrewingstand: return "interact_with_brewingstand"; + case CustomStatistic::InteractWithCampfire: return "interact_with_campfire"; + case CustomStatistic::InteractWithCartographyTable: return "interact_with_cartography_table"; + case CustomStatistic::InteractWithCraftingTable: return "interact_with_crafting_table"; + case CustomStatistic::InteractWithFurnace: return "interact_with_furnace"; + case CustomStatistic::InteractWithGrindstone: return "interact_with_grindstone"; + case CustomStatistic::InteractWithLectern: return "interact_with_lectern"; + case CustomStatistic::InteractWithLoom: return "interact_with_loom"; + case CustomStatistic::InteractWithSmithingTable: return "interact_with_smithing_table"; + case CustomStatistic::InteractWithSmoker: return "interact_with_smoker"; + case CustomStatistic::InteractWithStonecutter: return "interact_with_stonecutter"; + case CustomStatistic::Jump: return "jump"; + case CustomStatistic::LeaveGame: return "leave_game"; + case CustomStatistic::MinecartOneCm: return "minecart_one_cm"; + case CustomStatistic::MobKills: return "mob_kills"; + case CustomStatistic::OpenBarrel: return "open_barrel"; + case CustomStatistic::OpenChest: return "open_chest"; + case CustomStatistic::OpenEnderchest: return "open_enderchest"; + case CustomStatistic::OpenShulkerBox: return "open_shulker_box"; + case CustomStatistic::PigOneCm: return "pig_one_cm"; + case CustomStatistic::PlayNoteblock: return "play_noteblock"; + case CustomStatistic::PlayOneMinute: return "play_one_minute"; + case CustomStatistic::PlayRecord: return "play_record"; + case CustomStatistic::PlayerKills: return "player_kills"; + case CustomStatistic::PotFlower: return "pot_flower"; + case CustomStatistic::RaidTrigger: return "raid_trigger"; + case CustomStatistic::RaidWin: return "raid_win"; + case CustomStatistic::SleepInBed: return "sleep_in_bed"; + case CustomStatistic::SneakTime: return "sneak_time"; + case CustomStatistic::SprintOneCm: return "sprint_one_cm"; + case CustomStatistic::StriderOneCm: return "strider_one_cm"; + case CustomStatistic::SwimOneCm: return "swim_one_cm"; + case CustomStatistic::TalkedToVillager: return "talked_to_villager"; + case CustomStatistic::TargetHit: return "target_hit"; + case CustomStatistic::TimeSinceDeath: return "time_since_death"; + case CustomStatistic::TimeSinceRest: return "time_since_rest"; + case CustomStatistic::TradedWithVillager: return "traded_with_villager"; + case CustomStatistic::TriggerTrappedChest: return "trigger_trapped_chest"; + case CustomStatistic::TuneNoteblock: return "tune_noteblock"; + case CustomStatistic::UseCauldron: return "use_cauldron"; + case CustomStatistic::WalkOnWaterOneCm: return "walk_on_water_one_cm"; + case CustomStatistic::WalkOneCm: return "walk_one_cm"; + case CustomStatistic::WalkUnderWaterOneCm: return "walk_under_water_one_cm"; // Old ones just for compatibility - case Statistic::JunkFished: return "junk_fished"; - case Statistic::TreasureFished: return "treasure_fished"; + case CustomStatistic::JunkFished: return "junk_fished"; + case CustomStatistic::TreasureFished: return "treasure_fished"; // The old advancements - case Statistic::AchOpenInventory: return "cuberite:achievement.openInventory"; - case Statistic::AchMineWood: return "cuberite:achievement.mineWood"; - case Statistic::AchBuildWorkBench: return "cuberite:achievement.buildWorkBench"; - case Statistic::AchBuildPickaxe: return "cuberite:achievement.buildPickaxe"; - case Statistic::AchBuildFurnace: return "cuberite:achievement.buildFurnace"; - case Statistic::AchAcquireIron: return "cuberite:achievement.acquireIron"; - case Statistic::AchBuildHoe: return "cuberite:achievement.buildHoe"; - case Statistic::AchMakeBread: return "cuberite:achievement.makeBread"; - case Statistic::AchBakeCake: return "cuberite:achievement.bakeCake"; - case Statistic::AchBuildBetterPickaxe: return "cuberite:achievement.buildBetterPickaxe"; - case Statistic::AchCookFish: return "cuberite:achievement.cookFish"; - case Statistic::AchOnARail: return "cuberite:achievement.onARail"; - case Statistic::AchBuildSword: return "cuberite:achievement.buildSword"; - case Statistic::AchKillEnemy: return "cuberite:achievement.killEnemy"; - case Statistic::AchKillCow: return "cuberite:achievement.killCow"; - case Statistic::AchFlyPig: return "cuberite:achievement.flyPig"; - case Statistic::AchSnipeSkeleton: return "cuberite:achievement.snipeSkeleton"; - case Statistic::AchDiamonds: return "cuberite:achievement.diamonds"; - case Statistic::AchPortal: return "cuberite:achievement.portal"; - case Statistic::AchGhast: return "cuberite:achievement.ghast"; - case Statistic::AchBlazeRod: return "cuberite:achievement.blazeRod"; - case Statistic::AchPotion: return "cuberite:achievement.potion"; - case Statistic::AchTheEnd: return "cuberite:achievement.theEnd"; - case Statistic::AchTheEnd2: return "cuberite:achievement.theEnd2"; - case Statistic::AchEnchantments: return "cuberite:achievement.enchantments"; - case Statistic::AchOverkill: return "cuberite:achievement.overkill"; - case Statistic::AchBookcase: return "cuberite:achievement.bookcase"; - case Statistic::AchExploreAllBiomes: return "cuberite:achievement.exploreAllBiomes"; - case Statistic::AchSpawnWither: return "cuberite:achievement.spawnWither"; - case Statistic::AchKillWither: return "cuberite:achievement.killWither"; - case Statistic::AchFullBeacon: return "cuberite:achievement.fullBeacon"; - case Statistic::AchBreedCow: return "cuberite:achievement.breedCow"; - case Statistic::AchDiamondsToYou: return "cuberite:achievement.diamondsToYou"; + case CustomStatistic::AchOpenInventory: return "cuberite:achievement.openInventory"; + case CustomStatistic::AchMineWood: return "cuberite:achievement.mineWood"; + case CustomStatistic::AchBuildWorkBench: return "cuberite:achievement.buildWorkBench"; + case CustomStatistic::AchBuildPickaxe: return "cuberite:achievement.buildPickaxe"; + case CustomStatistic::AchBuildFurnace: return "cuberite:achievement.buildFurnace"; + case CustomStatistic::AchAcquireIron: return "cuberite:achievement.acquireIron"; + case CustomStatistic::AchBuildHoe: return "cuberite:achievement.buildHoe"; + case CustomStatistic::AchMakeBread: return "cuberite:achievement.makeBread"; + case CustomStatistic::AchBakeCake: return "cuberite:achievement.bakeCake"; + case CustomStatistic::AchBuildBetterPickaxe: return "cuberite:achievement.buildBetterPickaxe"; + case CustomStatistic::AchCookFish: return "cuberite:achievement.cookFish"; + case CustomStatistic::AchOnARail: return "cuberite:achievement.onARail"; + case CustomStatistic::AchBuildSword: return "cuberite:achievement.buildSword"; + case CustomStatistic::AchKillEnemy: return "cuberite:achievement.killEnemy"; + case CustomStatistic::AchKillCow: return "cuberite:achievement.killCow"; + case CustomStatistic::AchFlyPig: return "cuberite:achievement.flyPig"; + case CustomStatistic::AchSnipeSkeleton: return "cuberite:achievement.snipeSkeleton"; + case CustomStatistic::AchDiamonds: return "cuberite:achievement.diamonds"; + case CustomStatistic::AchPortal: return "cuberite:achievement.portal"; + case CustomStatistic::AchGhast: return "cuberite:achievement.ghast"; + case CustomStatistic::AchBlazeRod: return "cuberite:achievement.blazeRod"; + case CustomStatistic::AchPotion: return "cuberite:achievement.potion"; + case CustomStatistic::AchTheEnd: return "cuberite:achievement.theEnd"; + case CustomStatistic::AchTheEnd2: return "cuberite:achievement.theEnd2"; + case CustomStatistic::AchEnchantments: return "cuberite:achievement.enchantments"; + case CustomStatistic::AchOverkill: return "cuberite:achievement.overkill"; + case CustomStatistic::AchBookcase: return "cuberite:achievement.bookcase"; + case CustomStatistic::AchExploreAllBiomes: return "cuberite:achievement.exploreAllBiomes"; + case CustomStatistic::AchSpawnWither: return "cuberite:achievement.spawnWither"; + case CustomStatistic::AchKillWither: return "cuberite:achievement.killWither"; + case CustomStatistic::AchFullBeacon: return "cuberite:achievement.fullBeacon"; + case CustomStatistic::AchBreedCow: return "cuberite:achievement.breedCow"; + case CustomStatistic::AchDiamondsToYou: return "cuberite:achievement.diamondsToYou"; } UNREACHABLE("Tried to save unhandled statistic"); } @@ -274,123 +274,123 @@ std::string_view NamespaceSerializer::From(const BannerPattern a_Pattern) -Statistic NamespaceSerializer::ToCustomStatistic(const std::string_view ID) +CustomStatistic NamespaceSerializer::ToCustomStatistic(const std::string_view ID) { - static const std::unordered_map<std::string_view, Statistic> CustomStatistics + static const std::unordered_map<std::string_view, CustomStatistic> CustomStatistics { - { "animals_bred", Statistic::AnimalsBred }, - { "aviate_one_cm", Statistic::AviateOneCm }, - { "bell_ring", Statistic::BellRing }, - { "boat_one_cm", Statistic::BoatOneCm }, - { "clean_armor", Statistic::CleanArmor }, - { "clean_banner", Statistic::CleanBanner }, - { "clean_shulker_box", Statistic::CleanShulkerBox }, - { "climb_one_cm", Statistic::ClimbOneCm }, - { "crouch_one_cm", Statistic::CrouchOneCm }, - { "damage_absorbed", Statistic::DamageAbsorbed }, - { "damage_blocked_by_shield", Statistic::DamageBlockedByShield }, - { "damage_dealt", Statistic::DamageDealt }, - { "damage_dealt_absorbed", Statistic::DamageDealtAbsorbed }, - { "damage_dealt_resisted", Statistic::DamageDealtResisted }, - { "damage_resisted", Statistic::DamageResisted }, - { "damage_taken", Statistic::DamageTaken }, - { "deaths", Statistic::Deaths }, - { "drop", Statistic::Drop }, - { "eat_cake_slice", Statistic::EatCakeSlice }, - { "enchant_item", Statistic::EnchantItem }, - { "fall_one_cm", Statistic::FallOneCm }, - { "fill_cauldron", Statistic::FillCauldron }, - { "fish_caught", Statistic::FishCaught }, - { "fly_one_cm", Statistic::FlyOneCm }, - { "horse_one_cm", Statistic::HorseOneCm }, - { "inspect_dispenser", Statistic::InspectDispenser }, - { "inspect_dropper", Statistic::InspectDropper }, - { "inspect_hopper", Statistic::InspectHopper }, - { "interact_with_anvil", Statistic::InteractWithAnvil }, - { "interact_with_beacon", Statistic::InteractWithBeacon }, - { "interact_with_blast_furnace", Statistic::InteractWithBlastFurnace }, - { "interact_with_brewingstand", Statistic::InteractWithBrewingstand }, - { "interact_with_campfire", Statistic::InteractWithCampfire }, - { "interact_with_cartography_table", Statistic::InteractWithCartographyTable }, - { "interact_with_crafting_table", Statistic::InteractWithCraftingTable }, - { "interact_with_furnace", Statistic::InteractWithFurnace }, - { "interact_with_grindstone", Statistic::InteractWithGrindstone }, - { "interact_with_lectern", Statistic::InteractWithLectern }, - { "interact_with_loom", Statistic::InteractWithLoom }, - { "interact_with_smithing_table", Statistic::InteractWithSmithingTable }, - { "interact_with_smoker", Statistic::InteractWithSmoker }, - { "interact_with_stonecutter", Statistic::InteractWithStonecutter }, - { "jump", Statistic::Jump }, - { "leave_game", Statistic::LeaveGame }, - { "minecart_one_cm", Statistic::MinecartOneCm }, - { "mob_kills", Statistic::MobKills }, - { "open_barrel", Statistic::OpenBarrel }, - { "open_chest", Statistic::OpenChest }, - { "open_enderchest", Statistic::OpenEnderchest }, - { "open_shulker_box", Statistic::OpenShulkerBox }, - { "pig_one_cm", Statistic::PigOneCm }, - { "play_noteblock", Statistic::PlayNoteblock }, - { "play_one_minute", Statistic::PlayOneMinute }, - { "play_record", Statistic::PlayRecord }, - { "player_kills", Statistic::PlayerKills }, - { "pot_flower", Statistic::PotFlower }, - { "raid_trigger", Statistic::RaidTrigger }, - { "raid_win", Statistic::RaidWin }, - { "sleep_in_bed", Statistic::SleepInBed }, - { "sneak_time", Statistic::SneakTime }, - { "sprint_one_cm", Statistic::SprintOneCm }, - { "strider_one_cm", Statistic::StriderOneCm }, - { "swim_one_cm", Statistic::SwimOneCm }, - { "talked_to_villager", Statistic::TalkedToVillager }, - { "target_hit", Statistic::TargetHit }, - { "time_since_death", Statistic::TimeSinceDeath }, - { "time_since_rest", Statistic::TimeSinceRest }, - { "traded_with_villager", Statistic::TradedWithVillager }, - { "trigger_trapped_chest", Statistic::TriggerTrappedChest }, - { "tune_noteblock", Statistic::TuneNoteblock }, - { "use_cauldron", Statistic::UseCauldron }, - { "walk_on_water_one_cm", Statistic::WalkOnWaterOneCm }, - { "walk_one_cm", Statistic::WalkOneCm }, - { "walk_under_water_one_cm", Statistic::WalkUnderWaterOneCm }, + { "animals_bred", CustomStatistic::AnimalsBred }, + { "aviate_one_cm", CustomStatistic::AviateOneCm }, + { "bell_ring", CustomStatistic::BellRing }, + { "boat_one_cm", CustomStatistic::BoatOneCm }, + { "clean_armor", CustomStatistic::CleanArmor }, + { "clean_banner", CustomStatistic::CleanBanner }, + { "clean_shulker_box", CustomStatistic::CleanShulkerBox }, + { "climb_one_cm", CustomStatistic::ClimbOneCm }, + { "crouch_one_cm", CustomStatistic::CrouchOneCm }, + { "damage_absorbed", CustomStatistic::DamageAbsorbed }, + { "damage_blocked_by_shield", CustomStatistic::DamageBlockedByShield }, + { "damage_dealt", CustomStatistic::DamageDealt }, + { "damage_dealt_absorbed", CustomStatistic::DamageDealtAbsorbed }, + { "damage_dealt_resisted", CustomStatistic::DamageDealtResisted }, + { "damage_resisted", CustomStatistic::DamageResisted }, + { "damage_taken", CustomStatistic::DamageTaken }, + { "deaths", CustomStatistic::Deaths }, + { "drop", CustomStatistic::Drop }, + { "eat_cake_slice", CustomStatistic::EatCakeSlice }, + { "enchant_item", CustomStatistic::EnchantItem }, + { "fall_one_cm", CustomStatistic::FallOneCm }, + { "fill_cauldron", CustomStatistic::FillCauldron }, + { "fish_caught", CustomStatistic::FishCaught }, + { "fly_one_cm", CustomStatistic::FlyOneCm }, + { "horse_one_cm", CustomStatistic::HorseOneCm }, + { "inspect_dispenser", CustomStatistic::InspectDispenser }, + { "inspect_dropper", CustomStatistic::InspectDropper }, + { "inspect_hopper", CustomStatistic::InspectHopper }, + { "interact_with_anvil", CustomStatistic::InteractWithAnvil }, + { "interact_with_beacon", CustomStatistic::InteractWithBeacon }, + { "interact_with_blast_furnace", CustomStatistic::InteractWithBlastFurnace }, + { "interact_with_brewingstand", CustomStatistic::InteractWithBrewingstand }, + { "interact_with_campfire", CustomStatistic::InteractWithCampfire }, + { "interact_with_cartography_table", CustomStatistic::InteractWithCartographyTable }, + { "interact_with_crafting_table", CustomStatistic::InteractWithCraftingTable }, + { "interact_with_furnace", CustomStatistic::InteractWithFurnace }, + { "interact_with_grindstone", CustomStatistic::InteractWithGrindstone }, + { "interact_with_lectern", CustomStatistic::InteractWithLectern }, + { "interact_with_loom", CustomStatistic::InteractWithLoom }, + { "interact_with_smithing_table", CustomStatistic::InteractWithSmithingTable }, + { "interact_with_smoker", CustomStatistic::InteractWithSmoker }, + { "interact_with_stonecutter", CustomStatistic::InteractWithStonecutter }, + { "jump", CustomStatistic::Jump }, + { "leave_game", CustomStatistic::LeaveGame }, + { "minecart_one_cm", CustomStatistic::MinecartOneCm }, + { "mob_kills", CustomStatistic::MobKills }, + { "open_barrel", CustomStatistic::OpenBarrel }, + { "open_chest", CustomStatistic::OpenChest }, + { "open_enderchest", CustomStatistic::OpenEnderchest }, + { "open_shulker_box", CustomStatistic::OpenShulkerBox }, + { "pig_one_cm", CustomStatistic::PigOneCm }, + { "play_noteblock", CustomStatistic::PlayNoteblock }, + { "play_one_minute", CustomStatistic::PlayOneMinute }, + { "play_record", CustomStatistic::PlayRecord }, + { "player_kills", CustomStatistic::PlayerKills }, + { "pot_flower", CustomStatistic::PotFlower }, + { "raid_trigger", CustomStatistic::RaidTrigger }, + { "raid_win", CustomStatistic::RaidWin }, + { "sleep_in_bed", CustomStatistic::SleepInBed }, + { "sneak_time", CustomStatistic::SneakTime }, + { "sprint_one_cm", CustomStatistic::SprintOneCm }, + { "strider_one_cm", CustomStatistic::StriderOneCm }, + { "swim_one_cm", CustomStatistic::SwimOneCm }, + { "talked_to_villager", CustomStatistic::TalkedToVillager }, + { "target_hit", CustomStatistic::TargetHit }, + { "time_since_death", CustomStatistic::TimeSinceDeath }, + { "time_since_rest", CustomStatistic::TimeSinceRest }, + { "traded_with_villager", CustomStatistic::TradedWithVillager }, + { "trigger_trapped_chest", CustomStatistic::TriggerTrappedChest }, + { "tune_noteblock", CustomStatistic::TuneNoteblock }, + { "use_cauldron", CustomStatistic::UseCauldron }, + { "walk_on_water_one_cm", CustomStatistic::WalkOnWaterOneCm }, + { "walk_one_cm", CustomStatistic::WalkOneCm }, + { "walk_under_water_one_cm", CustomStatistic::WalkUnderWaterOneCm }, // Old ones just for compatibility - { "junk_fished", Statistic::JunkFished }, - { "treasure_fished", Statistic::TreasureFished }, + { "junk_fished", CustomStatistic::JunkFished }, + { "treasure_fished", CustomStatistic::TreasureFished }, // The old advancements - { "cuberite:achievement.openInventory", Statistic::AchOpenInventory }, - { "cuberite:achievement.mineWood", Statistic::AchMineWood }, - { "cuberite:achievement.buildWorkBench", Statistic::AchBuildWorkBench }, - { "cuberite:achievement.buildPickaxe", Statistic::AchBuildPickaxe }, - { "cuberite:achievement.buildFurnace", Statistic::AchBuildFurnace }, - { "cuberite:achievement.acquireIron", Statistic::AchAcquireIron }, - { "cuberite:achievement.buildHoe", Statistic::AchBuildHoe }, - { "cuberite:achievement.makeBread", Statistic::AchMakeBread }, - { "cuberite:achievement.bakeCake", Statistic::AchBakeCake }, - { "cuberite:achievement.buildBetterPickaxe", Statistic::AchBuildBetterPickaxe }, - { "cuberite:achievement.cookFish", Statistic::AchCookFish }, - { "cuberite:achievement.onARail", Statistic::AchOnARail }, - { "cuberite:achievement.buildSword", Statistic::AchBuildSword }, - { "cuberite:achievement.killEnemy", Statistic::AchKillEnemy }, - { "cuberite:achievement.killCow", Statistic::AchKillCow }, - { "cuberite:achievement.flyPig", Statistic::AchFlyPig }, - { "cuberite:achievement.snipeSkeleton", Statistic::AchSnipeSkeleton }, - { "cuberite:achievement.diamonds", Statistic::AchDiamonds }, - { "cuberite:achievement.portal", Statistic::AchPortal }, - { "cuberite:achievement.ghast", Statistic::AchGhast }, - { "cuberite:achievement.blazeRod", Statistic::AchBlazeRod }, - { "cuberite:achievement.potion", Statistic::AchPotion }, - { "cuberite:achievement.theEnd", Statistic::AchTheEnd }, - { "cuberite:achievement.theEnd2", Statistic::AchTheEnd2 }, - { "cuberite:achievement.enchantments", Statistic::AchEnchantments }, - { "cuberite:achievement.overkill", Statistic::AchOverkill }, - { "cuberite:achievement.bookcase", Statistic::AchBookcase }, - { "cuberite:achievement.exploreAllBiomes", Statistic::AchExploreAllBiomes }, - { "cuberite:achievement.spawnWither", Statistic::AchSpawnWither }, - { "cuberite:achievement.killWither", Statistic::AchKillWither }, - { "cuberite:achievement.fullBeacon", Statistic::AchFullBeacon }, - { "cuberite:achievement.breedCow", Statistic::AchBreedCow }, - { "cuberite:achievement.diamondsToYou", Statistic::AchDiamondsToYou} + { "cuberite:achievement.openInventory", CustomStatistic::AchOpenInventory }, + { "cuberite:achievement.mineWood", CustomStatistic::AchMineWood }, + { "cuberite:achievement.buildWorkBench", CustomStatistic::AchBuildWorkBench }, + { "cuberite:achievement.buildPickaxe", CustomStatistic::AchBuildPickaxe }, + { "cuberite:achievement.buildFurnace", CustomStatistic::AchBuildFurnace }, + { "cuberite:achievement.acquireIron", CustomStatistic::AchAcquireIron }, + { "cuberite:achievement.buildHoe", CustomStatistic::AchBuildHoe }, + { "cuberite:achievement.makeBread", CustomStatistic::AchMakeBread }, + { "cuberite:achievement.bakeCake", CustomStatistic::AchBakeCake }, + { "cuberite:achievement.buildBetterPickaxe", CustomStatistic::AchBuildBetterPickaxe }, + { "cuberite:achievement.cookFish", CustomStatistic::AchCookFish }, + { "cuberite:achievement.onARail", CustomStatistic::AchOnARail }, + { "cuberite:achievement.buildSword", CustomStatistic::AchBuildSword }, + { "cuberite:achievement.killEnemy", CustomStatistic::AchKillEnemy }, + { "cuberite:achievement.killCow", CustomStatistic::AchKillCow }, + { "cuberite:achievement.flyPig", CustomStatistic::AchFlyPig }, + { "cuberite:achievement.snipeSkeleton", CustomStatistic::AchSnipeSkeleton }, + { "cuberite:achievement.diamonds", CustomStatistic::AchDiamonds }, + { "cuberite:achievement.portal", CustomStatistic::AchPortal }, + { "cuberite:achievement.ghast", CustomStatistic::AchGhast }, + { "cuberite:achievement.blazeRod", CustomStatistic::AchBlazeRod }, + { "cuberite:achievement.potion", CustomStatistic::AchPotion }, + { "cuberite:achievement.theEnd", CustomStatistic::AchTheEnd }, + { "cuberite:achievement.theEnd2", CustomStatistic::AchTheEnd2 }, + { "cuberite:achievement.enchantments", CustomStatistic::AchEnchantments }, + { "cuberite:achievement.overkill", CustomStatistic::AchOverkill }, + { "cuberite:achievement.bookcase", CustomStatistic::AchBookcase }, + { "cuberite:achievement.exploreAllBiomes", CustomStatistic::AchExploreAllBiomes }, + { "cuberite:achievement.spawnWither", CustomStatistic::AchSpawnWither }, + { "cuberite:achievement.killWither", CustomStatistic::AchKillWither }, + { "cuberite:achievement.fullBeacon", CustomStatistic::AchFullBeacon }, + { "cuberite:achievement.breedCow", CustomStatistic::AchBreedCow }, + { "cuberite:achievement.diamondsToYou", CustomStatistic::AchDiamondsToYou} }; return CustomStatistics.at(ID); diff --git a/src/WorldStorage/NamespaceSerializer.h b/src/WorldStorage/NamespaceSerializer.h index 876db740f..c521db201 100644 --- a/src/WorldStorage/NamespaceSerializer.h +++ b/src/WorldStorage/NamespaceSerializer.h @@ -15,11 +15,11 @@ namespace NamespaceSerializer unsigned DataVersion(); - std::string_view From(Statistic a_ID); + std::string_view From(CustomStatistic a_ID); std::string_view From(eMonsterType a_ID); std::string_view From(BannerPattern a_ID); - Statistic ToCustomStatistic(std::string_view a_ID); + CustomStatistic ToCustomStatistic(std::string_view a_ID); eMonsterType ToMonsterType(std::string_view a_ID); std::pair<Namespace, std::string_view> SplitNamespacedID(std::string_view ID); diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp index 4721d7022..5432f6ab9 100644 --- a/src/WorldStorage/StatSerializer.cpp +++ b/src/WorldStorage/StatSerializer.cpp @@ -33,115 +33,112 @@ namespace StatSerializer - static void SaveStatToJSON(const cStatManager & Manager, Json::Value & a_Out) + static void SaveStatToJSON(const StatisticsManager & Manager, Json::Value & a_Out) { - Manager.ForEachStatisticType([&a_Out](const cStatManager::CustomStore & Store) + if (Manager.Custom.empty()) { - if (Store.empty()) - { - // Avoid saving "custom": null to disk: - return; - } + // Avoid saving "custom": null to disk: + return; + } - auto & Custom = a_Out["custom"]; - for (const auto & Item : Store) - { - Custom[NamespaceSerializer::From(Item.first).data()] = Item.second; - } - }); + auto & Custom = a_Out["custom"]; + for (const auto & [Statistic, Value] : Manager.Custom) + { + Custom[NamespaceSerializer::From(Statistic).data()] = Value; + } } - static void LoadLegacyFromJSON(cStatManager & Manager, const Json::Value & In) + static void LoadLegacyFromJSON(StatisticsManager & Manager, const Json::Value & In) { // Upgrade mapping from pre-1.13 names. TODO: remove on 2020-09-18 - static const std::unordered_map<std::string_view, Statistic> LegacyMapping + static const std::unordered_map<std::string_view, CustomStatistic> LegacyMapping { - { "achievement.openInventory", Statistic::AchOpenInventory }, - { "achievement.mineWood", Statistic::AchMineWood }, - { "achievement.buildWorkBench", Statistic::AchBuildWorkBench }, - { "achievement.buildPickaxe", Statistic::AchBuildPickaxe }, - { "achievement.buildFurnace", Statistic::AchBuildFurnace }, - { "achievement.acquireIron", Statistic::AchAcquireIron }, - { "achievement.buildHoe", Statistic::AchBuildHoe }, - { "achievement.makeBread", Statistic::AchMakeBread }, - { "achievement.bakeCake", Statistic::AchBakeCake }, - { "achievement.buildBetterPickaxe", Statistic::AchBuildBetterPickaxe }, - { "achievement.cookFish", Statistic::AchCookFish }, - { "achievement.onARail", Statistic::AchOnARail }, - { "achievement.buildSword", Statistic::AchBuildSword }, - { "achievement.killEnemy", Statistic::AchKillEnemy }, - { "achievement.killCow", Statistic::AchKillCow }, - { "achievement.flyPig", Statistic::AchFlyPig }, - { "achievement.snipeSkeleton", Statistic::AchSnipeSkeleton }, - { "achievement.diamonds", Statistic::AchDiamonds }, - { "achievement.portal", Statistic::AchPortal }, - { "achievement.ghast", Statistic::AchGhast }, - { "achievement.blazeRod", Statistic::AchBlazeRod }, - { "achievement.potion", Statistic::AchPotion }, - { "achievement.theEnd", Statistic::AchTheEnd }, - { "achievement.theEnd2", Statistic::AchTheEnd2 }, - { "achievement.enchantments", Statistic::AchEnchantments }, - { "achievement.overkill", Statistic::AchOverkill }, - { "achievement.bookcase", Statistic::AchBookcase }, - { "achievement.exploreAllBiomes", Statistic::AchExploreAllBiomes }, - { "achievement.spawnWither", Statistic::AchSpawnWither }, - { "achievement.killWither", Statistic::AchKillWither }, - { "achievement.fullBeacon", Statistic::AchFullBeacon }, - { "achievement.breedCow", Statistic::AchBreedCow }, - { "achievement.diamondsToYou", Statistic::AchDiamondsToYou }, - { "stat.animalsBred", Statistic::AnimalsBred }, - { "stat.boatOneCm", Statistic::BoatOneCm }, - { "stat.climbOneCm", Statistic::ClimbOneCm }, - { "stat.crouchOneCm", Statistic::CrouchOneCm }, - { "stat.damageDealt", Statistic::DamageDealt }, - { "stat.damageTaken", Statistic::DamageTaken }, - { "stat.deaths", Statistic::Deaths }, - { "stat.drop", Statistic::Drop }, - { "stat.fallOneCm", Statistic::FallOneCm }, - { "stat.fishCaught", Statistic::FishCaught }, - { "stat.flyOneCm", Statistic::FlyOneCm }, - { "stat.horseOneCm", Statistic::HorseOneCm }, - { "stat.jump", Statistic::Jump }, - { "stat.leaveGame", Statistic::LeaveGame }, - { "stat.minecartOneCm", Statistic::MinecartOneCm }, - { "stat.mobKills", Statistic::MobKills }, - { "stat.pigOneCm", Statistic::PigOneCm }, - { "stat.playerKills", Statistic::PlayerKills }, - { "stat.playOneMinute", Statistic::PlayOneMinute }, - { "stat.sprintOneCm", Statistic::SprintOneCm }, - { "stat.swimOneCm", Statistic::SwimOneCm }, - { "stat.talkedToVillager", Statistic::TalkedToVillager }, - { "stat.timeSinceDeath", Statistic::TimeSinceDeath }, - { "stat.tradedWithVillager", Statistic::TradedWithVillager }, - { "stat.walkOneCm", Statistic::WalkOneCm }, - { "stat.diveOneCm", Statistic::WalkUnderWaterOneCm }, - { "stat.armorCleaned", Statistic::CleanArmor }, - { "stat.bannerCleaned", Statistic::CleanBanner }, - { "stat.cakeSlicesEaten", Statistic::EatCakeSlice }, - { "stat.itemEnchanted", Statistic::EnchantItem }, - { "stat.cauldronFilled", Statistic::FillCauldron }, - { "stat.dispenserInspected", Statistic::InspectDispenser }, - { "stat.dropperInspected", Statistic::InspectDropper }, - { "stat.hopperInspected", Statistic::InspectHopper }, - { "stat.beaconInteraction", Statistic::InteractWithBeacon }, - { "stat.brewingstandInteraction", Statistic::InteractWithBrewingstand }, - { "stat.craftingTableInteraction", Statistic::InteractWithCraftingTable }, - { "stat.furnaceInteraction", Statistic::InteractWithFurnace }, - { "stat.chestOpened", Statistic::OpenChest }, - { "stat.enderchestOpened", Statistic::OpenEnderchest }, - { "stat.noteblockPlayed", Statistic::PlayNoteblock }, - { "stat.recordPlayed", Statistic::PlayRecord }, - { "stat.flowerPotted", Statistic::PotFlower }, - { "stat.trappedChestTriggered", Statistic::TriggerTrappedChest }, - { "stat.noteblockTuned", Statistic::TuneNoteblock }, - { "stat.cauldronUsed", Statistic::UseCauldron }, - { "stat.aviateOneCm", Statistic::AviateOneCm }, - { "stat.sleepInBed", Statistic::SleepInBed }, - { "stat.sneakTime", Statistic::SneakTime } + { "achievement.openInventory", CustomStatistic::AchOpenInventory }, + { "achievement.mineWood", CustomStatistic::AchMineWood }, + { "achievement.buildWorkBench", CustomStatistic::AchBuildWorkBench }, + { "achievement.buildPickaxe", CustomStatistic::AchBuildPickaxe }, + { "achievement.buildFurnace", CustomStatistic::AchBuildFurnace }, + { "achievement.acquireIron", CustomStatistic::AchAcquireIron }, + { "achievement.buildHoe", CustomStatistic::AchBuildHoe }, + { "achievement.makeBread", CustomStatistic::AchMakeBread }, + { "achievement.bakeCake", CustomStatistic::AchBakeCake }, + { "achievement.buildBetterPickaxe", CustomStatistic::AchBuildBetterPickaxe }, + { "achievement.cookFish", CustomStatistic::AchCookFish }, + { "achievement.onARail", CustomStatistic::AchOnARail }, + { "achievement.buildSword", CustomStatistic::AchBuildSword }, + { "achievement.killEnemy", CustomStatistic::AchKillEnemy }, + { "achievement.killCow", CustomStatistic::AchKillCow }, + { "achievement.flyPig", CustomStatistic::AchFlyPig }, + { "achievement.snipeSkeleton", CustomStatistic::AchSnipeSkeleton }, + { "achievement.diamonds", CustomStatistic::AchDiamonds }, + { "achievement.portal", CustomStatistic::AchPortal }, + { "achievement.ghast", CustomStatistic::AchGhast }, + { "achievement.blazeRod", CustomStatistic::AchBlazeRod }, + { "achievement.potion", CustomStatistic::AchPotion }, + { "achievement.theEnd", CustomStatistic::AchTheEnd }, + { "achievement.theEnd2", CustomStatistic::AchTheEnd2 }, + { "achievement.enchantments", CustomStatistic::AchEnchantments }, + { "achievement.overkill", CustomStatistic::AchOverkill }, + { "achievement.bookcase", CustomStatistic::AchBookcase }, + { "achievement.exploreAllBiomes", CustomStatistic::AchExploreAllBiomes }, + { "achievement.spawnWither", CustomStatistic::AchSpawnWither }, + { "achievement.killWither", CustomStatistic::AchKillWither }, + { "achievement.fullBeacon", CustomStatistic::AchFullBeacon }, + { "achievement.breedCow", CustomStatistic::AchBreedCow }, + { "achievement.diamondsToYou", CustomStatistic::AchDiamondsToYou }, + { "stat.animalsBred", CustomStatistic::AnimalsBred }, + { "stat.boatOneCm", CustomStatistic::BoatOneCm }, + { "stat.climbOneCm", CustomStatistic::ClimbOneCm }, + { "stat.crouchOneCm", CustomStatistic::CrouchOneCm }, + { "stat.damageDealt", CustomStatistic::DamageDealt }, + { "stat.damageTaken", CustomStatistic::DamageTaken }, + { "stat.deaths", CustomStatistic::Deaths }, + { "stat.drop", CustomStatistic::Drop }, + { "stat.fallOneCm", CustomStatistic::FallOneCm }, + { "stat.fishCaught", CustomStatistic::FishCaught }, + { "stat.flyOneCm", CustomStatistic::FlyOneCm }, + { "stat.horseOneCm", CustomStatistic::HorseOneCm }, + { "stat.jump", CustomStatistic::Jump }, + { "stat.leaveGame", CustomStatistic::LeaveGame }, + { "stat.minecartOneCm", CustomStatistic::MinecartOneCm }, + { "stat.mobKills", CustomStatistic::MobKills }, + { "stat.pigOneCm", CustomStatistic::PigOneCm }, + { "stat.playerKills", CustomStatistic::PlayerKills }, + { "stat.playOneMinute", CustomStatistic::PlayOneMinute }, + { "stat.sprintOneCm", CustomStatistic::SprintOneCm }, + { "stat.swimOneCm", CustomStatistic::SwimOneCm }, + { "stat.talkedToVillager", CustomStatistic::TalkedToVillager }, + { "stat.timeSinceDeath", CustomStatistic::TimeSinceDeath }, + { "stat.tradedWithVillager", CustomStatistic::TradedWithVillager }, + { "stat.walkOneCm", CustomStatistic::WalkOneCm }, + { "stat.diveOneCm", CustomStatistic::WalkUnderWaterOneCm }, + { "stat.armorCleaned", CustomStatistic::CleanArmor }, + { "stat.bannerCleaned", CustomStatistic::CleanBanner }, + { "stat.cakeSlicesEaten", CustomStatistic::EatCakeSlice }, + { "stat.itemEnchanted", CustomStatistic::EnchantItem }, + { "stat.cauldronFilled", CustomStatistic::FillCauldron }, + { "stat.dispenserInspected", CustomStatistic::InspectDispenser }, + { "stat.dropperInspected", CustomStatistic::InspectDropper }, + { "stat.hopperInspected", CustomStatistic::InspectHopper }, + { "stat.beaconInteraction", CustomStatistic::InteractWithBeacon }, + { "stat.brewingstandInteraction", CustomStatistic::InteractWithBrewingstand }, + { "stat.craftingTableInteraction", CustomStatistic::InteractWithCraftingTable }, + { "stat.furnaceInteraction", CustomStatistic::InteractWithFurnace }, + { "stat.chestOpened", CustomStatistic::OpenChest }, + { "stat.enderchestOpened", CustomStatistic::OpenEnderchest }, + { "stat.noteblockPlayed", CustomStatistic::PlayNoteblock }, + { "stat.recordPlayed", CustomStatistic::PlayRecord }, + { "stat.flowerPotted", CustomStatistic::PotFlower }, + { "stat.trappedChestTriggered", CustomStatistic::TriggerTrappedChest }, + { "stat.noteblockTuned", CustomStatistic::TuneNoteblock }, + { "stat.cauldronUsed", CustomStatistic::UseCauldron }, + { "stat.aviateOneCm", CustomStatistic::AviateOneCm }, + { "stat.sleepInBed", CustomStatistic::SleepInBed }, + { "stat.sneakTime", CustomStatistic::SneakTime } }; for (auto Entry = In.begin(); Entry != In.end(); ++Entry) @@ -151,7 +148,7 @@ namespace StatSerializer if ((FindResult != LegacyMapping.end()) && Entry->isInt()) { - Manager.SetValue(FindResult->second, Entry->asUInt()); + Manager.Custom[FindResult->second] = Entry->asUInt(); } } } @@ -160,7 +157,7 @@ namespace StatSerializer - static void LoadCustomStatFromJSON(cStatManager & Manager, const Json::Value & a_In) + static void LoadCustomStatFromJSON(StatisticsManager & Manager, const Json::Value & a_In) { for (auto it = a_In.begin(); it != a_In.end(); ++it) { @@ -175,7 +172,7 @@ namespace StatSerializer const auto & StatName = StatInfo.second; try { - Manager.SetValue(NamespaceSerializer::ToCustomStatistic(StatName), it->asUInt()); + Manager.Custom[NamespaceSerializer::ToCustomStatistic(StatName)] = it->asUInt(); } catch (const std::out_of_range &) { @@ -192,7 +189,7 @@ namespace StatSerializer - void Load(cStatManager & Manager, const std::string & WorldPath, std::string && FileName) + void Load(StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName) { Json::Value Root; InputFileStream(MakeStatisticsDirectory(WorldPath, std::move(FileName))) >> Root; @@ -205,7 +202,7 @@ namespace StatSerializer - void Save(const cStatManager & Manager, const std::string & WorldPath, std::string && FileName) + void Save(const StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName) { Json::Value Root; diff --git a/src/WorldStorage/StatSerializer.h b/src/WorldStorage/StatSerializer.h index 1a52b55b7..a178db79c 100644 --- a/src/WorldStorage/StatSerializer.h +++ b/src/WorldStorage/StatSerializer.h @@ -13,8 +13,7 @@ -// fwd: -class cStatManager; +struct StatisticsManager; namespace Json { class Value; } @@ -24,8 +23,8 @@ namespace Json { class Value; } namespace StatSerializer { /* Try to load the player statistics. */ - void Load(cStatManager & Manager, const std::string & WorldPath, std::string && FileName); + void Load(StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName); /* Try to save the player statistics. */ - void Save(const cStatManager & Manager, const std::string & WorldPath, std::string && FileName); + void Save(const StatisticsManager & Manager, const std::string & WorldPath, std::string && FileName); } |