kick players when keepalive timeout
This commit is contained in:
@ -14,7 +14,7 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
const MaxPlayer = 1024
|
||||
const MaxPlayer = 16384
|
||||
const IconPath = "./server-icon.png"
|
||||
|
||||
var motd = chat.Message{Text: "A Minecraft Server ", Extra: []chat.Message{{Text: "Powered by go-mc", Color: "yellow"}}}
|
||||
|
@ -28,6 +28,7 @@ func main() {
|
||||
time.Sleep(time.Second * 3)
|
||||
}
|
||||
}(i)
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
select {}
|
||||
}
|
||||
@ -46,7 +47,6 @@ func newIndividual(id int, name string) (i *individual) {
|
||||
i.player = basic.NewPlayer(i.client, basic.DefaultSettings)
|
||||
basic.EventsListener{
|
||||
GameStart: i.onGameStart,
|
||||
Death: i.onDeath,
|
||||
Disconnect: onDisconnect,
|
||||
}.Attach(i.client)
|
||||
return
|
||||
@ -68,19 +68,6 @@ func (i *individual) run(address string) {
|
||||
log.Printf("[%d] Handle game error: %v", i.id, err)
|
||||
}
|
||||
|
||||
func (i *individual) onDeath() error {
|
||||
log.Printf("[%d]Died and Respawned", i.id)
|
||||
// If we exclude Respawn(...) then the player won't press the "Respawn" button upon death
|
||||
go func() {
|
||||
time.Sleep(time.Second * 5)
|
||||
err := i.player.Respawn()
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *individual) onGameStart() error {
|
||||
log.Printf("[%d]Game start", i.id)
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user