fix client file configuration respectedly
This commit is contained in:
@@ -2,6 +2,7 @@ package whirlfrenzy.itemdespawntimer.config;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
@@ -18,6 +19,15 @@ public final class ServerConfig {
|
||||
}
|
||||
private ServerConfig() {}
|
||||
public static void load() {
|
||||
// The common/main initializer also runs in a physical Minecraft client.
|
||||
// Never create or read the server config there: a client installation owns
|
||||
// presentation settings only. Integrated singleplayer uses server defaults
|
||||
// in memory; a dedicated server owns the persistent server config file.
|
||||
if (FabricLoader.getInstance().getEnvironmentType() != EnvType.SERVER) {
|
||||
data = new Data();
|
||||
return;
|
||||
}
|
||||
|
||||
Path p = FabricLoader.getInstance().getConfigDir().resolve("item-despawn-timer-server.json");
|
||||
try {
|
||||
if (Files.exists(p)) { try (Reader r=Files.newBufferedReader(p)) { Data d=GSON.fromJson(r,Data.class); if(d!=null)data=d; } }
|
||||
|
||||
Reference in New Issue
Block a user