package main

import (
	"fmt"
	"time"

	"aytechnology.us/gominecraft/mod/mcping"
	"aytechnology.us/gominecraft/mod/server"
)

func main() {
	server := server.NewHandler("java", "server.jar", "256M", "256M", "")
	server.StartService()
	go func() {
		i := 0
		for {
			end := server.LenLog()
			log := server.ReadRangeLog(i, end)
			for _, line := range log {
				fmt.Println(line.Log)
			}
			i = end

			//for another shit
			resp, _ := mcping.Ping("localhost:25565")
			for _, user := range resp.Sample {
				server.SendCommand("kick " + user.Name + " " + user.Name + " BYE~")
			}
		}
	}()

	//auto stop
	time.Sleep(50 * time.Second)
	fmt.Println("STOP!!")
	server.SendCommand("stop")
	time.Sleep(40 * time.Second)
}
