aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BerryClient/core.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/BerryClient/core.py b/BerryClient/core.py
index 1b4e5b5..28e2a3b 100644
--- a/BerryClient/core.py
+++ b/BerryClient/core.py
@@ -5,6 +5,7 @@ from importlib import import_module, reload
from mcpi import minecraft
from BerryClient.events import process_events
from BerryClient.logging import MinecraftChatHandler
+from BerryClient.commands import COMMANDS
log = logging.getLogger()
@@ -22,7 +23,7 @@ class BerryCore:
self.running = False
self.__setupLogging()
- self.__loadAddons()
+ self.__loadDefaultAddons()
def __setupLogging(self):
root_logger = logging.getLogger()
@@ -42,12 +43,21 @@ class BerryCore:
root_logger.addHandler(stdout_handler)
- def __loadAddons(self):
+ def __loadDefaultAddons(self):
for addon in self.ADDONS:
+ self.__loadAddon(addon)
+
+
+ def __loadAddon(self, addon):
+ try:
self.ADDON_MODULES[addon] = import_module(addon)
log.info(f"Loaded {addon}")
+ except ImportError as e:
+ log.error(f"Failed to load {addon}")
+ log.exception(e)
def __reloadAddons(self):
+ COMMANDS.clear()
for addon in self.ADDONS:
try:
self.ADDON_MODULES[addon] = reload(self.ADDON_MODULES[addon])
@@ -66,6 +76,9 @@ class BerryCore:
def reload(self):
self.__reloadAddons()
+ def load(self, addon):
+ self.__loadAddon(addon)
+
def stop(self):
self.running = False