forked from SteamWar/SteamWar
Hotfix static initialisation of GameModeConfig
This commit is contained in:
@@ -40,9 +40,9 @@ public final class GameModeConfig<M, W> {
|
||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||
private static final Random random = new Random();
|
||||
|
||||
private static final Map<String, GameModeConfig<?, String>> byFileName = new HashMap<>();
|
||||
private static final Map<String, GameModeConfig<?, String>> byGameName = new HashMap<>();
|
||||
private static final Map<SchematicType, GameModeConfig<?, String>> bySchematicType = new HashMap<>();
|
||||
private static final Map<String, GameModeConfig<?, String>> byFileName;
|
||||
private static final Map<String, GameModeConfig<?, String>> byGameName;
|
||||
private static final Map<SchematicType, GameModeConfig<?, String>> bySchematicType;
|
||||
|
||||
public static <M> GameModeConfig<M, String> getByFileName(File file) {
|
||||
return (GameModeConfig<M, String>) byFileName.get(file.getName());
|
||||
@@ -56,16 +56,20 @@ public final class GameModeConfig<M, W> {
|
||||
return (GameModeConfig<M, String>) bySchematicType.get(schematicType);
|
||||
}
|
||||
|
||||
static {
|
||||
SchematicType.values();
|
||||
}
|
||||
|
||||
private static final GameModeConfig<?, String> DEFAULTS = SQLWrapper.impl.loadGameModeConfig(null);
|
||||
private static final GameModeConfig<?, String> DEFAULTS;
|
||||
|
||||
public static <M> GameModeConfig<M, String> getDefaults() {
|
||||
return (GameModeConfig<M, String>) DEFAULTS;
|
||||
}
|
||||
|
||||
static {
|
||||
byFileName = new HashMap<>();
|
||||
byGameName = new HashMap<>();
|
||||
bySchematicType = new HashMap<>();
|
||||
SchematicType.values();
|
||||
DEFAULTS = SQLWrapper.impl.loadGameModeConfig(null);
|
||||
}
|
||||
|
||||
public final boolean loaded;
|
||||
public final File configFile;
|
||||
|
||||
@@ -208,15 +212,13 @@ public final class GameModeConfig<M, W> {
|
||||
|
||||
Arena = new ArenaConfig(loader.with("Arena"), Schematic.Size, EnterStages);
|
||||
|
||||
if (cacheInstance) {
|
||||
if (configFile != null) {
|
||||
byFileName.put(configFile.getName(), (GameModeConfig) this);
|
||||
}
|
||||
if (cacheInstance && file != null) {
|
||||
byFileName.put(configFile.getName(), (GameModeConfig) this);
|
||||
byGameName.put(GameName, (GameModeConfig) this);
|
||||
}
|
||||
|
||||
if (Schematic.Type != null) {
|
||||
if (cacheInstance) {
|
||||
if (cacheInstance && file != null) {
|
||||
bySchematicType.put(Schematic.Type, (GameModeConfig) this);
|
||||
if (Schematic.Type.checkType() != null) {
|
||||
bySchematicType.put(Schematic.Type.checkType(), (GameModeConfig) this);
|
||||
@@ -239,7 +241,7 @@ public final class GameModeConfig<M, W> {
|
||||
try {
|
||||
Schematic_TypeField.set(Schematic, current);
|
||||
|
||||
if (cacheInstance) {
|
||||
if (cacheInstance && file != null) {
|
||||
bySchematicType.put(Schematic.Type, (GameModeConfig) this);
|
||||
if (Schematic.Type.checkType() != null) {
|
||||
bySchematicType.put(Schematic.Type.checkType(), (GameModeConfig) this);
|
||||
|
||||
Reference in New Issue
Block a user