resonant-induction/archive/java/resonantinduction/core/Settings.java
2014-01-11 17:44:07 +08:00

94 lines
3.8 KiB
Java

package resonantinduction.core;
import java.io.File;
import java.util.Arrays;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.Configuration;
import calclavia.lib.prefab.block.IDManager;
import calclavia.lib.utility.LanguageUtility;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModMetadata;
/** @author Calclavia */
public class Settings
{
/** IDs suggested by Jyzarc and Horfius */
public static final IDManager idManager = new IDManager(3200, 20150);
public static int getNextBlockID()
{
return idManager.getNextBlockID();
}
public static int getNextItemID()
{
return idManager.getNextItemID();
}
/** Settings */
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), Reference.NAME + ".cfg"));
public static int FURNACE_WATTAGE = 50000;
public static boolean SOUND_FXS = true;
public static boolean LO_FI_INSULATION = false;
public static boolean SHINY_SILVER = true;
public static boolean REPLACE_FURNACE = true;
public static int MAX_CONTRACTOR_DISTANCE = 200;
/**
* Called from RI's core.
*/
public static void load()
{
CONFIGURATION.load();
// Config
FURNACE_WATTAGE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Furnace Wattage Per Tick", FURNACE_WATTAGE).getInt(FURNACE_WATTAGE);
SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS);
LO_FI_INSULATION = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Use lo-fi insulation texture", LO_FI_INSULATION).getBoolean(LO_FI_INSULATION);
SHINY_SILVER = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Shiny silver wires", SHINY_SILVER).getBoolean(SHINY_SILVER);
MAX_CONTRACTOR_DISTANCE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_CONTRACTOR_DISTANCE).getInt(MAX_CONTRACTOR_DISTANCE);
REPLACE_FURNACE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Replace vanilla furnace", REPLACE_FURNACE).getBoolean(REPLACE_FURNACE);
LEVITATOR_ACCELERATION = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Acceleration", Settings.LEVITATOR_ACCELERATION).getDouble(Settings.LEVITATOR_ACCELERATION);
LEVITATOR_MAX_REACH = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Reach", Settings.LEVITATOR_MAX_REACH).getInt(Settings.LEVITATOR_MAX_REACH);
LEVITATOR_MAX_SPEED = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Speed", Settings.LEVITATOR_MAX_SPEED).getDouble(Settings.LEVITATOR_MAX_SPEED);
LEVITATOR_PUSH_DELAY = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Push Delay", Settings.LEVITATOR_PUSH_DELAY).getInt(Settings.LEVITATOR_PUSH_DELAY);
}
public static void save()
{
CONFIGURATION.save();
}
public static void setModMetadata(ModMetadata metadata, String id, String name)
{
metadata.modId = id;
metadata.name = name;
metadata.description = LanguageUtility.getLocal("meta.resonantinduction.description");
metadata.url = "http://calclavia.com/resonant-induction";
metadata.logoFile = "ri_logo.png";
metadata.version = Reference.VERSION + "." + Reference.BUILD_VERSION;
metadata.authorList = Arrays.asList(new String[] { "Calclavia", "DarkCow" });
metadata.credits = LanguageUtility.getLocal("meta.resonantinduction.credits");
metadata.autogenerated = false;
}
public static boolean isOp(String username)
{
MinecraftServer theServer = FMLCommonHandler.instance().getMinecraftServerInstance();
if (theServer != null)
{
return theServer.getConfigurationManager().getOps().contains(username.trim().toLowerCase());
}
return false;
}
public static int LEVITATOR_MAX_REACH = 40;
public static int LEVITATOR_PUSH_DELAY = 5;
public static double LEVITATOR_MAX_SPEED = .2;
public static double LEVITATOR_ACCELERATION = .02;
}