mc_read.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package main
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "strconv"
  6. "aytechnology.us/gominecraft/mod/mc"
  7. )
  8. func ReadLog(w http.ResponseWriter, r *http.Request) {
  9. log := MCServer.ReadAllLog()
  10. jsonData, _ := json.Marshal(log)
  11. sendJSONResponse(w, string(jsonData))
  12. }
  13. func ReadLogFrom(w http.ResponseWriter, r *http.Request) {
  14. start, _ := mv(r, "start", false)
  15. startInt, _ := strconv.Atoi(start)
  16. end := MCServer.LenLog()
  17. if startInt > MCServer.LenLog()-1 {
  18. sendJSONResponse(w, "[]")
  19. } else {
  20. log := MCServer.ReadRangeLog(startInt, end)
  21. jsonData, _ := json.Marshal(log)
  22. sendJSONResponse(w, string(jsonData))
  23. }
  24. }
  25. func ReadBanIP(w http.ResponseWriter, r *http.Request) {
  26. config := Config.ReadAllBannedIPs()
  27. jsonData, _ := json.Marshal(config)
  28. sendJSONResponse(w, string(jsonData))
  29. }
  30. func ReadBanPlayer(w http.ResponseWriter, r *http.Request) {
  31. config := Config.ReadAllBannedPlayers()
  32. for _, item := range config {
  33. skin := mc.NewHandler(item.UUID, serverConfig.Folder+"/skin/")
  34. skin.DownloadSkin()
  35. }
  36. jsonData, _ := json.Marshal(config)
  37. sendJSONResponse(w, string(jsonData))
  38. }
  39. func ReadEULA(w http.ResponseWriter, r *http.Request) {
  40. config := Config.ReadEULA()
  41. jsonData, _ := json.Marshal(config)
  42. sendJSONResponse(w, string(jsonData))
  43. }
  44. func ReadOps(w http.ResponseWriter, r *http.Request) {
  45. config := Config.ReadAllOps()
  46. for _, item := range config {
  47. skin := mc.NewHandler(item.UUID, serverConfig.Folder+"/skin/")
  48. skin.DownloadSkin()
  49. }
  50. jsonData, _ := json.Marshal(config)
  51. sendJSONResponse(w, string(jsonData))
  52. }
  53. func ReadProperties(w http.ResponseWriter, r *http.Request) {
  54. config := Config.ReadAllProperties()
  55. jsonData, _ := json.Marshal(config)
  56. sendJSONResponse(w, string(jsonData))
  57. }
  58. func ReadWhitelist(w http.ResponseWriter, r *http.Request) {
  59. config := Config.ReadAllWhitelists()
  60. for _, item := range config {
  61. skin := mc.NewHandler(item.UUID, serverConfig.Folder+"/skin/")
  62. skin.DownloadSkin()
  63. }
  64. jsonData, _ := json.Marshal(config)
  65. sendJSONResponse(w, string(jsonData))
  66. }