Fixes #976 Now uses GitHub to retrieve most current version

Reworked whole Version Checker with an extensible interface to add any other service later on easier.
The version checker now has its own config file, to collect the different options and extract them from the main config file.
In that you can specify how fine the versions should be checked.
This commit is contained in:
thatsIch
2015-03-09 17:35:19 +01:00
parent 720b38442e
commit 6baf952904
33 changed files with 2023 additions and 169 deletions
+5 -29
View File
@@ -55,9 +55,6 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
public static final double TUNNEL_POWER_LOSS = 0.05;
public String latestVersion = VERSION;
public long latestTimeStamp = 0;
public static final String VERSION = "@version@";
public static final String CHANNEL = "@aechannel@";
@@ -149,7 +146,7 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
public boolean disableColoredCableRecipesInNEI = true;
public boolean updatable = false;
final private File myPath;
final private File configFile;
public double meteoriteClusterChance = 0.1;
public double meteoriteSpawnChance = 0.3;
@@ -224,22 +221,20 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
public String getFilePath()
{
return this.myPath.toString();
return this.configFile.toString();
}
public AEConfig(String path) {
super( new File( path + "AppliedEnergistics2.cfg" ) );
this.myPath = new File( path + "AppliedEnergistics2.cfg" );
public AEConfig( File configFile ) {
super( configFile );
this.configFile = configFile;
FMLCommonHandler.instance().bus().register( this );
final double DEFAULT_BC_EXCHANGE = 5.0;
final double DEFAULT_IC2_EXCHANGE = 2.0;
final double DEFAULT_RTC_EXCHANGE = 1.0 / 11256.0;
final double DEFAULT_RF_EXCHANGE = 0.5;
final double DEFAULT_MEKANISM_EXCHANGE = 0.2;
PowerUnits.MJ.conversionRatio = this.get( "PowerRatios", "BuildCraft", DEFAULT_BC_EXCHANGE ).getDouble( DEFAULT_BC_EXCHANGE );
PowerUnits.MK.conversionRatio = this.get( "PowerRatios", "Mekanism", DEFAULT_MEKANISM_EXCHANGE ).getDouble( DEFAULT_MEKANISM_EXCHANGE );
PowerUnits.EU.conversionRatio = this.get( "PowerRatios", "IC2", DEFAULT_IC2_EXCHANGE ).getDouble( DEFAULT_IC2_EXCHANGE );
PowerUnits.WA.conversionRatio = this.get( "PowerRatios", "RotaryCraft", DEFAULT_RTC_EXCHANGE ).getDouble( DEFAULT_RTC_EXCHANGE );
@@ -340,19 +335,6 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
this.craftingCalculationTimePerTick );
}
if ( this.isFeatureEnabled( AEFeature.VersionChecker ) )
{
try
{
this.latestVersion = this.get( "VersionChecker", "LatestVersion", "" ).getString();
this.latestTimeStamp = Long.parseLong( this.get( "VersionChecker", "LatestTimeStamp", "" ).getString() );
}
catch (NumberFormatException err)
{
this.latestTimeStamp = 0;
}
}
this.updatable = true;
}
@@ -411,12 +393,6 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
@Override
public void save()
{
if ( this.isFeatureEnabled( AEFeature.VersionChecker ) )
{
this.get( "VersionChecker", "LatestVersion", this.latestVersion ).set( this.latestVersion );
this.get( "VersionChecker", "LatestTimeStamp", "" ).set( Long.toString( this.latestTimeStamp ) );
}
if ( this.isFeatureEnabled( AEFeature.SpatialIO ) )
{
this.get( "spatialio", "storageBiomeID", this.storageBiomeID ).set( this.storageBiomeID );
+23 -13
View File
@@ -22,8 +22,6 @@ package appeng.core;
import java.io.File;
import java.util.concurrent.TimeUnit;
import com.google.common.base.Stopwatch;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
@@ -37,6 +35,8 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import com.google.common.base.Stopwatch;
import appeng.core.crash.CrashEnhancement;
import appeng.core.crash.CrashInfo;
import appeng.core.features.AEFeature;
@@ -47,6 +47,7 @@ import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.server.AECommand;
import appeng.services.VersionChecker;
import appeng.services.version.VersionCheckerConfig;
import appeng.util.Platform;
@@ -70,7 +71,7 @@ public class AppEng
private final IMCHandler imcHandler;
private String configPath;
private File configDirectory;
public AppEng()
{
@@ -81,9 +82,9 @@ public class AppEng
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( CrashInfo.MOD_VERSION ) );
}
public String getConfigPath()
public final File getConfigDirectory()
{
return this.configPath;
return this.configDirectory;
}
public boolean isIntegrationEnabled( IntegrationType integrationName )
@@ -104,11 +105,16 @@ public class AppEng
CommonHelper.proxy.missingCoreMod();
}
Stopwatch star = Stopwatch.createStarted();
this.configPath = event.getModConfigurationDirectory().getPath() + File.separator + "AppliedEnergistics2" + File.separator;
Stopwatch watch = Stopwatch.createStarted();
this.configDirectory = new File(event.getModConfigurationDirectory().getPath(), "AppliedEnergistics2");
AEConfig.instance = new AEConfig( this.configPath );
FacadeConfig.instance = new FacadeConfig( this.configPath );
final File configFile = new File( this.configDirectory, "AppliedEnergistics2.cfg");
final File facadeFile = new File( this.configDirectory, "Facades.cfg" );
final File versionFile = new File( this.configDirectory, "VersionChecker.cfg" );
AEConfig.instance = new AEConfig( configFile );
FacadeConfig.instance = new FacadeConfig( facadeFile );
final VersionCheckerConfig versionCheckerConfig = new VersionCheckerConfig( versionFile );
AELog.info( "Pre Initialization ( started )" );
@@ -121,19 +127,23 @@ public class AppEng
Registration.INSTANCE.preInitialize( event );
if ( AEConfig.instance.isFeatureEnabled( AEFeature.VersionChecker ) )
if ( versionCheckerConfig.isEnabled() )
{
AELog.info( "Starting VersionChecker" );
this.startService( "AE2 VersionChecker", new Thread( new VersionChecker() ) );
final VersionChecker versionChecker = new VersionChecker( versionCheckerConfig );
final Thread versionCheckerThread = new Thread( versionChecker );
this.startService( "AE2 VersionChecker", versionCheckerThread );
}
AELog.info( "Pre Initialization ( ended after " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
AELog.info( "Pre Initialization ( ended after " + watch.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
}
private void startService( String serviceName, Thread thread )
{
thread.setName( serviceName );
thread.setPriority( Thread.MIN_PRIORITY );
AELog.info( "Starting " + serviceName );
thread.start();
}
+2 -2
View File
@@ -35,8 +35,8 @@ public class FacadeConfig extends Configuration
public static FacadeConfig instance;
final Pattern replacementPattern;
public FacadeConfig(String path) {
super( new File( path + "Facades.cfg" ) );
public FacadeConfig( File facadeFile ) {
super( facadeFile );
this.replacementPattern = Pattern.compile( "[^a-zA-Z0-9]" );
}
+5 -5
View File
@@ -21,10 +21,6 @@ package appeng.core;
import java.lang.reflect.Field;
import com.google.common.base.Optional;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.biome.BiomeGenBase;
@@ -41,6 +37,10 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.VillagerRegistry;
import com.google.common.base.Optional;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import appeng.api.AEApi;
import appeng.api.IAppEngApi;
import appeng.api.config.Upgrades;
@@ -546,7 +546,7 @@ public final class Registration
ItemMultiMaterial.instance.makeUnique();
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CustomRecipes ) )
this.recipeHandler.parseRecipes( new ConfigLoader( AppEng.instance.getConfigPath() ), "index.recipe" );
this.recipeHandler.parseRecipes( new ConfigLoader( AppEng.instance.getConfigDirectory() ), "index.recipe" );
else
this.recipeHandler.parseRecipes( new JarLoader( "/assets/appliedenergistics2/recipes/" ), "index.recipe" );
@@ -62,7 +62,7 @@ public enum AEFeature
MassCannonBlockDamage("BlockFeatures"), TinyTNTBlockDamage("BlockFeatures"), Facades("Facades"),
VersionChecker("Services"), UnsupportedDeveloperTools("Misc", false), Creative("Misc"),
UnsupportedDeveloperTools("Misc", false), Creative("Misc"),
GrinderLogging("Misc", false), Logging("Misc"), IntegrationLogging("Misc", false), CustomRecipes("Crafting", false), WebsiteRecipes("Misc", false),
@@ -29,7 +29,7 @@ import appeng.core.WorldSettings;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.core.sync.network.NetworkHandler;
import appeng.services.helpers.ICompassCallback;
import appeng.services.compass.ICompassCallback;
public class PacketCompassRequest extends AppEngPacket implements ICompassCallback
{