3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-25 15:50:14 +01:00

Add load complete message and don't null the server if reloading

Dieser Commit ist enthalten in:
DoctorMacc 2020-10-25 16:22:50 -04:00
Ursprung a9b414c675
Commit 4883a20797
3 geänderte Dateien mit 24 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -26,7 +26,7 @@
package org.geysermc.platform.fabric;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.fabricmc.api.DedicatedServerModInitializer;
import lombok.Setter;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
@ -55,12 +55,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.*;
import java.util.function.Function;
public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
private static GeyserFabricMod instance;
@Setter
private boolean reloading;
private GeyserConnector connector;
private Path dataFolder;
private List<String> playerCommands;
@ -111,6 +113,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
} else {
// Server has started and this is a reload
startGeyser(this.server);
reloading = false;
}
}
@ -162,7 +165,9 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
connector.shutdown();
connector = null;
}
this.server = null;
if (!reloading) {
this.server = null;
}
}
@Override

Datei anzeigen

@ -31,6 +31,7 @@ import net.minecraft.server.command.ServerCommandSource;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.GeyserCommand;
import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.platform.fabric.GeyserFabricMod;
public class GeyserFabricCommandExecutor implements Command<ServerCommandSource> {
@ -55,6 +56,9 @@ public class GeyserFabricCommandExecutor implements Command<ServerCommandSource>
sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.bootstrap.command.permission_fail"));
return 0;
}
if (this.commandName.equals("reload")) {
GeyserFabricMod.getInstance().setReloading(true);
}
getCommand(commandName).execute(sender, new String[0]);
return 0;
}

Datei anzeigen

@ -27,11 +27,16 @@ package org.geysermc.platform.fabric.mixin.client;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.text.LiteralText;
import net.minecraft.world.GameMode;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.platform.fabric.GeyserFabricMod;
import org.geysermc.platform.fabric.GeyserServerPortGetter;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -44,11 +49,18 @@ public class IntegratedServerMixin implements GeyserServerPortGetter {
@Shadow
private int lanPort;
@Shadow @Final private MinecraftClient client;
@Inject(method = "openToLan", at = @At("RETURN"))
private void onOpenToLan(GameMode gameMode, boolean cheatsAllowed, int port, CallbackInfoReturnable<Boolean> cir) {
if (cir.getReturnValueZ()) {
// If the LAN is opened, starts Geyser.
GeyserFabricMod.getInstance().startGeyser((MinecraftServer) (Object) this);
// Ensure player locale has been loaded, in case it's different from Java system language
LanguageUtils.loadGeyserLocale(this.client.options.language);
// Give indication that Geyser is loaded
this.client.player.sendMessage(new LiteralText(LanguageUtils.getPlayerLocaleString("geyser.core.start",
this.client.options.language, "localhost", String.valueOf(this.lanPort))), false);
}
}