ping_response.go 934 B

123456789101112131415161718192021222324252627
  1. package mcping
  2. import (
  3. "regexp"
  4. )
  5. //PingResponse contains all known fields of the ping response packet
  6. type PingResponse struct {
  7. Latency uint `json:"latency"` //Latency in ms
  8. Online int `json:"online"` //Amount of online players
  9. Max int `json:"max"` //Maximum amount of players
  10. Protocol int `json:"protocol"` //E.g '4'
  11. Favicon []byte `json:"favicon"` //Base64 encoded favicon in data URI format
  12. Motd string `json:"motd"`
  13. Server string `json:"server"` //E.g 'PaperSpigot'
  14. Version string `json:"version"` //E.g "1.7.10"
  15. Sample []PlayerSample `json:"sample"`
  16. }
  17. //Code unknown to work, playing around
  18. func stripMotd(motd string) string {
  19. return regexp.MustCompile("\\s+").ReplaceAllString(regexp.MustCompile("`+.").ReplaceAllString(
  20. regexp.MustCompile("[^\x20-\x7f]").ReplaceAllString(
  21. motd, "`"),
  22. ""),
  23. " ")
  24. }