Skip to content

Commit

Permalink
feat: support ShortTag and FloatTag for player health (#291)
Browse files Browse the repository at this point in the history
Signed-off-by: Engin Diri <[email protected]>
  • Loading branch information
Engin Diri authored Aug 25, 2022
1 parent 35996bc commit 570e907
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type PlayerData struct {
XpLevel int32
XpTotal int32
Score int32
Health float32
Health interface{}
FoodLevel int32 `nbt:"foodLevel"`
Bukkit struct {
LastKnownName string `nbt:"lastKnownName"`
Expand Down Expand Up @@ -509,7 +509,11 @@ func (e *Exporter) getPlayerStats(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(e.playerStat, prometheus.GaugeValue, float64(data.XpLevel), player.Name, "current_xp")
ch <- prometheus.MustNewConstMetric(e.playerStat, prometheus.GaugeValue, float64(data.Score), player.Name, "score")
ch <- prometheus.MustNewConstMetric(e.playerStat, prometheus.GaugeValue, float64(data.FoodLevel), player.Name, "food_level")
ch <- prometheus.MustNewConstMetric(e.playerStat, prometheus.GaugeValue, float64(data.Health), player.Name, "health")
health, err := strconv.ParseFloat(fmt.Sprint(data.Health), 64)
if err != nil {
return err
}
ch <- prometheus.MustNewConstMetric(e.playerStat, prometheus.GaugeValue, health, player.Name, "health")

err = e.advancements(id, ch, player.Name)
if err != nil {
Expand Down

0 comments on commit 570e907

Please sign in to comment.