Allow events to be registered by any class

Supersedes & closes #3073

Co-authored-by: Redned <redned235@gmail.com>
This commit is contained in:
ImDaBigBoss 2022-09-04 16:11:08 -05:00 committed by RednedEpic
parent db3b470225
commit f1da9d7072
25 changed files with 353 additions and 115 deletions

View file

@ -72,8 +72,7 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
private GeyserImpl geyser;
@Override
public void onEnable() {
public void onLoad() {
GeyserLocale.init(this);
if (!configDir.exists())
@ -114,7 +113,13 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
this.geyser = GeyserImpl.start(PlatformType.SPONGE, this);
this.geyser = GeyserImpl.load(PlatformType.SPONGE, this);
}
@Override
public void onEnable() {
GeyserImpl.start();
if (geyserConfig.isLegacyPingPassthrough()) {
this.geyserSpongePingPassthrough = GeyserLegacyPingPassthrough.init(geyser);
@ -124,6 +129,7 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
this.geyserCommandManager = new GeyserSpongeCommandManager(Sponge.getCommandManager(), geyser);
this.geyserCommandManager.init();
Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(geyser, geyserCommandManager.getCommands()), "geyser");
for (Map.Entry<Extension, Map<String, Command>> entry : this.geyserCommandManager.extensionCommands().entrySet()) {
@ -166,6 +172,11 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
return configDir.toPath();
}
@Listener
public void onServerStarting() {
onLoad();
}
@Listener
public void onServerStart(GameStartedServerEvent event) {
onEnable();