Use new package for status
This commit is contained in:
2
go.mod
2
go.mod
@@ -3,9 +3,9 @@ module main
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/PassTheMayo/mcstatus/v4 v4.0.2
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/gofiber/fiber/v2 v2.35.0
|
||||
github.com/mcstatus-io/mcutil v0.0.0-20220811020841-9c02c743caf4
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1,5 +1,3 @@
|
||||
github.com/PassTheMayo/mcstatus/v4 v4.0.2 h1:Tn+ULG+1e9eXjJf/WUrqF1JPAs0dDRjTyELF/ieQpiE=
|
||||
github.com/PassTheMayo/mcstatus/v4 v4.0.2/go.mod h1:62Iagw0yGRyufsvEqPI4T8fJpIf6UUh14junH8ZR2LY=
|
||||
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
||||
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
@@ -22,6 +20,8 @@ github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mcstatus-io/mcutil v0.0.0-20220811020841-9c02c743caf4 h1:yCaZ0jlqqvBfWmV3jpqJ4apyITl0ft4c/l3RD0+LfZo=
|
||||
github.com/mcstatus-io/mcutil v0.0.0-20220811020841-9c02c743caf4/go.mod h1:gTqwQyfbgLiJod3BbyztuDq8DoM3iRoriw9x4WxcvFo=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/PassTheMayo/mcstatus/v4"
|
||||
"github.com/mcstatus-io/mcutil"
|
||||
)
|
||||
|
||||
type StatusOffline struct {
|
||||
@@ -150,7 +150,7 @@ func GetServerIcon(host string, port uint16) ([]byte, error) {
|
||||
|
||||
icon := defaultIconBytes
|
||||
|
||||
status, err := mcstatus.Status(host, port)
|
||||
status, err := mcutil.Status(host, port)
|
||||
|
||||
if err == nil && status.Favicon != nil && strings.HasPrefix(*status.Favicon, "data:image/png;base64,") {
|
||||
data, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(*status.Favicon, "data:image/png;base64,"))
|
||||
@@ -172,10 +172,10 @@ func GetServerIcon(host string, port uint16) ([]byte, error) {
|
||||
}
|
||||
|
||||
func FetchJavaStatus(host string, port uint16) interface{} {
|
||||
status, err := mcstatus.Status(host, port)
|
||||
status, err := mcutil.Status(host, port)
|
||||
|
||||
if err != nil {
|
||||
statusLegacy, err := mcstatus.StatusLegacy(host, port)
|
||||
statusLegacy, err := mcutil.StatusLegacy(host, port)
|
||||
|
||||
if err != nil {
|
||||
return StatusOffline{
|
||||
@@ -208,9 +208,9 @@ func FetchJavaStatus(host string, port uint16) interface{} {
|
||||
|
||||
if statusLegacy.Version != nil {
|
||||
response.Version = &JavaVersion{
|
||||
NameRaw: statusLegacy.Version.Name,
|
||||
NameClean: statusLegacy.Version.Clean,
|
||||
NameHTML: statusLegacy.Version.HTML,
|
||||
NameRaw: statusLegacy.Version.NameRaw,
|
||||
NameClean: statusLegacy.Version.NameClean,
|
||||
NameHTML: statusLegacy.Version.NameHTML,
|
||||
Protocol: statusLegacy.Version.Protocol,
|
||||
}
|
||||
}
|
||||
@@ -224,9 +224,9 @@ func FetchJavaStatus(host string, port uint16) interface{} {
|
||||
for _, player := range status.Players.Sample {
|
||||
playerList = append(playerList, Player{
|
||||
UUID: player.ID,
|
||||
NameRaw: player.Name,
|
||||
NameClean: player.Clean,
|
||||
NameHTML: player.HTML,
|
||||
NameRaw: player.NameRaw,
|
||||
NameClean: player.NameClean,
|
||||
NameHTML: player.NameHTML,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -248,9 +248,9 @@ func FetchJavaStatus(host string, port uint16) interface{} {
|
||||
Port: port,
|
||||
EULABlocked: IsBlockedAddress(host),
|
||||
Version: &JavaVersion{
|
||||
NameRaw: status.Version.Name,
|
||||
NameClean: status.Version.Clean,
|
||||
NameHTML: status.Version.HTML,
|
||||
NameRaw: status.Version.NameRaw,
|
||||
NameClean: status.Version.NameClean,
|
||||
NameHTML: status.Version.NameHTML,
|
||||
Protocol: status.Version.Protocol,
|
||||
},
|
||||
Players: JavaPlayers{
|
||||
@@ -269,7 +269,7 @@ func FetchJavaStatus(host string, port uint16) interface{} {
|
||||
}
|
||||
|
||||
func FetchBedrockStatus(host string, port uint16) interface{} {
|
||||
status, err := mcstatus.StatusBedrock(host, port)
|
||||
status, err := mcutil.StatusBedrock(host, port)
|
||||
|
||||
if err != nil {
|
||||
return StatusOffline{
|
||||
|
||||
Reference in New Issue
Block a user