minor improvements and changes

Signed-off-by: Michael <michael.lindman@gmail.com>
This commit is contained in:
Michael 2021-01-08 15:55:40 +00:00
parent 049ab265d3
commit 20478e3c1f
3 changed files with 17 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
mcstatus mcstatus
mcstatus.exe
run.sh run.sh
go.sum go.sum

View File

@ -22,6 +22,6 @@ clean:
go clean go clean
proto: 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 .PHONY: run doc build debs update-debs fmt proto

18
main.go
View File

@ -28,7 +28,11 @@ func run() error {
return err return err
} }
if cmd.ping { 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 return nil
} }
if cmd.raw { if cmd.raw {
@ -39,8 +43,12 @@ func run() error {
fmt.Printf("%s\n", string(json)) fmt.Printf("%s\n", string(json))
return nil return nil
} }
name := status.Description.Text
if name == "" {
name = status.Description.Extra[0].Text
}
fmt.Printf("Name: %s\nPlayers: %d/%d\nVersion: %s\n", fmt.Printf("Name: %s\nPlayers: %d/%d\nVersion: %s\n",
status.Description.Text, name,
status.Players.Online, status.Players.Online,
status.Players.Max, status.Players.Max,
status.Version.Name) status.Version.Name)
@ -50,7 +58,11 @@ func run() error {
fmt.Printf("\t%s\n", player.Name) 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 return nil
} }
} }