From 781c8268e53a75c6d54b5305ed7a6b94c58a9c0d Mon Sep 17 00:00:00 2001 From: Keuin Date: Fri, 22 Jan 2021 21:10:56 +0800 Subject: Fix a small inconsistency between different versions --- src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/keuin/kbackupfabric') diff --git a/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java b/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java index 1d90864..e1d5cbd 100644 --- a/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java +++ b/src/main/java/com/keuin/kbackupfabric/KBPluginEvents.java @@ -9,6 +9,7 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.server.ServerStartCallback; import net.fabricmc.fabric.api.registry.CommandRegistry; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.MinecraftDedicatedServer; import java.io.File; import java.io.FileInputStream; @@ -37,6 +38,9 @@ public final class KBPluginEvents implements ModInitializer, ServerStartCallback @Override public void onStartServer(MinecraftServer server) { + if (!(server instanceof MinecraftDedicatedServer)) + throw new RuntimeException("KBackup is a server-side-only plugin. Please do not use it in Minecraft client."); + // Initialize player manager reference PrintUtil.setPlayerManager(server.getPlayerManager()); @@ -45,7 +49,7 @@ public final class KBPluginEvents implements ModInitializer, ServerStartCallback // Check if we have just recovered from a previous backup. If so, print message. try { - File levelDirectory = new File(server.getRunDirectory(), server.getLevelName()); + File levelDirectory = new File(server.getRunDirectory(), ((MinecraftDedicatedServer) server).getLevelName()); File metadataFile = new File(levelDirectory, BackupMetadata.metadataFileName); if (metadataFile.exists()) { // Metadata exists. Deserialize. -- cgit v1.2.3