Cuberite
A lightweight, fast and extensible game server for Minecraft
NamespaceSerializer.cpp
Go to the documentation of this file.
1 #include "Globals.h"
2 
3 #include "NamespaceSerializer.h"
4 
5 #include <cctype>
6 
7 
8 
10 {
11  return 2566;
12 }
13 
14 
15 
16 
17 
18 std::string_view NamespaceSerializer::From(const CustomStatistic a_ID)
19 {
20  switch (a_ID)
21  {
22  case CustomStatistic::AnimalsBred: return "animals_bred";
23  case CustomStatistic::AviateOneCm: return "aviate_one_cm";
24  case CustomStatistic::BellRing: return "bell_ring";
25  case CustomStatistic::BoatOneCm: return "boat_one_cm";
26  case CustomStatistic::CleanArmor: return "clean_armor";
27  case CustomStatistic::CleanBanner: return "clean_banner";
28  case CustomStatistic::CleanShulkerBox: return "clean_shulker_box";
29  case CustomStatistic::ClimbOneCm: return "climb_one_cm";
30  case CustomStatistic::CrouchOneCm: return "crouch_one_cm";
31  case CustomStatistic::DamageAbsorbed: return "damage_absorbed";
32  case CustomStatistic::DamageBlockedByShield: return "damage_blocked_by_shield";
33  case CustomStatistic::DamageDealt: return "damage_dealt";
34  case CustomStatistic::DamageDealtAbsorbed: return "damage_dealt_absorbed";
35  case CustomStatistic::DamageDealtResisted: return "damage_dealt_resisted";
36  case CustomStatistic::DamageResisted: return "damage_resisted";
37  case CustomStatistic::DamageTaken: return "damage_taken";
38  case CustomStatistic::Deaths: return "deaths";
39  case CustomStatistic::Drop: return "drop";
40  case CustomStatistic::EatCakeSlice: return "eat_cake_slice";
41  case CustomStatistic::EnchantItem: return "enchant_item";
42  case CustomStatistic::FallOneCm: return "fall_one_cm";
43  case CustomStatistic::FillCauldron: return "fill_cauldron";
44  case CustomStatistic::FishCaught: return "fish_caught";
45  case CustomStatistic::FlyOneCm: return "fly_one_cm";
46  case CustomStatistic::HorseOneCm: return "horse_one_cm";
47  case CustomStatistic::InspectDispenser: return "inspect_dispenser";
48  case CustomStatistic::InspectDropper: return "inspect_dropper";
49  case CustomStatistic::InspectHopper: return "inspect_hopper";
50  case CustomStatistic::InteractWithAnvil: return "interact_with_anvil";
51  case CustomStatistic::InteractWithBeacon: return "interact_with_beacon";
52  case CustomStatistic::InteractWithBlastFurnace: return "interact_with_blast_furnace";
53  case CustomStatistic::InteractWithBrewingstand: return "interact_with_brewingstand";
54  case CustomStatistic::InteractWithCampfire: return "interact_with_campfire";
55  case CustomStatistic::InteractWithCartographyTable: return "interact_with_cartography_table";
56  case CustomStatistic::InteractWithCraftingTable: return "interact_with_crafting_table";
57  case CustomStatistic::InteractWithFurnace: return "interact_with_furnace";
58  case CustomStatistic::InteractWithGrindstone: return "interact_with_grindstone";
59  case CustomStatistic::InteractWithLectern: return "interact_with_lectern";
60  case CustomStatistic::InteractWithLoom: return "interact_with_loom";
61  case CustomStatistic::InteractWithSmithingTable: return "interact_with_smithing_table";
62  case CustomStatistic::InteractWithSmoker: return "interact_with_smoker";
63  case CustomStatistic::InteractWithStonecutter: return "interact_with_stonecutter";
64  case CustomStatistic::Jump: return "jump";
65  case CustomStatistic::LeaveGame: return "leave_game";
66  case CustomStatistic::MinecartOneCm: return "minecart_one_cm";
67  case CustomStatistic::MobKills: return "mob_kills";
68  case CustomStatistic::OpenBarrel: return "open_barrel";
69  case CustomStatistic::OpenChest: return "open_chest";
70  case CustomStatistic::OpenEnderchest: return "open_enderchest";
71  case CustomStatistic::OpenShulkerBox: return "open_shulker_box";
72  case CustomStatistic::PigOneCm: return "pig_one_cm";
73  case CustomStatistic::PlayNoteblock: return "play_noteblock";
74  case CustomStatistic::PlayOneMinute: return "play_one_minute";
75  case CustomStatistic::PlayRecord: return "play_record";
76  case CustomStatistic::PlayerKills: return "player_kills";
77  case CustomStatistic::PotFlower: return "pot_flower";
78  case CustomStatistic::RaidTrigger: return "raid_trigger";
79  case CustomStatistic::RaidWin: return "raid_win";
80  case CustomStatistic::SleepInBed: return "sleep_in_bed";
81  case CustomStatistic::SneakTime: return "sneak_time";
82  case CustomStatistic::SprintOneCm: return "sprint_one_cm";
83  case CustomStatistic::StriderOneCm: return "strider_one_cm";
84  case CustomStatistic::SwimOneCm: return "swim_one_cm";
85  case CustomStatistic::TalkedToVillager: return "talked_to_villager";
86  case CustomStatistic::TargetHit: return "target_hit";
87  case CustomStatistic::TimeSinceDeath: return "time_since_death";
88  case CustomStatistic::TimeSinceRest: return "time_since_rest";
89  case CustomStatistic::TradedWithVillager: return "traded_with_villager";
90  case CustomStatistic::TriggerTrappedChest: return "trigger_trapped_chest";
91  case CustomStatistic::TuneNoteblock: return "tune_noteblock";
92  case CustomStatistic::UseCauldron: return "use_cauldron";
93  case CustomStatistic::WalkOnWaterOneCm: return "walk_on_water_one_cm";
94  case CustomStatistic::WalkOneCm: return "walk_one_cm";
95  case CustomStatistic::WalkUnderWaterOneCm: return "walk_under_water_one_cm";
96 
97  // Old ones just for compatibility
98  case CustomStatistic::JunkFished: return "junk_fished";
99  case CustomStatistic::TreasureFished: return "treasure_fished";
100 
101  // The old advancements
102  case CustomStatistic::AchOpenInventory: return "cuberite:achievement.openInventory";
103  case CustomStatistic::AchMineWood: return "cuberite:achievement.mineWood";
104  case CustomStatistic::AchBuildWorkBench: return "cuberite:achievement.buildWorkBench";
105  case CustomStatistic::AchBuildPickaxe: return "cuberite:achievement.buildPickaxe";
106  case CustomStatistic::AchBuildFurnace: return "cuberite:achievement.buildFurnace";
107  case CustomStatistic::AchAcquireIron: return "cuberite:achievement.acquireIron";
108  case CustomStatistic::AchBuildHoe: return "cuberite:achievement.buildHoe";
109  case CustomStatistic::AchMakeBread: return "cuberite:achievement.makeBread";
110  case CustomStatistic::AchBakeCake: return "cuberite:achievement.bakeCake";
111  case CustomStatistic::AchBuildBetterPickaxe: return "cuberite:achievement.buildBetterPickaxe";
112  case CustomStatistic::AchCookFish: return "cuberite:achievement.cookFish";
113  case CustomStatistic::AchOnARail: return "cuberite:achievement.onARail";
114  case CustomStatistic::AchBuildSword: return "cuberite:achievement.buildSword";
115  case CustomStatistic::AchKillEnemy: return "cuberite:achievement.killEnemy";
116  case CustomStatistic::AchKillCow: return "cuberite:achievement.killCow";
117  case CustomStatistic::AchFlyPig: return "cuberite:achievement.flyPig";
118  case CustomStatistic::AchSnipeSkeleton: return "cuberite:achievement.snipeSkeleton";
119  case CustomStatistic::AchDiamonds: return "cuberite:achievement.diamonds";
120  case CustomStatistic::AchPortal: return "cuberite:achievement.portal";
121  case CustomStatistic::AchGhast: return "cuberite:achievement.ghast";
122  case CustomStatistic::AchBlazeRod: return "cuberite:achievement.blazeRod";
123  case CustomStatistic::AchPotion: return "cuberite:achievement.potion";
124  case CustomStatistic::AchTheEnd: return "cuberite:achievement.theEnd";
125  case CustomStatistic::AchTheEnd2: return "cuberite:achievement.theEnd2";
126  case CustomStatistic::AchEnchantments: return "cuberite:achievement.enchantments";
127  case CustomStatistic::AchOverkill: return "cuberite:achievement.overkill";
128  case CustomStatistic::AchBookcase: return "cuberite:achievement.bookcase";
129  case CustomStatistic::AchExploreAllBiomes: return "cuberite:achievement.exploreAllBiomes";
130  case CustomStatistic::AchSpawnWither: return "cuberite:achievement.spawnWither";
131  case CustomStatistic::AchKillWither: return "cuberite:achievement.killWither";
132  case CustomStatistic::AchFullBeacon: return "cuberite:achievement.fullBeacon";
133  case CustomStatistic::AchBreedCow: return "cuberite:achievement.breedCow";
134  case CustomStatistic::AchDiamondsToYou: return "cuberite:achievement.diamondsToYou";
135  }
136  UNREACHABLE("Tried to save unhandled statistic");
137 }
138 
139 
140 
141 
142 
143 std::string_view NamespaceSerializer::From(const eMonsterType a_ID)
144 {
145  switch (a_ID)
146  {
147  case mtBat: return "bat";
148  case mtBlaze: return "blaze";
149  case mtCat: return "cat";
150  case mtCaveSpider: return "cave_spider";
151  case mtChicken: return "chicken";
152  case mtCod: return "cod";
153  case mtCow: return "cow";
154  case mtCreeper: return "creeper";
155  case mtDolphin: return "dolphin";
156  case mtDonkey: return "donkey";
157  case mtDrowned: return "drowned";
158  case mtElderGuardian: return "elder_guardian";
159  case mtEnderDragon: return "ender_dragon";
160  case mtEnderman: return "enderman";
161  case mtEndermite: return "endermite";
162  case mtEvoker: return "evoker";
163  case mtFox: return "fox";
164  case mtGhast: return "ghast";
165  case mtGiant: return "giant";
166  case mtGuardian: return "guardian";
167  case mtHorse: return "horse";
168  case mtHoglin: return "hoglin";
169  case mtHusk: return "husk";
170  case mtIllusioner: return "illusioner";
171  case mtIronGolem: return "iron_golem";
172  case mtLlama: return "llama";
173  case mtMagmaCube: return "magma_cube";
174  case mtMooshroom: return "mooshroom";
175  case mtMule: return "mule";
176  case mtOcelot: return "ocelot";
177  case mtPanda: return "panda";
178  case mtParrot: return "parrot";
179  case mtPhantom: return "phantom";
180  case mtPig: return "pig";
181  case mtPiglin: return "piglin";
182  case mtPiglinBrute: return "piglin_brute";
183  case mtPillager: return "pillager";
184  case mtPolarBear: return "polar_bear";
185  case mtPufferfish: return "pufferfish";
186  case mtRabbit: return "rabbit";
187  case mtRavager: return "ravager";
188  case mtSalmon: return "salmon";
189  case mtSheep: return "sheep";
190  case mtShulker: return "shulker";
191  case mtSilverfish: return "silverfish";
192  case mtSkeleton: return "skeleton";
193  case mtSkeletonHorse: return "skeleton_horse";
194  case mtSlime: return "slime";
195  case mtSnowGolem: return "snow_golem";
196  case mtSpider: return "spider";
197  case mtSquid: return "squid";
198  case mtStray: return "stray";
199  case mtStrider: return "strider";
200  case mtTraderLlama: return "trader_llama";
201  case mtTropicalFish: return "tropical_fish";
202  case mtTurtle: return "turtle";
203  case mtVex: return "vex";
204  case mtVillager: return "villager";
205  case mtVindicator: return "vindicator";
206  case mtWanderingTrader:return "wandering_trader";
207  case mtWitch: return "witch";
208  case mtWither: return "wither";
209  case mtWitherSkeleton: return "wither_skeleton";
210  case mtWolf: return "wolf";
211  case mtZoglin: return "zoglin";
212  case mtZombie: return "zombie";
213  case mtZombieHorse: return "zombie_horse";
214  case mtZombiePigman: return "zombified_piglin";
215  case mtZombieVillager: return "zombie_villager";
216  case mtInvalidType: break;
217  }
218  UNREACHABLE("Tried to save unknown monster type");
219 }
220 
221 
222 
223 
224 
225 std::string_view NamespaceSerializer::From(const BannerPattern a_Pattern)
226 {
227  switch (a_Pattern)
228  {
229  case BannerPattern::BottomStripe: return "bs";
230  case BannerPattern::TopStripe: return "ts";
231  case BannerPattern::LeftStripe: return "ls";
232  case BannerPattern::RightStripe: return "rs";
233  case BannerPattern::CenterStripeVertical: return "cs";
234  case BannerPattern::MiddleStripeHorizontal: return "ms";
235  case BannerPattern::DownRightStripe: return "drs";
236  case BannerPattern::DownLeftStripe: return "dls";
237  case BannerPattern::SmallVerticalStripes: return "ss";
238  case BannerPattern::DiagonalCross: return "cr";
239  case BannerPattern::SquareCross: return "sc";
240  case BannerPattern::LeftOfDiagonal: return "ld";
241  case BannerPattern::RightOfUpsideDownDiagonal: return "rud";
242  case BannerPattern::LeftOfUpsideDownDiagonal: return "lud";
243  case BannerPattern::RightOfDiagonal: return "rd";
244  case BannerPattern::VerticalHalfLeft: return "vh";
245  case BannerPattern::VerticalHalfRight: return "vhr";
246  case BannerPattern::HorizontalHalfTop: return "hh";
247  case BannerPattern::HorizontalHalfBottom: return "hhb";
248  case BannerPattern::BottomLeftCorner: return "bl";
249  case BannerPattern::BottomRightCorner: return "br";
250  case BannerPattern::TopLeftCorner: return "tl";
251  case BannerPattern::TopRightCorner: return "tr";
252  case BannerPattern::BottomTriangle: return "bt";
253  case BannerPattern::TopTriangle: return "tt";
254  case BannerPattern::BottomTriangleSawtooth: return "bts";
255  case BannerPattern::TopTriangleSawtooth: return "tts";
256  case BannerPattern::MiddleCircle: return "mc";
257  case BannerPattern::MiddleRhombus: return "mr";
258  case BannerPattern::Border: return "bo";
259  case BannerPattern::CurlyBorder: return "cbo";
260  case BannerPattern::Brick: return "bri";
261  case BannerPattern::Gradient: return "gra";
262  case BannerPattern::GradientUpsideDown: return "gru";
263  case BannerPattern::Creeper: return "cre";
264  case BannerPattern::Skull: return "sku";
265  case BannerPattern::Flower: return "flo";
266  case BannerPattern::Mojang: return "moj";
267  case BannerPattern::Globe: return "glb";
268  case BannerPattern::Piglin: return "pig";
269  }
270  UNREACHABLE("Unsupported banner pattern");
271 }
272 
273 
274 
275 
276 
278 {
279  static const std::unordered_map<std::string_view, CustomStatistic> CustomStatistics
280  {
281  { "animals_bred", CustomStatistic::AnimalsBred },
282  { "aviate_one_cm", CustomStatistic::AviateOneCm },
283  { "bell_ring", CustomStatistic::BellRing },
284  { "boat_one_cm", CustomStatistic::BoatOneCm },
285  { "clean_armor", CustomStatistic::CleanArmor },
286  { "clean_banner", CustomStatistic::CleanBanner },
287  { "clean_shulker_box", CustomStatistic::CleanShulkerBox },
288  { "climb_one_cm", CustomStatistic::ClimbOneCm },
289  { "crouch_one_cm", CustomStatistic::CrouchOneCm },
290  { "damage_absorbed", CustomStatistic::DamageAbsorbed },
291  { "damage_blocked_by_shield", CustomStatistic::DamageBlockedByShield },
292  { "damage_dealt", CustomStatistic::DamageDealt },
293  { "damage_dealt_absorbed", CustomStatistic::DamageDealtAbsorbed },
294  { "damage_dealt_resisted", CustomStatistic::DamageDealtResisted },
295  { "damage_resisted", CustomStatistic::DamageResisted },
296  { "damage_taken", CustomStatistic::DamageTaken },
297  { "deaths", CustomStatistic::Deaths },
298  { "drop", CustomStatistic::Drop },
299  { "eat_cake_slice", CustomStatistic::EatCakeSlice },
300  { "enchant_item", CustomStatistic::EnchantItem },
301  { "fall_one_cm", CustomStatistic::FallOneCm },
302  { "fill_cauldron", CustomStatistic::FillCauldron },
303  { "fish_caught", CustomStatistic::FishCaught },
304  { "fly_one_cm", CustomStatistic::FlyOneCm },
305  { "horse_one_cm", CustomStatistic::HorseOneCm },
306  { "inspect_dispenser", CustomStatistic::InspectDispenser },
307  { "inspect_dropper", CustomStatistic::InspectDropper },
308  { "inspect_hopper", CustomStatistic::InspectHopper },
309  { "interact_with_anvil", CustomStatistic::InteractWithAnvil },
310  { "interact_with_beacon", CustomStatistic::InteractWithBeacon },
311  { "interact_with_blast_furnace", CustomStatistic::InteractWithBlastFurnace },
312  { "interact_with_brewingstand", CustomStatistic::InteractWithBrewingstand },
313  { "interact_with_campfire", CustomStatistic::InteractWithCampfire },
314  { "interact_with_cartography_table", CustomStatistic::InteractWithCartographyTable },
315  { "interact_with_crafting_table", CustomStatistic::InteractWithCraftingTable },
316  { "interact_with_furnace", CustomStatistic::InteractWithFurnace },
317  { "interact_with_grindstone", CustomStatistic::InteractWithGrindstone },
318  { "interact_with_lectern", CustomStatistic::InteractWithLectern },
319  { "interact_with_loom", CustomStatistic::InteractWithLoom },
320  { "interact_with_smithing_table", CustomStatistic::InteractWithSmithingTable },
321  { "interact_with_smoker", CustomStatistic::InteractWithSmoker },
322  { "interact_with_stonecutter", CustomStatistic::InteractWithStonecutter },
323  { "jump", CustomStatistic::Jump },
324  { "leave_game", CustomStatistic::LeaveGame },
325  { "minecart_one_cm", CustomStatistic::MinecartOneCm },
326  { "mob_kills", CustomStatistic::MobKills },
327  { "open_barrel", CustomStatistic::OpenBarrel },
328  { "open_chest", CustomStatistic::OpenChest },
329  { "open_enderchest", CustomStatistic::OpenEnderchest },
330  { "open_shulker_box", CustomStatistic::OpenShulkerBox },
331  { "pig_one_cm", CustomStatistic::PigOneCm },
332  { "play_noteblock", CustomStatistic::PlayNoteblock },
333  { "play_one_minute", CustomStatistic::PlayOneMinute },
334  { "play_record", CustomStatistic::PlayRecord },
335  { "player_kills", CustomStatistic::PlayerKills },
336  { "pot_flower", CustomStatistic::PotFlower },
337  { "raid_trigger", CustomStatistic::RaidTrigger },
338  { "raid_win", CustomStatistic::RaidWin },
339  { "sleep_in_bed", CustomStatistic::SleepInBed },
340  { "sneak_time", CustomStatistic::SneakTime },
341  { "sprint_one_cm", CustomStatistic::SprintOneCm },
342  { "strider_one_cm", CustomStatistic::StriderOneCm },
343  { "swim_one_cm", CustomStatistic::SwimOneCm },
344  { "talked_to_villager", CustomStatistic::TalkedToVillager },
345  { "target_hit", CustomStatistic::TargetHit },
346  { "time_since_death", CustomStatistic::TimeSinceDeath },
347  { "time_since_rest", CustomStatistic::TimeSinceRest },
348  { "traded_with_villager", CustomStatistic::TradedWithVillager },
349  { "trigger_trapped_chest", CustomStatistic::TriggerTrappedChest },
350  { "tune_noteblock", CustomStatistic::TuneNoteblock },
351  { "use_cauldron", CustomStatistic::UseCauldron },
352  { "walk_on_water_one_cm", CustomStatistic::WalkOnWaterOneCm },
353  { "walk_one_cm", CustomStatistic::WalkOneCm },
354  { "walk_under_water_one_cm", CustomStatistic::WalkUnderWaterOneCm },
355 
356  // Old ones just for compatibility
357  { "junk_fished", CustomStatistic::JunkFished },
358  { "treasure_fished", CustomStatistic::TreasureFished },
359 
360  // The old advancements
361  { "cuberite:achievement.openInventory", CustomStatistic::AchOpenInventory },
362  { "cuberite:achievement.mineWood", CustomStatistic::AchMineWood },
363  { "cuberite:achievement.buildWorkBench", CustomStatistic::AchBuildWorkBench },
364  { "cuberite:achievement.buildPickaxe", CustomStatistic::AchBuildPickaxe },
365  { "cuberite:achievement.buildFurnace", CustomStatistic::AchBuildFurnace },
366  { "cuberite:achievement.acquireIron", CustomStatistic::AchAcquireIron },
367  { "cuberite:achievement.buildHoe", CustomStatistic::AchBuildHoe },
368  { "cuberite:achievement.makeBread", CustomStatistic::AchMakeBread },
369  { "cuberite:achievement.bakeCake", CustomStatistic::AchBakeCake },
370  { "cuberite:achievement.buildBetterPickaxe", CustomStatistic::AchBuildBetterPickaxe },
371  { "cuberite:achievement.cookFish", CustomStatistic::AchCookFish },
372  { "cuberite:achievement.onARail", CustomStatistic::AchOnARail },
373  { "cuberite:achievement.buildSword", CustomStatistic::AchBuildSword },
374  { "cuberite:achievement.killEnemy", CustomStatistic::AchKillEnemy },
375  { "cuberite:achievement.killCow", CustomStatistic::AchKillCow },
376  { "cuberite:achievement.flyPig", CustomStatistic::AchFlyPig },
377  { "cuberite:achievement.snipeSkeleton", CustomStatistic::AchSnipeSkeleton },
378  { "cuberite:achievement.diamonds", CustomStatistic::AchDiamonds },
379  { "cuberite:achievement.portal", CustomStatistic::AchPortal },
380  { "cuberite:achievement.ghast", CustomStatistic::AchGhast },
381  { "cuberite:achievement.blazeRod", CustomStatistic::AchBlazeRod },
382  { "cuberite:achievement.potion", CustomStatistic::AchPotion },
383  { "cuberite:achievement.theEnd", CustomStatistic::AchTheEnd },
384  { "cuberite:achievement.theEnd2", CustomStatistic::AchTheEnd2 },
385  { "cuberite:achievement.enchantments", CustomStatistic::AchEnchantments },
386  { "cuberite:achievement.overkill", CustomStatistic::AchOverkill },
387  { "cuberite:achievement.bookcase", CustomStatistic::AchBookcase },
388  { "cuberite:achievement.exploreAllBiomes", CustomStatistic::AchExploreAllBiomes },
389  { "cuberite:achievement.spawnWither", CustomStatistic::AchSpawnWither },
390  { "cuberite:achievement.killWither", CustomStatistic::AchKillWither },
391  { "cuberite:achievement.fullBeacon", CustomStatistic::AchFullBeacon },
392  { "cuberite:achievement.breedCow", CustomStatistic::AchBreedCow },
393  { "cuberite:achievement.diamondsToYou", CustomStatistic::AchDiamondsToYou}
394  };
395 
396  return CustomStatistics.at(ID);
397 }
398 
399 
400 
401 
402 
403 std::pair<NamespaceSerializer::Namespace, std::string_view> NamespaceSerializer::SplitNamespacedID(const std::string_view ID)
404 {
405  const auto NamespaceIndex = ID.find(':');
406  if (NamespaceIndex == std::string_view::npos)
407  {
408  // No explicit namespace defaults to the Minecraft namespace:
409  return { Namespace::Minecraft, ID };
410  }
411 
412  const auto Namespace = ID.substr(0, NamespaceIndex);
413  if (Namespace == "minecraft")
414  {
415  // An unprefixed ID in the vanilla Minecraft namespace.
416  const auto Value = ID.substr(NamespaceIndex + 1);
417 
418  return { Namespace::Minecraft, Value };
419  }
420 
421  if (Namespace == "cuberite")
422  {
423  return { Namespace::Cuberite, ID };
424  }
425 
426  return { Namespace::Unknown, ID };
427 }
428 
429 
430 
431 
432 
434 {
435  static const std::unordered_map<std::string_view, eMonsterType> MonsterTypes
436  {
437  { "bat", mtBat },
438  { "blaze", mtBlaze },
439  { "cat", mtCat },
440  { "cave_spider", mtCaveSpider },
441  { "chicken", mtChicken },
442  { "cod", mtCod },
443  { "cow", mtCow },
444  { "creeper", mtCreeper },
445  { "dolphin", mtDolphin },
446  { "donkey", mtDonkey },
447  { "drowned", mtDrowned },
448  { "elder_guardian", mtElderGuardian },
449  { "ender_dragon", mtEnderDragon },
450  { "enderman", mtEnderman },
451  { "endermite", mtEndermite },
452  { "evoker", mtEvoker },
453  { "fox", mtFox },
454  { "ghast", mtGhast },
455  { "giant", mtGiant },
456  { "guardian", mtGuardian },
457  { "horse", mtHorse },
458  { "hoglin", mtHoglin },
459  { "husk", mtHusk },
460  { "illusioner", mtIllusioner },
461  { "iron_golem", mtIronGolem },
462  { "llama", mtLlama },
463  { "magma_cube", mtMagmaCube },
464  { "mooshroom", mtMooshroom },
465  { "mule", mtMule },
466  { "ocelot", mtOcelot },
467  { "panda", mtPanda },
468  { "parrot", mtParrot },
469  { "phantom", mtPhantom },
470  { "pig", mtPig },
471  { "piglin", mtPiglin },
472  { "piglin_brute", mtPiglinBrute },
473  { "pillager", mtPillager },
474  { "polar_bear", mtPolarBear },
475  { "pufferfish", mtPufferfish },
476  { "rabbit", mtRabbit },
477  { "ravager", mtRavager },
478  { "salmon", mtSalmon },
479  { "sheep", mtSheep },
480  { "shulker", mtShulker },
481  { "silverfish", mtSilverfish },
482  { "skeleton", mtSkeleton },
483  { "skeleton_horse", mtSkeletonHorse },
484  { "slime", mtSlime },
485  { "snow_golem", mtSnowGolem },
486  { "spider", mtSpider },
487  { "squid", mtSquid },
488  { "stray", mtStray },
489  { "strider", mtStrider },
490  { "trader_llama", mtTraderLlama },
491  { "tropical_fish", mtTropicalFish },
492  { "turtle", mtTurtle },
493  { "vex", mtVex },
494  { "villager", mtVillager },
495  { "vindicator", mtVindicator },
496  { "wandering_trader", mtWanderingTrader },
497  { "witch", mtWitch },
498  { "wither", mtWither },
499  { "wither_skeleton", mtWitherSkeleton },
500  { "wolf", mtWolf },
501  { "zoglin", mtZoglin },
502  { "zombie", mtZombie },
503  { "zombie_horse", mtZombieHorse },
504  { "zombified_piglin", mtZombiePigman },
505  { "zombie_villager", mtZombieVillager },
506 
507  { "snowman", mtSnowGolem },
508  { "villager_golem", mtIronGolem },
509  { "zombie_pigman", mtZombiePigman },
510 
511  // Old names:
512  { "Bat", mtBat },
513  { "Blaze", mtBlaze },
514  { "CaveSpider", mtCaveSpider },
515  { "Chicken", mtChicken },
516  { "Cow", mtCow },
517  { "Creeper", mtCreeper },
518  { "EnderDragon", mtEnderDragon },
519  { "Enderman", mtEnderman },
520  { "Ghast", mtGhast },
521  { "Giant", mtGiant },
522  { "Guardian", mtGuardian },
523  { "Horse", mtHorse },
524  { "VillagerGolem", mtIronGolem },
525  { "LavaSlime", mtMagmaCube },
526  { "MushroomCow", mtMooshroom },
527  { "Ozelot", mtOcelot },
528  { "Pig", mtPig },
529  { "Rabbit", mtRabbit },
530  { "Sheep", mtSheep },
531  { "Silverfish", mtSilverfish },
532  { "Skeleton", mtSkeleton },
533  { "Slime", mtSlime },
534  { "SnowMan", mtSnowGolem },
535  { "Spider", mtSpider },
536  { "Squid", mtSquid },
537  { "Villager", mtVillager },
538  { "Witch", mtWitch },
539  { "WitherBoss", mtWither },
540  { "WitherSkeleton", mtWitherSkeleton },
541  { "Wolf", mtWolf },
542  { "Zombie", mtZombie },
543  { "PigZombie", mtZombiePigman },
544  { "ZombieVillager", mtZombieVillager }
545  };
546 
547  return MonsterTypes.at(a_ID);
548 }
549 
550 
551 
552 
553 
555 {
556 
557  bool NextLetterCapitalized = true;
558  std::for_each(a_ID.begin(), a_ID.end(), [&](char & a_Letter)
559  {
560  if (NextLetterCapitalized)
561  {
562  a_Letter = static_cast<char>(std::toupper(a_Letter));
563  NextLetterCapitalized = false;
564  }
565  else if (a_Letter == '_')
566  {
567  a_Letter = ' ';
568  NextLetterCapitalized = true;
569  }
570  });
571  return a_ID;
572 }
573 
574 
575 
576 
577 
578 AString NamespaceSerializer::PrettifyEntityName(const AString & a_ID, const bool a_IsTamed)
579 {
580  // In older vanilla Minecraft version (before 1.14) ocelots and cats were the same mob.
581  // So after killing a tamed ocelot without a custom name the message will say "Cat was slain by [PlayerName]".
582  if ((a_ID == "ocelot") && a_IsTamed)
583  {
584  return "Cat";
585  }
586  return Prettify(a_ID);
587 }
BannerPattern
Definition: Defines.h:380
@ RightOfUpsideDownDiagonal
@ LeftOfUpsideDownDiagonal
#define UNREACHABLE(x)
Definition: Globals.h:288
eMonsterType
Identifies individual monster type.
Definition: MonsterTypes.h:11
@ mtZombieVillager
Definition: MonsterTypes.h:82
@ mtVindicator
Definition: MonsterTypes.h:72
@ mtElderGuardian
Definition: MonsterTypes.h:25
@ mtHoglin
Definition: MonsterTypes.h:35
@ mtSkeleton
Definition: MonsterTypes.h:59
@ mtSheep
Definition: MonsterTypes.h:56
@ mtEndermite
Definition: MonsterTypes.h:28
@ mtPiglin
Definition: MonsterTypes.h:48
@ mtTurtle
Definition: MonsterTypes.h:69
@ mtPolarBear
Definition: MonsterTypes.h:51
@ mtDolphin
Definition: MonsterTypes.h:22
@ mtMagmaCube
Definition: MonsterTypes.h:40
@ mtWanderingTrader
Definition: MonsterTypes.h:73
@ mtWolf
Definition: MonsterTypes.h:77
@ mtStray
Definition: MonsterTypes.h:65
@ mtRabbit
Definition: MonsterTypes.h:53
@ mtTraderLlama
Definition: MonsterTypes.h:67
@ mtCat
Definition: MonsterTypes.h:16
@ mtZombie
Definition: MonsterTypes.h:79
@ mtOcelot
Definition: MonsterTypes.h:43
@ mtRavager
Definition: MonsterTypes.h:54
@ mtDonkey
Definition: MonsterTypes.h:23
@ mtVex
Definition: MonsterTypes.h:70
@ mtEnderman
Definition: MonsterTypes.h:27
@ mtTropicalFish
Definition: MonsterTypes.h:68
@ mtHusk
Definition: MonsterTypes.h:36
@ mtCaveSpider
Definition: MonsterTypes.h:17
@ mtEvoker
Definition: MonsterTypes.h:29
@ mtPhantom
Definition: MonsterTypes.h:46
@ mtShulker
Definition: MonsterTypes.h:57
@ mtPufferfish
Definition: MonsterTypes.h:52
@ mtWither
Definition: MonsterTypes.h:75
@ mtSkeletonHorse
Definition: MonsterTypes.h:60
@ mtPig
Definition: MonsterTypes.h:47
@ mtDrowned
Definition: MonsterTypes.h:24
@ mtVillager
Definition: MonsterTypes.h:71
@ mtHorse
Definition: MonsterTypes.h:34
@ mtZombieHorse
Definition: MonsterTypes.h:80
@ mtWitch
Definition: MonsterTypes.h:74
@ mtCow
Definition: MonsterTypes.h:20
@ mtSalmon
Definition: MonsterTypes.h:55
@ mtEnderDragon
Definition: MonsterTypes.h:26
@ mtPiglinBrute
Definition: MonsterTypes.h:49
@ mtMooshroom
Definition: MonsterTypes.h:41
@ mtSquid
Definition: MonsterTypes.h:64
@ mtInvalidType
Definition: MonsterTypes.h:12
@ mtBat
Definition: MonsterTypes.h:14
@ mtIllusioner
Definition: MonsterTypes.h:37
@ mtChicken
Definition: MonsterTypes.h:18
@ mtGiant
Definition: MonsterTypes.h:32
@ mtSnowGolem
Definition: MonsterTypes.h:62
@ mtFox
Definition: MonsterTypes.h:30
@ mtBlaze
Definition: MonsterTypes.h:15
@ mtLlama
Definition: MonsterTypes.h:39
@ mtIronGolem
Definition: MonsterTypes.h:38
@ mtCreeper
Definition: MonsterTypes.h:21
@ mtSpider
Definition: MonsterTypes.h:63
@ mtMule
Definition: MonsterTypes.h:42
@ mtPillager
Definition: MonsterTypes.h:50
@ mtGhast
Definition: MonsterTypes.h:31
@ mtParrot
Definition: MonsterTypes.h:45
@ mtSilverfish
Definition: MonsterTypes.h:58
@ mtZoglin
Definition: MonsterTypes.h:78
@ mtPanda
Definition: MonsterTypes.h:44
@ mtCod
Definition: MonsterTypes.h:19
@ mtStrider
Definition: MonsterTypes.h:66
@ mtZombiePigman
Definition: MonsterTypes.h:85
@ mtSlime
Definition: MonsterTypes.h:61
@ mtWitherSkeleton
Definition: MonsterTypes.h:76
@ mtGuardian
Definition: MonsterTypes.h:33
CustomStatistic
@ InteractWithCartographyTable
std::string AString
Definition: StringUtils.h:11
AString Prettify(AString a_ID)
AString PrettifyEntityName(const AString &a_ID, const bool a_IsTamed=false)
std::string_view From(CustomStatistic a_ID)
CustomStatistic ToCustomStatistic(std::string_view a_ID)
std::pair< Namespace, std::string_view > SplitNamespacedID(std::string_view ID)
eMonsterType ToMonsterType(std::string_view a_ID)