Fixes 1878: Now saves worlddata more reliable.

This commit is contained in:
yueh 2015-09-16 20:23:26 +02:00 committed by thatsIch
parent 97b7583ff2
commit 174818c6d8
4 changed files with 15 additions and 19 deletions

View file

@ -19,7 +19,6 @@
package appeng.core.worlddata; package appeng.core.worlddata;
import java.io.File;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -64,13 +63,11 @@ final class DimensionData implements IWorldDimensionData, IOnWorldStartable, IOn
private final Configuration config; private final Configuration config;
private final List<Integer> storageCellDimensionIDs; private final List<Integer> storageCellDimensionIDs;
DimensionData( @Nonnull final File parentFile, @Nonnull final String configVersion ) DimensionData( @Nonnull final Configuration parentFile )
{ {
Preconditions.checkNotNull( parentFile ); Preconditions.checkNotNull( parentFile );
Preconditions.checkNotNull( configVersion );
Preconditions.checkArgument( !configVersion.isEmpty() );
this.config = new Configuration( parentFile, configVersion ); this.config = parentFile;
final int[] storageCellIDs = this.storageCellIDsProperty().getIntList(); final int[] storageCellIDs = this.storageCellIDsProperty().getIntList();

View file

@ -19,7 +19,6 @@
package appeng.core.worlddata; package appeng.core.worlddata;
import java.io.File;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -57,13 +56,11 @@ final class PlayerData implements IWorldPlayerData, IOnWorldStartable, IOnWorldS
private int lastPlayerID; private int lastPlayerID;
public PlayerData( @Nonnull final File configFile, @Nonnull final String configVersion ) public PlayerData( @Nonnull final Configuration configFile )
{ {
Preconditions.checkNotNull( configFile ); Preconditions.checkNotNull( configFile );
Preconditions.checkNotNull( configVersion );
Preconditions.checkArgument( !configVersion.isEmpty() );
this.config = new Configuration( configFile, configVersion ); this.config = configFile;
final ConfigCategory playerList = this.config.getCategory( "players" ); final ConfigCategory playerList = this.config.getCategory( "players" );
this.playerMapping = new PlayerMapping( playerList ); this.playerMapping = new PlayerMapping( playerList );

View file

@ -19,7 +19,6 @@
package appeng.core.worlddata; package appeng.core.worlddata;
import java.io.File;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
@ -55,13 +54,11 @@ final class StorageData implements IWorldGridStorageData, IOnWorldStartable, IOn
private long lastGridStorage; private long lastGridStorage;
public StorageData( @Nonnull final File settingsFile, @Nonnull final String version ) public StorageData( @Nonnull final Configuration settingsFile )
{ {
Preconditions.checkNotNull( settingsFile ); Preconditions.checkNotNull( settingsFile );
Preconditions.checkNotNull( version );
Preconditions.checkArgument( !version.isEmpty() );
this.config = new Configuration( settingsFile, version ); this.config = settingsFile;
} }
/** /**

View file

@ -30,6 +30,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.config.Configuration;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.services.CompassService; import appeng.services.CompassService;
@ -39,7 +40,8 @@ import appeng.services.compass.CompassThreadFactory;
/** /**
* Singleton access to anything related to world-based data. * Singleton access to anything related to world-based data.
* *
* Data will change depending which world is loaded. Will probably not affect SMP at all since only one world is loaded, but SSP more, cause they play on * Data will change depending which world is loaded. Will probably not affect SMP at all since only one world is loaded,
* but SSP more, cause they play on
* different worlds. * different worlds.
* *
* @author thatsIch * @author thatsIch
@ -69,6 +71,8 @@ public final class WorldData implements IWorldData
private final File spawnDirectory; private final File spawnDirectory;
private final File compassDirectory; private final File compassDirectory;
private final Configuration sharedConfig;
private WorldData( @Nonnull final File worldDirectory ) private WorldData( @Nonnull final File worldDirectory )
{ {
Preconditions.checkNotNull( worldDirectory ); Preconditions.checkNotNull( worldDirectory );
@ -79,10 +83,11 @@ public final class WorldData implements IWorldData
this.compassDirectory = new File( this.ae2directory, COMPASS_DIR_NAME ); this.compassDirectory = new File( this.ae2directory, COMPASS_DIR_NAME );
final File settingsFile = new File( this.ae2directory, SETTING_FILE_NAME ); final File settingsFile = new File( this.ae2directory, SETTING_FILE_NAME );
this.sharedConfig = new Configuration( settingsFile, AEConfig.VERSION );
final PlayerData playerData = new PlayerData( settingsFile, AEConfig.VERSION ); final PlayerData playerData = new PlayerData( this.sharedConfig );
final DimensionData dimensionData = new DimensionData( settingsFile, AEConfig.VERSION ); final DimensionData dimensionData = new DimensionData( this.sharedConfig );
final StorageData storageData = new StorageData( settingsFile, AEConfig.VERSION ); final StorageData storageData = new StorageData( this.sharedConfig );
final ThreadFactory compassThreadFactory = new CompassThreadFactory(); final ThreadFactory compassThreadFactory = new CompassThreadFactory();
final CompassService compassService = new CompassService( this.compassDirectory, compassThreadFactory ); final CompassService compassService = new CompassService( this.compassDirectory, compassThreadFactory );