forked from Sandertv/gophertunnel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adventure_settings.go
88 lines (80 loc) · 2.97 KB
/
adventure_settings.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package packet
import (
"github.com/Adrian8115/gophertunnel-Amethyst-Protocol/minecraft/protocol"
)
const (
AdventureFlagWorldImmutable = 1 << iota
AdventureSettingsFlagsNoPvM
AdventureSettingsFlagsNoMvP
AdventureSettingsFlagsUnused
AdventureSettingsFlagsShowNameTags
AdventureFlagAutoJump
AdventureFlagAllowFlight
AdventureFlagNoClip
AdventureFlagWorldBuilder
AdventureFlagFlying
AdventureFlagMuted
)
const (
CommandPermissionLevelNormal = iota
CommandPermissionLevelGameDirectors
CommandPermissionLevelAdmin
CommandPermissionLevelHost
CommandPermissionLevelOwner
CommandPermissionLevelInternal
)
const (
ActionPermissionMine = 1 << iota
ActionPermissionDoorsAndSwitches
ActionPermissionOpenContainers
ActionPermissionAttackPlayers
ActionPermissionAttackMobs
ActionPermissionOperator
ActionPermissionTeleport
ActionPermissionBuild
ActionPermissionDefault
)
const (
PermissionLevelVisitor = iota
PermissionLevelMember
PermissionLevelOperator
PermissionLevelCustom
)
// AdventureSettings is sent by the server to update game-play related features, in particular permissions to
// access these features for the client. It includes allowing the player to fly, build and mine, and attack
// entities. Most of these flags should be checked server-side instead of using this packet only.
// The client may also send this packet to the server when it updates one of these settings through the
// in-game settings interface. The server should verify if the player actually has permission to update those
// settings.
type AdventureSettings struct {
// Flags is a set of flags that specify certain properties of the player, such as whether or not it can
// fly and/or move through blocks. It is one of the AdventureFlag constants above.
Flags uint32
// CommandPermissionLevel is a permission level that specifies the kind of commands that the player is
// allowed to use. It is one of the CommandPermissionLevel constants above.
CommandPermissionLevel uint32
// ActionPermissions is, much like Flags, a set of flags that specify actions that the player is allowed
// to undertake, such as whether it is allowed to edit blocks, open doors etc. It is a combination of the
// ActionPermission constants above.
ActionPermissions uint32
// PermissionLevel is the permission level of the player as it shows up in the player list built up using
// the PlayerList packet. It is one of the PermissionLevel constants above.
PermissionLevel uint32
// CustomStoredPermissions ...
CustomStoredPermissions uint32
// PlayerUniqueID is a unique identifier of the player. This must be filled out with the entity unique ID of the
// player.
PlayerUniqueID int64
}
// ID ...
func (*AdventureSettings) ID() uint32 {
return IDAdventureSettings
}
func (pk *AdventureSettings) Marshal(io protocol.IO) {
io.Varuint32(&pk.Flags)
io.Varuint32(&pk.CommandPermissionLevel)
io.Varuint32(&pk.ActionPermissions)
io.Varuint32(&pk.PermissionLevel)
io.Varuint32(&pk.CustomStoredPermissions)
io.Int64(&pk.PlayerUniqueID)
}