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 {
|
stages {
|
||||||
stage ('Build') {
|
stage ('Build') {
|
||||||
steps {
|
steps {
|
||||||
sh './gradlew clean build'
|
sh './gradlew clean build --refresh-dependencies'
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
|
|
|
@ -97,9 +97,27 @@ public class GeyserFabricMod implements DedicatedServerModInitializer, GeyserBoo
|
||||||
|
|
||||||
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
|
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) -> {
|
ServerLifecycleEvents.SERVER_STARTED.register((server) -> {
|
||||||
// Required to do this so we can get the proper IP and port if needed
|
|
||||||
this.server = server;
|
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")) {
|
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||||
String ip = server.getServerIp();
|
String ip = server.getServerIp();
|
||||||
|
@ -131,16 +149,13 @@ public class GeyserFabricMod implements DedicatedServerModInitializer, GeyserBoo
|
||||||
!playerCommands.contains(command.getKey()))));
|
!playerCommands.contains(command.getKey()))));
|
||||||
}
|
}
|
||||||
server.getCommandManager().getDispatcher().register(builder);
|
server.getCommandManager().getDispatcher().register(builder);
|
||||||
});
|
|
||||||
|
|
||||||
// Register onDisable so players are properly kicked
|
|
||||||
ServerLifecycleEvents.SERVER_STOPPING.register((server) -> onDisable());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (connector != null) {
|
if (connector != null) {
|
||||||
connector.shutdown();
|
connector.shutdown();
|
||||||
|
connector = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue