mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix reloading Geyser
This commit is contained in:
parent
856ce6b588
commit
c426c335d7
2 changed files with 48 additions and 33 deletions
2
bootstrap/fabric/Jenkinsfile
vendored
2
bootstrap/fabric/Jenkinsfile
vendored
|
@ -9,7 +9,7 @@ pipeline {
|
|||
stages {
|
||||
stage ('Build') {
|
||||
steps {
|
||||
sh './gradlew clean build'
|
||||
sh './gradlew clean build --refresh-dependencies'
|
||||
}
|
||||
post {
|
||||
success {
|
||||
|
|
|
@ -97,9 +97,27 @@ public class GeyserFabricMod implements DedicatedServerModInitializer, GeyserBoo
|
|||
|
||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
||||
|
||||
if (server == null) {
|
||||
// Server has yet to start
|
||||
// Set as an event so we can get the proper IP and port if needed
|
||||
ServerLifecycleEvents.SERVER_STARTED.register((server) -> {
|
||||
// Required to do this so we can get the proper IP and port if needed
|
||||
this.server = server;
|
||||
startGeyser();
|
||||
});
|
||||
|
||||
// Register onDisable so players are properly kicked
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register((server) -> onDisable());
|
||||
} else {
|
||||
// Server has started and this is a reload
|
||||
startGeyser();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize core Geyser.
|
||||
* A function, as it needs to be called in different places depending on if Geyser is being reloaded or not.
|
||||
*/
|
||||
public void startGeyser() {
|
||||
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||
String ip = server.getServerIp();
|
||||
|
@ -131,16 +149,13 @@ public class GeyserFabricMod implements DedicatedServerModInitializer, GeyserBoo
|
|||
!playerCommands.contains(command.getKey()))));
|
||||
}
|
||||
server.getCommandManager().getDispatcher().register(builder);
|
||||
});
|
||||
|
||||
// Register onDisable so players are properly kicked
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register((server) -> onDisable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (connector != null) {
|
||||
connector.shutdown();
|
||||
connector = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue