Skip to content

Commit

Permalink
update pulsar handling to use pulsars autogenerated configs
Browse files Browse the repository at this point in the history
use .cfg file for tcon -- legacy one should be renamed if it is the only one present
only save config files if they have actually changed
  • Loading branch information
progwml6 committed Jul 1, 2014
1 parent 3de90bd commit 75ea872
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 75 deletions.
2 changes: 1 addition & 1 deletion build.properties
@@ -1,7 +1,7 @@
minecraft_version=1.7.10
minecraft_version_old=1.7.2
forge_version=10.13.0.1151
mantle_version=152.e3820d9
mantle_version=155.504b639
FMP_version=1.1.0.268
CCLIB_version=1.1.0.77
NEI_version=1.0.1
Expand Down
24 changes: 8 additions & 16 deletions src/main/java/tconstruct/TConstruct.java
Expand Up @@ -80,7 +80,7 @@ public class TConstruct
public static TProxyCommon proxy;

/* Loads modules in a way that doesn't clutter the @Mod list */
private PulseManager pulsar = new PulseManager(modID); //Scheduled to change shortly.
private PulseManager pulsar = new PulseManager(modID, "TinkersModules"); //Scheduled to change shortly.

public TConstruct()
{
Expand All @@ -102,21 +102,13 @@ public void preInit (FMLPreInitializationEvent event)
{
PHConstruct.initProps(event.getModConfigurationDirectory());

//Temporarily hijacked
if (PHConstruct.worldModule)
pulsar.registerPulse(new TinkerWorld());
if (PHConstruct.toolModule)
pulsar.registerPulse(new TinkerTools());
if (PHConstruct.smelteryModule)
pulsar.registerPulse(new TinkerSmeltery());
if (PHConstruct.mechworksModule)
pulsar.registerPulse(new TinkerMechworks());
if (PHConstruct.armorModule)
pulsar.registerPulse(new TinkerArmor());
/*if (PHConstruct.prayerModule)
pulsar.registerPulse(new TinkerPrayers());
if (PHConstruct.cropifyModule)
pulsar.registerPulse(new TinkerCropify());*/
pulsar.registerPulse(new TinkerWorld());
pulsar.registerPulse(new TinkerTools());
pulsar.registerPulse(new TinkerSmeltery());
pulsar.registerPulse(new TinkerMechworks());
pulsar.registerPulse(new TinkerArmor());
/*pulsar.registerPulse(new TinkerPrayers());
pulsar.registerPulse(new TinkerCropify());*/

TConstructRegistry.materialTab = new TabTools("TConstructMaterials");
TConstructRegistry.toolTab = new TabTools("TConstructTools");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/armor/TinkerArmor.java
Expand Up @@ -42,7 +42,7 @@
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;

@ObjectHolder(TConstruct.modID)
@Pulse(id = TConstruct.modID)
@Pulse(id = "TinkerArmor", description = "Modifyable armors, such as the traveller's gear.")
public class TinkerArmor implements IPulse //TODO: Remove IPulse implementation, keep annotation
{
@Instance("TinkerArmor")
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/tconstruct/mechworks/TinkerMechworks.java
Expand Up @@ -27,7 +27,8 @@
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;

@ObjectHolder(TConstruct.modID)
@Pulse(id = TConstruct.modID)
//TODO handle migration of all items/blocks that were owned by the previously seperate mod
@Pulse(id = "TinkerMechworks", description = "Mechanical machinations and steampunk inspired shenanigans.")
public class TinkerMechworks implements IPulse //TODO: Remove IPulse implementation, keep annotation
{
@PulseProxy(client = "tconstruct.mechworks.MechworksProxyClient", server = "tconstruct.mechworks.MechworksProxyCommon")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/smeltery/TinkerSmeltery.java
Expand Up @@ -86,7 +86,7 @@
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;

@ObjectHolder(TConstruct.modID)
@Pulse(id = TConstruct.modID)
@Pulse(id = "TinkerSmeltery", description = "Liquid metals, casting, and the multiblock structure.")
public class TinkerSmeltery implements IPulse //TODO: Remove IPulse implementation, keep annotation
{
@Instance("TinkerSmeltery")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/tools/TinkerTools.java
Expand Up @@ -120,7 +120,7 @@
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;

@ObjectHolder(TConstruct.modID)
@Pulse(id = TConstruct.modID)
@Pulse(id = "TinkerTools", description = "The main core of the mod! All of the tools, the tables, and the patterns are here.")
public class TinkerTools implements IPulse //TODO: Remove IPulse implementation, keep annotation
{
/* Proxies for sides, used for graphics processing */
Expand Down
63 changes: 10 additions & 53 deletions src/main/java/tconstruct/util/config/PHConstruct.java
Expand Up @@ -15,48 +15,20 @@ public class PHConstruct

public static void initProps (File location)
{
/* Before we do anything, let's set up which modules can and cannot load. */
File modules = new File(location + "/TinkersModules.txt");

/* Some basic debugging will go a long way */
File currentConfig = new File(location + "/TConstruct.cfg");
File legacyConfig = new File(location + "/TinkersWorkshop.txt");
try
{
modules.createNewFile();
if(!currentConfig.exists() && legacyConfig.exists())
legacyConfig.renameTo(currentConfig);
}
catch (IOException e)
{
TConstruct.logger.warn("Could not create module configuration file for TConstruct. Reason:");
TConstruct.logger.warn(e.getLocalizedMessage());
}
/* [Forge] Configuration class, used as config method */
Configuration config = new Configuration(modules);
config.load();
worldModule = config.get("Modules: Disabling these will disable a chunk of the mod", "World", true, "Ores, slime islands, essence berries, and the like.").getBoolean(true);
toolModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Tools", true, "The main core of the mod! All of the tools, the tables, and the patterns are here.").getBoolean(true);
smelteryModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Smeltery", true, "Liquid metals, casting, and the multiblock structure.").getBoolean(true);
mechworksModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Smeltery", true, "Mechanical machinations and steampunk inspired shenanigans.").getBoolean(true);
armorModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Armor", true, "Modifyable armors, such as the traveller's gear.").getBoolean(true);
prayerModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Prayers", true, "Area of effect and time delayed status changes. Scrolltastic!").getBoolean(true);
cropifyModule = config.get("Modules: Disabling these will disable a chunk of the mod", "Cropify", true, "Tinkering with the world never felt this bushy.").getBoolean(true);
config.save();

/* Here we will set up the config file for the mod
* First: Create a folder inside the config folder
* Second: Create the actual config file
* Note: Configs are a pain, but absolutely necessary for every mod.
*/
File newFile = new File(location + "/TinkersWorkshop.txt");
try
{
newFile.createNewFile();
}
catch (IOException e)
catch (Exception e)
{
TConstruct.logger.warn("Could not create configuration file for TConstruct. Reason:");
TConstruct.logger.warn("Could not update legacy configuration file for TConstruct. Reason:");
TConstruct.logger.warn(e.getLocalizedMessage());
}

config = new Configuration(newFile);
Configuration config = new Configuration(currentConfig);
cfglocation = location;
/* Load the configuration file */
config.load();
Expand Down Expand Up @@ -206,12 +178,9 @@ public static void initProps (File location)
newSmeltery = config.get("Experimental", "Use new adaptive Smeltery code", false, "Warning: Very buggy").getBoolean(false);
meltableHorses = config.get("Experimental", "Allow horses to be melted down for glue", true).getBoolean(true);

// Addon stuff
isCleaverTwoHanded = config.get("Battlegear", "Can Cleavers have shields", true).getBoolean(true);
isHatchetWeapon = config.get("Battlegear", "Are Hatches also weapons", true).getBoolean(true);

/* Save the configuration file */
config.save();
/* Save the configuration file only if it has changed */
if(config.hasChanged())
config.save();

File gt = new File(location + "/GregTech");
if (gt.exists())
Expand All @@ -222,15 +191,6 @@ public static void initProps (File location)
gregtech = gtConfig.get("smelting", "tile.anvil.slightlyDamaged", false).getBoolean(false);
}
}

//Modules
public static boolean worldModule;
public static boolean toolModule;
public static boolean smelteryModule;
public static boolean mechworksModule;
public static boolean armorModule;
public static boolean prayerModule;
public static boolean cropifyModule;

public static boolean exoCraftingEnabled;
public static boolean capesEnabled;
Expand Down Expand Up @@ -373,7 +333,4 @@ public static void initProps (File location)
public static boolean newSmeltery;
public static boolean meltableHorses;

// Addon stuff
public static boolean isCleaverTwoHanded;
public static boolean isHatchetWeapon;
}
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/world/TinkerWorld.java
Expand Up @@ -89,7 +89,7 @@
import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder;

@ObjectHolder(TConstruct.modID)
@Pulse(id = TConstruct.modID)
@Pulse(id = "TinkerWorld", description = "Ores, slime islands, essence berries, and the like.")
public class TinkerWorld implements IPulse //TODO: Remove IPulse implementation, keep annotation
{
@Instance("TinkerWorld")
Expand Down

0 comments on commit 75ea872

Please sign in to comment.