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

Commit 28e731b

Browse files
committed
Added reload_plugins, removed old command from admin_command_plugin.
1 parent ca33e65 commit 28e731b

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

plugin_manager.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ def load_plugins(self, plugin_dir):
9393
except ImportError:
9494
self.logger.debug("Import error for %s", name)
9595

96+
def reload_plugins(self):
97+
self.logger.warning("Reloading plugins.")
98+
for x in self.plugins:
99+
del x
100+
self.plugins = []
101+
try:
102+
self.load_plugins(self.core_plugin_dir)
103+
self.load_plugins(self.plugin_dir)
104+
self.activate_plugins()
105+
except:
106+
self.logger.exception("Couldn't reload plugins!")
107+
raise
108+
109+
110+
96111
def activate_plugins(self):
97112
for plugin in self.plugins:
98113
if plugin.auto_activate:

plugins/admin_commands_plugin/admin_command_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class UserCommandPlugin(SimpleCommandPlugin):
99
"""
1010
name = "user_management_commands"
1111
depends = ['command_dispatcher', 'player_manager']
12-
commands = ["who", "whois", "promote", "kick", "ban", "kickban", "give_item", "planet"]
12+
commands = ["who", "whois", "promote", "kick", "ban", "give_item", "planet"]
1313
auto_activate = True
1414

1515
def activate(self):

plugins/announcer_plugin/announcer_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from base_plugin import BasePlugin
22

3-
43
class Announcer(BasePlugin):
54
"""
65
Broadcasts a message whenever a player joins or leaves the server.
@@ -10,6 +9,7 @@ class Announcer(BasePlugin):
109

1110
def activate(self):
1211
super(Announcer, self).activate()
12+
print "Boop"
1313

1414
def after_connect_response(self, data):
1515
try:

plugins/plugin_manager_plugin/plugin_manager_plugin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class PluginManagerPlugin(SimpleCommandPlugin):
77
name = "plugin_manager"
8-
commands = ["list_plugins", "enable_plugin", "disable_plugin", "help"]
8+
commands = ["list_plugins", "enable_plugin", "disable_plugin", "help", "reload_plugins"]
99
auto_activate = True
1010

1111
@property
@@ -62,6 +62,11 @@ def enable_plugin(self, data):
6262
plugin.activate()
6363
self.protocol.send_chat_message("Successfully activated plugin.")
6464

65+
@permissions(UserLevels.ADMIN)
66+
def reload_plugins(self, data):
67+
"""Reloads all active plugins. Syntax: /reload_plugins"""
68+
self.plugin_manager.reload_plugins()
69+
6570
def help(self, data):
6671
"""Prints help messages for plugin commands. Syntax: /help [command]"""
6772
if len(data) > 0:

0 commit comments

Comments
 (0)