diff --git a/.gitignore b/.gitignore index f4bacb3..cf44a6c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ mcstatus +mcstatus.exe run.sh go.sum \ No newline at end of file diff --git a/Makefile b/Makefile index 41393b5..77a8bf7 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,6 @@ clean: go clean proto: - protoc --go_out=/home/michael/go/src response.proto + protoc --go_out=/home/michael/go/src protobuf/*.proto .PHONY: run doc build debs update-debs fmt proto \ No newline at end of file diff --git a/main.go b/main.go index 21b3ad5..ec68516 100644 --- a/main.go +++ b/main.go @@ -28,7 +28,11 @@ func run() error { return err } if cmd.ping { - fmt.Printf("Ping: %+v\n", client.PingServer()) + ping, err := client.PingServer() + if err != nil { + return err + } + fmt.Printf("Ping: %+v\n", ping) return nil } if cmd.raw { @@ -39,8 +43,12 @@ func run() error { fmt.Printf("%s\n", string(json)) return nil } + name := status.Description.Text + if name == "" { + name = status.Description.Extra[0].Text + } fmt.Printf("Name: %s\nPlayers: %d/%d\nVersion: %s\n", - status.Description.Text, + name, status.Players.Online, status.Players.Max, status.Version.Name) @@ -50,7 +58,11 @@ func run() error { fmt.Printf("\t%s\n", player.Name) } } - fmt.Printf("Ping: %+v\n", client.PingServer()) + ping, err := client.PingServer() + if err != nil { + return err + } + fmt.Printf("Ping: %+v\n", ping) return nil } }