Skip to content

Commit

Permalink
Merge pull request #1046 from thatsIch/b-976-version-checker
Browse files Browse the repository at this point in the history
Fixes #976 Now uses GitHub to retrieve most current version
  • Loading branch information
thatsIch committed Mar 17, 2015
2 parents e0b32d2 + 6baf952 commit 34597a4
Show file tree
Hide file tree
Showing 33 changed files with 2,015 additions and 161 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jar {
minecraft {
version = config.minecraft_version + "-" + config.forge_version

replaceIn "AEConfig.java"
replace "@version@", project.version
replace "@aechannel@", config.aechannel

Expand Down
34 changes: 5 additions & 29 deletions src/main/java/appeng/core/AEConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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@";

Expand Down Expand Up @@ -149,7 +146,7 @@ public Property get(String category, String key, String defaultValue, String com
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;
Expand Down Expand Up @@ -224,22 +221,20 @@ public boolean disableColoredCableRecipesInNEI()

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 );
Expand Down Expand Up @@ -340,19 +335,6 @@ public AEConfig(String path) {
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;
}

Expand Down Expand Up @@ -411,12 +393,6 @@ public void updateSetting(IConfigManager manager, Enum setting, Enum newValue)
@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 );
Expand Down
36 changes: 23 additions & 13 deletions src/main/java/appeng/core/AppEng.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
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;
Expand All @@ -37,6 +35,8 @@
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;
Expand All @@ -47,6 +47,7 @@
import appeng.integration.IntegrationType;
import appeng.server.AECommand;
import appeng.services.VersionChecker;
import appeng.services.version.VersionCheckerConfig;
import appeng.util.Platform;


Expand All @@ -70,7 +71,7 @@ public class AppEng

private final IMCHandler imcHandler;

private String configPath;
private File configDirectory;

public AppEng()
{
Expand All @@ -81,9 +82,9 @@ public 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 )
Expand All @@ -104,11 +105,16 @@ void preInit( FMLPreInitializationEvent event )
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");

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( this.configPath );
FacadeConfig.instance = new FacadeConfig( this.configPath );
AEConfig.instance = new AEConfig( configFile );
FacadeConfig.instance = new FacadeConfig( facadeFile );
final VersionCheckerConfig versionCheckerConfig = new VersionCheckerConfig( versionFile );

AELog.info( "Pre Initialization ( started )" );

Expand All @@ -121,19 +127,23 @@ void preInit( FMLPreInitializationEvent event )

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();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/appeng/core/FacadeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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]" );
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/appeng/core/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@

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;
Expand All @@ -41,6 +37,10 @@
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;
Expand Down Expand Up @@ -546,7 +546,7 @@ public void initialize( FMLInitializationEvent event )
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" );

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/core/features/AEFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/hooks/MeteoriteWorldGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import appeng.core.WorldSettings;
import appeng.core.features.registries.WorldGenRegistry;
import appeng.helpers.MeteoritePlacer;
import appeng.services.helpers.ICompassCallback;
import appeng.services.compass.ICompassCallback;
import appeng.util.Platform;

final public class MeteoriteWorldGen implements IWorldGenerator
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/appeng/recipes/loader/ConfigLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,29 @@

package appeng.recipes.loader;


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;

import appeng.api.recipes.IRecipeLoader;

public class ConfigLoader implements IRecipeLoader
{

private final String rootPath;
public final class ConfigLoader implements IRecipeLoader
{
private final File rootDirectory;

public ConfigLoader(String s) {
this.rootPath = s;
public ConfigLoader( File rootDirectory )
{
this.rootDirectory = rootDirectory;
}

@Override
public BufferedReader getFile(String s) throws Exception
public BufferedReader getFile( String s ) throws Exception
{
File f = new File( this.rootPath + s );
final File f = new File( this.rootDirectory, s );

return new BufferedReader( new InputStreamReader( new FileInputStream( f ), "UTF-8" ) );
}
}
4 changes: 2 additions & 2 deletions src/main/java/appeng/services/CompassService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

import appeng.api.AEApi;
import appeng.api.util.DimensionalCoord;
import appeng.services.helpers.CompassReader;
import appeng.services.helpers.ICompassCallback;
import appeng.services.compass.CompassReader;
import appeng.services.compass.ICompassCallback;

public class CompassService implements ThreadFactory
{
Expand Down
Loading

0 comments on commit 34597a4

Please sign in to comment.