Closed Minetest-j45 closed 2 years ago
This won't work if you have no group (it will crash the proxy). Since proxy.Conf().UserGroups
is a map that's directly being decoded into there is no default value, you need to handle it yourself. See the group
command:
proxy.RegisterChatCmd(proxy.ChatCmd{
Name: "group",
Perm: "cmd_group",
Help: "Display the group of a player. Display your group if no player name is specified.",
Usage: "group [name]",
TelnetUsage: "group <name>",
Handler: func(cc *proxy.ClientConn, w io.Writer, args ...string) string {
if len(args) > 0 {
if len(args) != 1 {
return "Usage: group [name]"
}
grp, ok := proxy.Conf().UserGroups[args[0]]
if !ok {
grp = "default"
}
return "Group: " + grp
}
if cc == nil {
return "Telnet usage: group <name>"
}
grp, ok := proxy.Conf().UserGroups[cc.Name()]
if !ok {
grp = "default"
}
return "Your group: " + grp
},
})
With the
gperms
command, you can only dogperms <group>
, and the group is not optional. This is inconsistent withperms
, which defaults to you if you don't specify aname
.Here is an untested diff file that might fix it but I'm not sure if it will work. diff.txt To test this, use
git apply diff.txt
to apply the diff file to your local branch