diff options
Diffstat (limited to 'src/Java/miscutil')
52 files changed, 63 insertions, 4237 deletions
diff --git a/src/Java/miscutil/MiscUtils.java b/src/Java/miscutil/MiscUtils.java index d618217316..efb395d0f4 100644 --- a/src/Java/miscutil/MiscUtils.java +++ b/src/Java/miscutil/MiscUtils.java @@ -35,11 +35,32 @@ implements ActionListener public static CommonProxy proxy; + + public void handleConfigFile(FMLPreInitializationEvent event) { + Configuration config = new Configuration(event.getSuggestedConfigurationFile()); + boolean EIO = false; + + config.load(); + CORE.DEBUG = config.getBoolean("debugMode", "debug", false, "Enables all sorts of debug logging. (Don't use unless told to, breaks other things.)"); + CORE.disableEnderIOIntegration = config.getBoolean("disableEnderIO", "debug", false, "Disables EnderIO Integration."); + CORE.disableStaballoyBlastFurnaceRecipe = config.getBoolean("disableStaballoyBlastFurnaceRecipe", "debug", false, "Disables Staballoy Blast Furnace Recipe."); + config.save(); + } + + + + //Pre-Init @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { Utils.LOG_INFO("Loading "+CORE.name+" V"+CORE.VERSION); + /*Configuration Config = new Configuration(event.getSuggestedConfigurationFile()); + Config.load(); + CORE.Config = Config; + CORE.disableEnderIOIntegration = Config.get(Configuration.CATEGORY_GENERAL, "disableEnderIOIntegration", false).getBoolean(false); + CORE.disableStaballoyBlastFurnaceRecipe = Config.get(Configuration.CATEGORY_GENERAL, "disableStaballoyBlastFurnaceRecipe", false).getBoolean(false);*/ + handleConfigFile(event); proxy.registerTileEntities(); proxy.registerRenderThings(); HANDLER_GT.mMaterialProperties = new GT_Config(new Configuration(new File(new File(event.getModConfigurationDirectory(), "MiscUtils"), "MaterialProperties.cfg"))); @@ -61,7 +82,7 @@ implements ActionListener public void postInit(FMLPostInitializationEvent event) { proxy.postInit(event); } - + @EventHandler public void serverStarting(FMLServerStartingEvent event) { diff --git a/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMisc.java b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMisc.java index 1330f86aee..2327eaac7a 100644 --- a/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMisc.java +++ b/src/Java/miscutil/core/creative/tabs/MiscUtilCreativeTabMisc.java @@ -12,7 +12,7 @@ public class MiscUtilCreativeTabMisc extends CreativeTabs { @Override public Item getTabIconItem() { - return ModItems.itemPlateVibrantAlloy; + return ModItems.itemIngotStaballoy; } } diff --git a/src/Java/miscutil/core/lib/CORE.java b/src/Java/miscutil/core/lib/CORE.java index 270ebee91c..c2909c2709 100644 --- a/src/Java/miscutil/core/lib/CORE.java +++ b/src/Java/miscutil/core/lib/CORE.java @@ -5,11 +5,11 @@ import java.util.List; import java.util.Map; import miscutil.core.creative.AddToCreativeTab; -import miscutil.core.util.aeonbits.owner.ConfigFactory; import miscutil.core.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import miscutil.core.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; import miscutil.core.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraftforge.common.config.Configuration; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -18,7 +18,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; public static final String VERSION = "1.4.3.2"; - public static final boolean DEBUG = false; + public static boolean DEBUG = false; public static final boolean LOAD_ALL_CONTENT = false; public static final int GREG_FIRST_ID = 760; public static Map PlayerCache; @@ -26,44 +26,48 @@ public class CORE { public static final boolean MAIN_GREGTECH_5U_EXPERIMENTAL_FORK = Meta_GT_Proxy.areWeUsingGregtech5uExperimental(); public static IGregtech_RecipeAdder RA; @Deprecated - public static IGregtech_RecipeAdder sRecipeAdder; - + public static IGregtech_RecipeAdder sRecipeAdder; + @SideOnly(Side.CLIENT) - public static IIconRegister GT_BlockIcons, GT_ItemIcons; + public static IIconRegister GT_BlockIcons, GT_ItemIcons; public static List<Runnable> GT_BlockIconload = new ArrayList<Runnable>(); public static final Class<AddToCreativeTab> TAB = AddToCreativeTab.class; - public static ConfigHandler cfg = ConfigFactory.create(ConfigHandler.class); + public static Configuration Config; + + public static boolean disableEnderIOIntegration = false; + public static boolean disableStaballoyBlastFurnaceRecipe = false; + /** - * A List containing all the Materials, which are somehow in use by GT and therefor receive a specific Set of Items. - */ - public static final GT_Materials[] sMU_GeneratedMaterials = new GT_Materials[1000]; - + * A List containing all the Materials, which are somehow in use by GT and therefor receive a specific Set of Items. + */ + public static final GT_Materials[] sMU_GeneratedMaterials = new GT_Materials[1000]; + //GUIS public enum GUI_ENUM { - ENERGYBUFFER, TOOLBUILDER, NULL, NULL1, NULL2 + ENERGYBUFFER, TOOLBUILDER, NULL, NULL1, NULL2 } - + /** - * File Paths and Resource Paths - */ - public static final String - TEX_DIR = "textures/", - TEX_DIR_GUI = TEX_DIR + "gui/", - TEX_DIR_ITEM = TEX_DIR + "items/", - TEX_DIR_BLOCK = TEX_DIR + "blocks/", - TEX_DIR_ENTITY = TEX_DIR + "entity/", - TEX_DIR_ASPECTS = TEX_DIR + "aspects/", - TEX_DIR_FLUIDS = TEX_DIR_BLOCK + "fluids/", - RES_PATH = MODID + ":" + TEX_DIR, - RES_PATH_GUI = MODID + ":" + TEX_DIR_GUI, - RES_PATH_ITEM = MODID + ":" + TEX_DIR_ITEM, - RES_PATH_BLOCK = MODID + ":" + TEX_DIR_BLOCK, - RES_PATH_ENTITY = MODID + ":" + TEX_DIR_ENTITY, - RES_PATH_ASPECTS = MODID + ":" + TEX_DIR_ASPECTS, - RES_PATH_FLUIDS = MODID + ":" + TEX_DIR_FLUIDS; - - + * File Paths and Resource Paths + */ + public static final String + TEX_DIR = "textures/", + TEX_DIR_GUI = TEX_DIR + "gui/", + TEX_DIR_ITEM = TEX_DIR + "items/", + TEX_DIR_BLOCK = TEX_DIR + "blocks/", + TEX_DIR_ENTITY = TEX_DIR + "entity/", + TEX_DIR_ASPECTS = TEX_DIR + "aspects/", + TEX_DIR_FLUIDS = TEX_DIR_BLOCK + "fluids/", + RES_PATH = MODID + ":" + TEX_DIR, + RES_PATH_GUI = MODID + ":" + TEX_DIR_GUI, + RES_PATH_ITEM = MODID + ":" + TEX_DIR_ITEM, + RES_PATH_BLOCK = MODID + ":" + TEX_DIR_BLOCK, + RES_PATH_ENTITY = MODID + ":" + TEX_DIR_ENTITY, + RES_PATH_ASPECTS = MODID + ":" + TEX_DIR_ASPECTS, + RES_PATH_FLUIDS = MODID + ":" + TEX_DIR_FLUIDS; + + //public static final Materials2[] MiscGeneratedMaterials = new Materials2[1000]; - + } diff --git a/src/Java/miscutil/core/lib/ConfigHandler.java b/src/Java/miscutil/core/lib/ConfigHandler.java deleted file mode 100644 index d8ec0d6ff9..0000000000 --- a/src/Java/miscutil/core/lib/ConfigHandler.java +++ /dev/null @@ -1,14 +0,0 @@ -package miscutil.core.lib; - -import miscutil.core.util.aeonbits.owner.Config; - -public interface ConfigHandler extends Config{ - - @DefaultValue("false") - boolean debugMode(); - - @DefaultValue("true") - boolean disableEnderIOIntegration(); - - -} diff --git a/src/Java/miscutil/core/lib/LoadedMods.java b/src/Java/miscutil/core/lib/LoadedMods.java index 2412482f6b..86cc8e94a9 100644 --- a/src/Java/miscutil/core/lib/LoadedMods.java +++ b/src/Java/miscutil/core/lib/LoadedMods.java @@ -53,7 +53,7 @@ public class LoadedMods { totalMods++; } - if (Loader.isModLoaded("EnderIO") == true && !CORE.cfg.disableEnderIOIntegration()){ + if (Loader.isModLoaded("EnderIO") == true && !CORE.disableEnderIOIntegration){ EnderIO = true; Utils.LOG_INFO("Components enabled for: EnderIO"); totalMods++; diff --git a/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java b/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java index 89e6f9a86b..2529dc60b1 100644 --- a/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/miscutil/core/recipe/RECIPES_GREGTECH.java @@ -152,6 +152,7 @@ public class RECIPES_GREGTECH { private static void blastFurnaceRecipes(){ Utils.LOG_INFO("Registering Blast Furnace Recipes."); + if (!CORE.disableStaballoyBlastFurnaceRecipe){ GT_Values.RA.addBlastRecipe( UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 11028, 1), UtilsItems.simpleMetaStack("gregtech:gt.metaitem.01", 11098, 1), @@ -185,4 +186,5 @@ public class RECIPES_GREGTECH { (int) Math.max(GT_Materials.Staballoy.getMass() / 80L, 1L) * GT_Materials.Staballoy.mBlastFurnaceTemp, 2000, GT_Materials.Staballoy.mBlastFurnaceTemp); } + } }
\ No newline at end of file diff --git a/src/Java/miscutil/core/util/aeonbits/owner/Accessible.java b/src/Java/miscutil/core/util/aeonbits/owner/Accessible.java deleted file mode 100644 index cbd770f4a8..0000000000 --- a/src/Java/miscutil/core/util/aeonbits/owner/Accessible.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2012-2015, Luigi R. Viggiano - * All rights reserved. - * - * This software is distributable under the BSD license. - * See the terms of the BSD license in the documentation provided with this software. - */ - -package miscutil.core.util.aeonbits.owner; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.util.Map; -import java.util.Set; - -/** - * <p>Allows a <tt>Config</tt> object to access the contents of the properties, providing utility methods to perform - * consequent operations.</p> - * <p>Example:</p> - * <pre> - * public interface MyConfig extends Config, Accessible { - * int someProperty(); - * } - * - * public void doSomething() { - * MyConfig cfg = ConfigFactory.create(MyConfig.class); - * cfg.list(System.out); - * } - * </pre> - * <p>These methods will print the list of properties, see {@link java.util.Properties#list(java.io.PrintStream)} and - * {@link java.util.Properties#list(java.io.PrintWriter)}.</p> - * - * @author Luigi R. Viggiano - * @since 1.0.4 - */ -public interface Accessible extends Config { - - /** - * Prints this property list out to the specified output stream. This method is useful for debugging. - * - * @param out an output stream. - * @throws ClassCastException if any key in this property list is not a string. - * @see java.util.Properties#list(java.io.PrintStream) - * @since 1.0.4 - */ - void list(PrintStream out); - - /** - * Prints this property list out to the specified output stream. This method is useful for debugging. - * - * @param out an output stream. - * @throws ClassCastException if any key in this property list is not a string. - * @see java.util.Properties#list(java.io.PrintWriter) - * @since 1.0.4 - */ - void list(PrintWriter out); - - /** - * Stores the underlying properties into an {@link java.io.OutputStream}. - * <p> - * Notice that method {@link java.util.Properties#store(java.io.Writer, String)} is not implemented since it's not - * available in JDK 1.5 (while the target of this library is Java 1.5+). - * - * @param out an output stream. - * @param comments a description of the property list. - * @throws IOException if writing this property list to the specified output stream throws an <tt>IOException</tt>. - * @see java.util.Properties#store(java.io.OutputStream, String) - * @since 1.0.4 - */ - void store(OutputStream out, String comments) throws IOException; - - /** - * Fills the given {@link java.util.Map} with the properties contained by this object. <br> - * This is useful to extract the content of the config object into a {@link java.util.Map}. - * <p> - * Notice that you can specify a properties object as parameter instead of a map, - * since {@link java.util.Properties} implements the {@link java.util.Map} interface. - * - * @param map the {@link java.util.Map} to fill. - * @since 1.0.9 - */ - void fill(Map map); - - /** - * Searches for the property with the specified key in this property list. - * If the key is not found in this property list, the default property list, - * and its defaults, recursively, are then checked. The method returns - * <code>null</code> if the property is not found. - * - * @param key the property key. - * @return the value in this property list with the specified key value. - * @see java.util.Properties#getProperty(String) - * @since 1.0.4 - */ - String getProperty(String key); - - /** - * Searches for the property with the specified key in this property list. - * If the key is not found in this property list, the default property list, - * and its defaults, recursively, are then checked. The method returns the - * default value argument if the property is not found. - * - * @param key the property key. - * @param defaultValue a default value. - * @return the value in this property list with the specified key value. - * @see java.util.Properties#getProperty(String, String) - * - * @since 1.0.4 - */ - String getProperty(String key, String defaultValue); - - /** - * Emits an XML document representing all of the properties contained - * in this table. - * - * <p> An invocation of this method of the form <tt>props.storeToXML(os, - * comment)</tt> behaves in exactly the same way as the invocation - * <tt>props.storeToXML(os, comment, "UTF-8");</tt>. - * - * @param os the output stream on which to emit the XML document. - * @param comment a description of the property list, or <code>null</code> - * if no comment is desired. - * @throws IOException if writing to the specified output stream - * results in an <tt>IOException</tt>. - * @throws NullPointerException if <code>os</code> is null. - * @throws ClassCastException if this <code>Properties</code> object - * contains any keys or values that are not - * <code>Strings</code>. - * @since 1.0.5 - */ - void storeToXML(OutputStream os, String comment) throws IOException; - - /** - * Returns a set of keys in this property list - * including distinct keys in the default property list if a key - * of the same name has not already been found from the main - * properties list. - * <p> - * The returned set is not backed by the <tt>Properties</tt> object. - * Changes to this <tt>Properties</tt> are not reflected in the set, - * or vice versa. - * - * @return a set of keys in this property list, including the keys in the - * default property list. - * @throws ClassCastException if any key in this property list - * is not a string. - * @see java.util.Properties#defaults - * @see java.util.Properties#stringPropertyNames() - * @see java.util.Properties#propertyNames() - * @since 1.0.5 - */ - Set<String> propertyNames(); - -} diff --git a/src/Java/miscutil/core/util/aeonbits/owner/Config.java b/src/Java/miscutil/core/util/aeonbits/owner/Config.java deleted file mode 100644 index ab7fa23cc1..0000000000 --- a/src/Java/miscutil/core/util/aeonbits/owner/Config.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2012-2015, Luigi R. Viggiano - * All rights reserved. - * - * This software is distributable under the BSD license. - * See the terms of the BSD license in the documentation provided with this software. - */ - -package miscutil.core.util.aeonbits.owner; - - -import java.io.IOException; -import java.io.Serializable; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import java.net.URI; -import java.util.List; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import static java.util.concurrent.TimeUnit.SECONDS; -import static miscutil.core.util.aeonbits.owner.Config.HotReloadType.SYNC; -import static miscutil.core.util.aeonbits.owner.Config.LoadType.FIRST; -import static miscutil.core.util.aeonbits.owner.Util.ignore; -import static miscutil.core.util.aeonbits.owner.Util.reverse; - -/** - * Marker interface that must be implemented by all Config sub-interfaces. - * <p> - * Sub-interfaces may also extend {@link Accessible} to allow some debugging facility, or {@link Reloadable} to allow the - * user to programmatically reload properties. - * </p> - * - * @author Luigi R. Viggiano - * @see java.util.Properties - */ -public interface Config extends Serializable { - - /** - * Specifies the policy for loading the properties files. By default the first available properties file specified - * by {@link Sources} will be loaded, see {@link LoadType#FIRST}. User can also specify that the load policy is - * {@link LoadType#MERGE} to have the properties files merged: properties are loaded in order from the first file to - * the last, if there are conflicts in properties names the earlier files loaded prevail. - * - * @since 1.0.2 - */ - @Retention(RUNTIME) - @Target(TYPE) - @Documented - @interface LoadPolicy { - LoadType value() default FIRST; - } - - /** - * Specifies the source from which to load the properties file. It has to be specified in a URI string format. - * By default, allowed protocols are the ones allowed by {@link java.net.URL} plus - * <tt>classpath:path/to/resource.properties</tt>, but user can specify his own additional protocols. - * - * @since 1.0.2 - */ - @Retention(RUNTIME) - @Target(TYPE) - @Documented - @interface Sources { - String[] value(); - } - - /** - * Default value to be used if no property is found. No quoting (other than normal Java string quoting) is done. - */ - @Retention(RUNTIME) - @Target(METHOD) - @Documented - @interface DefaultValue { - String value(); - } - - /** - * The key used for lookup for the property. If not present, the key will be generated based on the unqualified - * method name. - */ - @Retention(RUNTIME) - @Target(METHOD) - @Documented - @interface Key { - String value(); - } - - /** - * Specifies the policy type to use to load the {@link miscutil.core.util.aeonbits.owner.Config.Sources} files for properties. - * - * @since 1.0.2 - */ - enum LoadType { - - /** - * The first available of the specified sources will be loaded. - */ - FIRST { - @Override - Properties load(List<URI> uris, LoadersManager loaders) { - Properties result = new Properties(); - for (URI uri : uris) - try { - loaders.load(result, uri); - break; - } catch (IOException ex) { - // happens when a file specified in the sources is not found or cannot be read. - ignore(); - } - return result; - } - }, - - /** - * All the specified sources will be loaded and merged. If the same property key is - * specified from more than one source, the one specified first will prevail. - */ - MERGE { - @Override - Properties load(List<URI> uris, LoadersManager loaders) { - Properties result = new Properties(); - for (URI uri : reverse(uris)) - try { - loaders.load(result, uri); - } catch (IOException ex) { - // happens when a file specified in the sources is not found or cannot be read. - ignore(); - } - return result; - } - }; - - abstract Properties load(List<URI> uris, LoadersManager loaders); - } - - /** - * Specify that the class implements hot reloading of properties from filesystem baked {@link Sources} (hot - * reloading can't be applied to all types of URIs). - * <p> - * It is possible to specify an interval to indicate how frequently the library shall check the files for - * modifications and perform the reload. - * </p> - * Examples: - * <pre> - * @HotReload // will check for file changes every 5 seconds. - * @Sources("file:foo/bar/baz.properties") - * interface MyConfig extends Config { ... } - |
