From aa55190637eb14076aaa48e6832e86f02bb74cda Mon Sep 17 00:00:00 2001 From: Joshua Grimm Date: Sun, 10 May 2020 11:15:50 +0200 Subject: [PATCH] only add metrics if the advancements exists --- minecraft_exporter.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/minecraft_exporter.py b/minecraft_exporter.py index 39a886e..8d28c07 100644 --- a/minecraft_exporter.py +++ b/minecraft_exporter.py @@ -234,16 +234,21 @@ class MinecraftCollector(object): player_quests_finished.add_sample('player_quests_finished',value=value,labels={'player':name}) if "stats" in data: # Minecraft > 1.15 - for block, value in data["stats"]["minecraft:crafted"].items(): - blocks_crafted.add_sample('blocks_crafted',value=value,labels={'player':name,'block':block}) - for block, value in data["stats"]["minecraft:mined"].items(): - blocks_mined.add_sample("blocks_mined",value=value,labels={'player':name,'block':block}) - for block, value in data["stats"]["minecraft:picked_up"].items(): - blocks_picked_up.add_sample("blocks_picked_up",value=value,labels={'player':name,'block':block}) - for entity, value in data["stats"]["minecraft:killed"].items(): - entities_killed.add_sample('entities_killed',value=value,labels={'player':name,"entity":entity}) - for entity, value in data["stats"]["minecraft:killed_by"].items(): - player_deaths.add_sample('player_deaths',value=value,labels={'player':name,'cause': entity}) + if "minecraft:crafted" in data["stats"]: + for block, value in data["stats"]["minecraft:crafted"].items(): + blocks_crafted.add_sample('blocks_crafted',value=value,labels={'player':name,'block':block}) + if "minecraft:mined" in data["stats"]: + for block, value in data["stats"]["minecraft:mined"].items(): + blocks_mined.add_sample("blocks_mined",value=value,labels={'player':name,'block':block}) + if "minecraft:picked_up" in data["stats"]: + for block, value in data["stats"]["minecraft:picked_up"].items(): + blocks_picked_up.add_sample("blocks_picked_up",value=value,labels={'player':name,'block':block}) + if "minecraft:killed" in data["stats"]: + for entity, value in data["stats"]["minecraft:killed"].items(): + entities_killed.add_sample('entities_killed',value=value,labels={'player':name,"entity":entity}) + if "minecraft:killed_by" in data["stats"]: + for entity, value in data["stats"]["minecraft:killed_by"].items(): + player_deaths.add_sample('player_deaths',value=value,labels={'player':name,'cause': entity}) for stat, value in data["stats"]["minecraft:custom"].items(): if stat == "minecraft:jump": player_jumps.add_sample("player_jumps",value=value,labels={'player':name})