Add cache for GameModeConfig

This commit is contained in:
2025-10-26 13:34:25 +01:00
parent 79ebdcea85
commit 5ab04d0518
9 changed files with 61 additions and 37 deletions
@@ -22,7 +22,6 @@ package de.steamwar.bausystem.region.fixed;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.region.*;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.data.GameModeConfigUtils;
import de.steamwar.sql.GameModeConfig;
import lombok.NonNull;
import lombok.Setter;
@@ -93,8 +92,6 @@ public final class FixedGlobalRegion implements Region {
}
};
private static final GameModeConfig<Material, String> GLOBAL_CONFIG = new GameModeConfig<>(null, GameModeConfigUtils.ToMaterial, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear);
private FixedGlobalRegion() {
}
@@ -129,8 +126,8 @@ public final class FixedGlobalRegion implements Region {
}
@Override
public @NonNull GameModeConfig getGameModeConfig() {
return GLOBAL_CONFIG;
public @NonNull GameModeConfig<Material, String> getGameModeConfig() {
return GameModeConfig.getDefaults();
}
@Override
@@ -28,7 +28,6 @@ import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.core.Core;
import de.steamwar.data.GameModeConfigUtils;
import de.steamwar.sql.GameModeConfig;
import de.steamwar.sql.SchematicType;
import lombok.NonNull;
@@ -339,7 +338,11 @@ public class FixedRegion implements Region {
break;
}
}
this.gameModeConfig = new GameModeConfig<>(found, GameModeConfigUtils.ToMaterial, GameModeConfig.ToString, GameModeConfig.ToStaticWarGear);
if (found == null) {
this.gameModeConfig = GameModeConfig.getDefaults();
} else {
this.gameModeConfig = GameModeConfig.getByFileName(found);
}
this.regionData = new RegionData.RegionDataImpl(regionData, WorldData::write);
}
@@ -374,7 +377,7 @@ public class FixedRegion implements Region {
}
@Override
public @NonNull GameModeConfig getGameModeConfig() {
public @NonNull GameModeConfig<Material, String> getGameModeConfig() {
return gameModeConfig;
}