/
disconnect.go
37 lines (32 loc) · 1010 Bytes
/
disconnect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package packet
import (
"github.com/sandertv/gophertunnel/minecraft/protocol"
)
// Disconnect may be sent by the server to disconnect the client using an optional message to send as the
// disconnect screen.
type Disconnect struct {
// HideDisconnectionScreen specifies if the disconnection screen should be hidden when the client is
// disconnected, meaning it will be sent directly to the main menu.
HideDisconnectionScreen bool
// Message is an optional message to show when disconnected. This message is only written if the
// HideDisconnectionScreen field is set to true.
Message string
}
// ID ...
func (*Disconnect) ID() uint32 {
return IDDisconnect
}
// Marshal ...
func (pk *Disconnect) Marshal(w *protocol.Writer) {
w.Bool(&pk.HideDisconnectionScreen)
if !pk.HideDisconnectionScreen {
w.String(&pk.Message)
}
}
// Unmarshal ...
func (pk *Disconnect) Unmarshal(r *protocol.Reader) {
r.Bool(&pk.HideDisconnectionScreen)
if !pk.HideDisconnectionScreen {
r.String(&pk.Message)
}
}