diff options
author | Himbeer <himbeer@disroot.org> | 2024-11-17 18:06:47 +0100 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-11-17 18:06:47 +0100 |
commit | 1146868006773592b8119dd61bdd95d6136c79b8 (patch) | |
tree | 0f1a24f29d0093cd992bf9c7f6a7be2756d33f31 | |
parent | fb8ce8c1891ee326ebe769eff511826e4f8e639b (diff) |
Implement banning offline players
This change is enabled by the proxy exposing the authentication backend.
-rw-r--r-- | chatcommands.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/chatcommands.go b/chatcommands.go index a546356..871eac3 100644 --- a/chatcommands.go +++ b/chatcommands.go @@ -557,15 +557,23 @@ func init() { Name: "ban", Perm: "cmd_ban", Help: "Ban a player from using the proxy.", - Usage: "ban <name>", + Usage: "ban <name> [address]", Handler: func(cc *proxy.ClientConn, args ...string) string { - if len(args) != 1 { - return "Usage: ban <name>" + if len(args) < 1 { + return "Usage: ban <name> [address]" + } + + if len(args) == 2 { + if err := proxy.DefaultAuth().Ban(args[1], args[0]); err != nil { + return "Could not ban. Error: " + err.Error() + } + + return "Address banned." } clt := proxy.Find(args[0]) if clt == nil { - return "Player is not connected." + return "Player is not connected. Usage: ban <name> <address>" } if err := clt.Ban(); err != nil { |