Refactor startup logic.

This commit re-implements and rearranges a lot of the logic in the main plugin class. It also removes the ConfigCommand class and moves its functionality into the CommandHandler to allow for reloads to be a bit more special than normal commands.

In the refactoring of the main class, the startup logic is broken up into two phases, setup and (re)load:

- In the setup phase, we create the data folder, and the command handler, config serializer(s), plugin integrations, boss abilities, the global event listener, and metrics are initialized. The ArenaMaster is instantiated, but it isn't initialized. These are things that need to be set up just once and don't change on reloads.

- In the (re)load phase, the config-file is loaded from disk, the global messenger is instantiated, the arena master is initialized (loads settings, classes, and arenas), the announcements file is loaded from disk along with the sign data/templates. These are things that we want to be reloadable.

If anything goes wrong during these phases, we store the exception thrown. This puts MobArena into a state where it prints the exception message to anyone who types a non-reload MobArena command to bring attention to the error so it can be fixed.
This commit is contained in:
Andreas Troelsen
2018-08-10 23:23:30 +02:00
parent dc25a38d98
commit 2081405d3b
7 changed files with 296 additions and 268 deletions
+3
View File
@@ -16,6 +16,9 @@ These changes will (most likely) be included in the next version.
- Right-clicking is now allowed in the lobby. This makes it possible to activate blocks like buttons and levers.
- Snow and ice no longer melts in arenas.
- Much of the parsing logic has been rewritten so that MobArena now logs more user-friendly errors when it encounters invalid values in the config-file.
- If MobArena fails to load due to config-file errors, it now enters a type of "error state". In this state, it responds to all commands (except for the reload command) with a short message explaining why it's disabled.
- It is now possible to reload config-files with `/ma reload`.
- The reload command now also reloads global settings, e.g. the global messenger prefix.
Thanks to:
- PrinceIonia and Nesseley for help with test of dev builds