From 81b0ba8f46bc4e4f4aabc1ca3b4cdb1dee262288 Mon Sep 17 00:00:00 2001 From: Drew Date: Sun, 5 May 2024 21:07:18 -0400 Subject: [PATCH] fixes broken places logic Opening PR for https://github.com/dirien/minecraft-prometheus-exporter/issues/770 --- pkg/exporter/exporter.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/exporter/exporter.go b/pkg/exporter/exporter.go index edc2e85d..4a79e725 100644 --- a/pkg/exporter/exporter.go +++ b/pkg/exporter/exporter.go @@ -755,7 +755,8 @@ func (e *Exporter) getPlayerList(ch chan<- prometheus.Metric) (retErr error) { players := e.playerOnlineRegexp.FindStringSubmatch(*resp) if len(players) > 1 { playersList := players[1] - for _, player := range strings.Fields(strings.ReplaceAll(playersList, ",", " ")) { + list := strings.Split(playersList, ",") + for _, player := range list { player = removeColorCodesFromWord(player) ch <- prometheus.MustNewConstMetric(e.playerOnline, prometheus.CounterValue, 1, strings.TrimSpace(player)) }