Skip to content

Commit

Permalink
save config when changing
Browse files Browse the repository at this point in the history
resolve #7
  • Loading branch information
zyxkad committed Aug 10, 2024
1 parent 6d76a42 commit 4a3e5a9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions loginproxy/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def ban(self, source: MCDR.CommandSource, name: str):
conn = get_proxy().get_conn(name)
if conn is not None:
conn.kick(self.config.messages['banned.name'], server=source.get_server())
self.lists.save()
send_message(source, MSG_ID, tr_res('player.banned', name))

@Literal('banip')
Expand All @@ -136,6 +137,7 @@ def banip(self, source: MCDR.CommandSource, ip: str):
conns = get_proxy().get_conns_by_ip(ip)
for c in conns:
c.kick(msg, server=server)
self.lists.save()
send_message(source, MSG_ID, tr_res('ip.banned', ip0))

@Literal('pardon')
Expand All @@ -145,6 +147,7 @@ def pardon(self, source: MCDR.CommandSource, name: str):
except ValueError:
send_message(source, MSG_ID, tr_res('player.not_banned', name))
return
self.lists.save()
send_message(source, MSG_ID, tr_res('player.unbanned', name))

@Literal('pardonip')
Expand All @@ -158,6 +161,7 @@ def pardonip(self, source: MCDR.CommandSource, ip: str):
except ValueError:
send_message(source, MSG_ID, tr_res('ip.not_banned', ip0))
return
self.lists.save()
send_message(source, MSG_ID, tr_res('ip.unbanned', ip0))

@Literal(['whitelist', 'wh'])
Expand Down Expand Up @@ -272,6 +276,7 @@ def allow(self, source: MCDR.CommandSource, name: str):
send_message(source, MSG_ID, tr_res('player.already_allowed', name))
return
self.lists.allowed.append(name)
self.lists.save()
send_message(source, MSG_ID, tr_res('player.allowed', name))

@Literal('allowip')
Expand All @@ -283,6 +288,7 @@ def allowip(self, source: MCDR.CommandSource, ip: str):
send_message(source, MSG_ID, tr_res('ip.already_allowed', ip))
return
self.lists.allowedip.append(ip0)
self.lists.save()
send_message(source, MSG_ID, tr_res('ip.allowed', ip0))

@Literal(['remove', 'rm'])
Expand All @@ -296,6 +302,7 @@ def remove(self, source: MCDR.CommandSource, name: str):
conn = get_proxy().get_conn(name)
if conn is not None:
conn.kick(self.config.messages['whitelist.name'], server=source.get_server())
self.lists.save()
send_message(source, MSG_ID, tr_res('player.removed', name))

@Literal(['removeip', 'rmip'])
Expand All @@ -315,4 +322,5 @@ def removeip(self, source: MCDR.CommandSource, ip: str):
for c in conns:
if not self.config.check_player_level(c.ip):
c.kick(msg, server=server)
self.lists.save()
send_message(source, MSG_ID, tr_res('ip.removed', ip0))

0 comments on commit 4a3e5a9

Please sign in to comment.