Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Add load complete message and don't null the server if reloading
Dieser Commit ist enthalten in:
Ursprung
a9b414c675
Commit
4883a20797
@ -26,7 +26,7 @@
|
|||||||
package org.geysermc.platform.fabric;
|
package org.geysermc.platform.fabric;
|
||||||
|
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import net.fabricmc.api.DedicatedServerModInitializer;
|
import lombok.Setter;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
@ -55,12 +55,14 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
||||||
|
|
||||||
private static GeyserFabricMod instance;
|
private static GeyserFabricMod instance;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private boolean reloading;
|
||||||
|
|
||||||
private GeyserConnector connector;
|
private GeyserConnector connector;
|
||||||
private Path dataFolder;
|
private Path dataFolder;
|
||||||
private List<String> playerCommands;
|
private List<String> playerCommands;
|
||||||
@ -111,6 +113,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
|||||||
} else {
|
} else {
|
||||||
// Server has started and this is a reload
|
// Server has started and this is a reload
|
||||||
startGeyser(this.server);
|
startGeyser(this.server);
|
||||||
|
reloading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +165,9 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
|||||||
connector.shutdown();
|
connector.shutdown();
|
||||||
connector = null;
|
connector = null;
|
||||||
}
|
}
|
||||||
this.server = null;
|
if (!reloading) {
|
||||||
|
this.server = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,6 +31,7 @@ import net.minecraft.server.command.ServerCommandSource;
|
|||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.command.GeyserCommand;
|
import org.geysermc.connector.command.GeyserCommand;
|
||||||
import org.geysermc.connector.utils.LanguageUtils;
|
import org.geysermc.connector.utils.LanguageUtils;
|
||||||
|
import org.geysermc.platform.fabric.GeyserFabricMod;
|
||||||
|
|
||||||
public class GeyserFabricCommandExecutor implements Command<ServerCommandSource> {
|
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"));
|
sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.bootstrap.command.permission_fail"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (this.commandName.equals("reload")) {
|
||||||
|
GeyserFabricMod.getInstance().setReloading(true);
|
||||||
|
}
|
||||||
getCommand(commandName).execute(sender, new String[0]);
|
getCommand(commandName).execute(sender, new String[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,16 @@ package org.geysermc.platform.fabric.mixin.client;
|
|||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.integrated.IntegratedServer;
|
import net.minecraft.server.integrated.IntegratedServer;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.world.GameMode;
|
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.GeyserFabricMod;
|
||||||
import org.geysermc.platform.fabric.GeyserServerPortGetter;
|
import org.geysermc.platform.fabric.GeyserServerPortGetter;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@ -44,11 +49,18 @@ public class IntegratedServerMixin implements GeyserServerPortGetter {
|
|||||||
@Shadow
|
@Shadow
|
||||||
private int lanPort;
|
private int lanPort;
|
||||||
|
|
||||||
|
@Shadow @Final private MinecraftClient client;
|
||||||
|
|
||||||
@Inject(method = "openToLan", at = @At("RETURN"))
|
@Inject(method = "openToLan", at = @At("RETURN"))
|
||||||
private void onOpenToLan(GameMode gameMode, boolean cheatsAllowed, int port, CallbackInfoReturnable<Boolean> cir) {
|
private void onOpenToLan(GameMode gameMode, boolean cheatsAllowed, int port, CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (cir.getReturnValueZ()) {
|
if (cir.getReturnValueZ()) {
|
||||||
// If the LAN is opened, starts Geyser.
|
// If the LAN is opened, starts Geyser.
|
||||||
GeyserFabricMod.getInstance().startGeyser((MinecraftServer) (Object) this);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren