Skip to content
This repository was archived by the owner on Apr 27, 2019. It is now read-only.

Commit 1c97d8b

Browse files
committed
Added shutdown command for owners.
1 parent 9a7577f commit 1c97d8b

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

plugins/admin_commands_plugin/admin_command_plugin.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from twisted.internet import reactor
12
from base_plugin import SimpleCommandPlugin, BasePlugin
23
from core_plugins.player_manager import permissions, UserLevels
34
from packets import chat_sent
@@ -10,7 +11,7 @@ class UserCommandPlugin(SimpleCommandPlugin):
1011
"""
1112
name = "user_management_commands"
1213
depends = ['command_dispatcher', 'player_manager']
13-
commands = ["who", "whois", "promote", "kick", "ban", "give_item", "planet", "mute", "unmute", "passthrough"]
14+
commands = ["who", "whois", "promote", "kick", "ban", "give_item", "planet", "mute", "unmute", "passthrough", "shutdown"]
1415
auto_activate = True
1516

1617
def activate(self):
@@ -201,11 +202,17 @@ def unmute(self, data):
201202
target_protocol.send_chat_message("You have been unmuted.")
202203
self.protocol.send_chat_message("%s has been unmuted." % name)
203204

204-
@permissions(UserLevels.OWNER)
205+
@permissions(UserLevels.ADMIN)
205206
def passthrough(self, data):
206207
"""Sets the server to passthrough mode. *This is irreversible without restart.* Syntax: /passthrough"""
207208
self.config.passthrough = True
208209

210+
@permissions(UserLevels.ADMIN)
211+
def shutdown(self, data):
212+
"""Shutdown the server in n seconds. Syntax: /shutdown [number of seconds] (>0)"""
213+
x = float(data[0])
214+
self.protocol.factory.broadcast("SERVER ANNOUNCEMENT: Server is shutting down in %s seconds!" % data[0])
215+
reactor.callLater(x, reactor.stop)
209216

210217
class MuteManager(BasePlugin):
211218
name = "mute_manager"

0 commit comments

Comments
 (0)