Localize Configs #507

This commit is contained in:
mezz committed 2015-06-21 23:18:39 -07:00
1 parent 117fd7235c
commit 3e9e4afbfd
13 files changed
+633 -727

No files matched your search

@@ -36,7 +36,6 @@ import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.oredict.OreDictionary;
@@ -135,6 +134,7 @@ import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.config.LocalizedConfiguration;
import forestry.core.fluids.Fluids;
import forestry.core.gadgets.BlockBase;
import forestry.core.gadgets.MachineDefinition;
@@ -151,6 +151,7 @@ import forestry.core.proxy.Proxies;
import forestry.core.render.EntitySnowFX;
import forestry.core.utils.ShapedRecipeCustom;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
@Plugin(pluginID = "Apiculture", name = "Apiculture", author = "SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.apiculture.description")
public class PluginApiculture extends ForestryPlugin {
@@ -160,7 +161,7 @@ public class PluginApiculture extends ForestryPlugin {
private static final String CONFIG_CATEGORY = "apiculture";
public static final String[] EMPTY_STRINGS = new String[0];
public static String beekeepingMode = "NORMAL";
private static double secondPrincessChance = 0;
private static float secondPrincessChance = 0;
public static int ticksPerBeeWorkCycle = 550;
public static boolean apiarySideSensitive = false;
public static boolean fancyRenderedBees = false;
@@ -261,7 +262,7 @@ public class PluginApiculture extends ForestryPlugin {
ApicultureTriggers.initialize();
}
if (Config.enableVillager) {
if (Config.enableVillagers) {
// Register village components with the Structure registry.
VillageHandlerApiculture.registerVillageComponents();
}
@@ -291,35 +292,29 @@ public class PluginApiculture extends ForestryPlugin {
}
}
Configuration config = new Configuration(configFile);
Property property = config.get("apiary", "sidesensitive", apiarySideSensitive);
property.comment = "set to false if apiaries should output all items regardless of side a pipe is attached to";
apiarySideSensitive = property.getBoolean();
property = config.get("render.bees", "fancy", fancyRenderedBees);
property.comment = "set to true to enable a fancy butterfly-like renderer for bees. (experimental!)";
fancyRenderedBees = property.getBoolean();
LocalizedConfiguration config = new LocalizedConfiguration(configFile, "1.0.0");
List<IBeekeepingMode> beekeepingModes = BeeManager.beeRoot.getBeekeepingModes();
String[] validBeekeepingModeNames = new String[beekeepingModes.size()];
for (int i = 0; i < beekeepingModes.size(); i++) {
validBeekeepingModeNames[i] = beekeepingModes.get(i).getName();
}
property = config.get("beekeeping", "mode", "NORMAL", "Change the beekeeping mode. Accepted values are EASY, NORMAL, HARD, HARDCORE, and INSANE.", validBeekeepingModeNames);
beekeepingMode = property.getString();
beekeepingMode = config.getStringLocalized("beekeeping", "mode", "NORMAL", validBeekeepingModeNames);
Proxies.log.finer("Beekeeping mode read from config: " + beekeepingMode);
property = config.get("beekeeping", "secondPrincess", secondPrincessChance, "percent chance of a second princess drop, for limited/skyblock maps.", 0.0, 100.0);
secondPrincessChance = property.getDouble();
secondPrincessChance = config.getFloatLocalized("beekeeping", "second.princess", secondPrincessChance, 0.0f, 100.0f);
String acceptedFlowerMessage = StringUtil.localize("config.beekeeping.flowers.accepted.comment");
String plantableFlowerMessage = StringUtil.localize("config.beekeeping.flowers.plantable.comment");
for (String flowerType : FlowerManager.flowerRegistry.getFlowerTypes()) {
String[] defaultAccepted = defaultAcceptedFlowers.get(flowerType);
if (defaultAccepted == null) {
defaultAccepted = EMPTY_STRINGS;
}
property = config.get("beekeeping.flowers." + flowerType, "accepted", defaultAccepted);
property.comment = "Accepted flowers allow bees to work. Format is 'modid:name:meta', one per line. The format for wildcard metadata is 'modid:name'.";
Property property = config.get("beekeeping.flowers." + flowerType, "accepted", defaultAccepted);
property.comment = acceptedFlowerMessage;
parseAcceptedFlowers(property, flowerType);
String[] defaultPlantable = defaultPlantableFlowers.get(flowerType);
@@ -327,13 +322,12 @@ public class PluginApiculture extends ForestryPlugin {
defaultPlantable = EMPTY_STRINGS;
}
property = config.get("beekeeping.flowers." + flowerType, "plantable", defaultPlantable);
property.comment = "Plantable flowers are placed by bees. All plantable flowers are automatically accepted flowers. Format is 'weight:modid:name:meta', one per line. 'weight' is between 0.0 and 1.0. The format for wildcard metadata is 'weight:modid:name'.";
property.comment = plantableFlowerMessage;
parsePlantableFlowers(property, flowerType);
}
property = config.get("species.blacklist", CONFIG_CATEGORY, EMPTY_STRINGS);
property.comment = "add species to blacklist identified by their uid, one per line.";
parseBeeBlacklist(property.getStringList());
String[] blacklist = config.getStringListLocalized("species", "blacklist", EMPTY_STRINGS);
parseBeeBlacklist(blacklist);
config.save();
@@ -370,7 +364,7 @@ public class PluginApiculture extends ForestryPlugin {
BeeManager.villageBees[1].add(BeeDefinition.COMMON.getGenome());
BeeManager.villageBees[1].add(BeeDefinition.VALIANT.getGenome());
if (Config.enableVillager) {
if (Config.enableVillagers) {
// Register villager stuff
VillageHandlerApiculture villageHandler = new VillageHandlerApiculture();
VillagerRegistry.instance().registerVillageCreationHandler(villageHandler);
@@ -465,7 +459,7 @@ public class PluginApiculture extends ForestryPlugin {
beekeepingMode = property.value.trim();
Proxies.log.finer("Beekeeping mode read from config: " + beekeepingMode);
property = apicultureConfig.get("beekeeping.secondprincess", CONFIG_CATEGORY, (float) secondPrincessChance);
property = apicultureConfig.get("beekeeping.secondprincess", CONFIG_CATEGORY, secondPrincessChance);
property.comment = "percent chance of second princess drop, for limited/skyblock maps. Acceptable values up to 2 decimals.";
secondPrincessChance = Float.parseFloat(property.value);
@@ -340,7 +340,7 @@ public class PluginArboriculture extends ForestryPlugin {
MinecraftForge.EVENT_BUS.register(new EventHandlerArboriculture());
if (Config.enableVillager) {
if (Config.enableVillagers) {
VillagerRegistry.instance().registerVillagerId(Defaults.ID_VILLAGER_LUMBERJACK);
Proxies.render.registerVillagerSkin(Defaults.ID_VILLAGER_LUMBERJACK, Defaults.TEXTURE_SKIN_LUMBERJACK);
VillagerRegistry.instance().registerVillageTradeHandler(Defaults.ID_VILLAGER_LUMBERJACK, new VillageHandlerArboriculture());
@@ -19,8 +19,6 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.oredict.RecipeSorter;
import cpw.mods.fml.common.SidedProxy;
@@ -40,6 +38,7 @@ import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.config.LocalizedConfiguration;
import forestry.core.fluids.Fluids;
import forestry.core.gadgets.BlockBase;
import forestry.core.gadgets.MachineDefinition;
@@ -124,21 +123,7 @@ public class PluginLepidopterology extends ForestryPlugin {
}
}
Configuration config = new Configuration(configFile);
Property property = config.get("entities", "spawn.limit", spawnConstraint);
property.comment = "Butterflies will stop natural spawning once this limit is reached.";
spawnConstraint = property.getInt();
property = config.get("entities", "maximum", entityConstraint);
property.comment = "New butterflies will stay in item form and will not take flight once this limit is reached.";
entityConstraint = property.getInt();
property = config.get("entities", "pollination", allowPollination);
property.comment = "Allow butterflies to pollinate leaves.";
allowPollination = property.getBoolean();
config.save();
loadNewConfig(configFile);
PluginCore.rootCommand.addChildCommand(new CommandButterfly());
@@ -165,7 +150,17 @@ public class PluginLepidopterology extends ForestryPlugin {
RecipeSorter.register("forestry:lepidopterologymating", MatingRecipe.class, RecipeSorter.Category.SHAPELESS, "before:minecraft:shapeless");
}
private void loadOldConfig() {
private static void loadNewConfig(File configFile) {
LocalizedConfiguration config = new LocalizedConfiguration(configFile, "1.0.0");
spawnConstraint = config.getIntLocalized("butterfly.entities", "spawn.limit", spawnConstraint, 0, 500);
entityConstraint = config.getIntLocalized("butterfly.entities", "maximum", entityConstraint, 0, 5000);
allowPollination = config.getBooleanLocalized("butterfly.entities", "pollination", allowPollination);
config.save();
}
private static void loadOldConfig() {
forestry.core.config.deprecated.Configuration config = new forestry.core.config.deprecated.Configuration();
forestry.core.config.deprecated.Property property = config.get("entities.spawn.limit", CONFIG_CATEGORY, spawnConstraint);
@@ -131,9 +131,12 @@ public class PluginMail extends ForestryPlugin {
protected void registerItems() {
stampDefinitions = new StampInfo[]{
new StampInfo("1n", EnumPostage.P_1, ForestryItem.apatite, 0x4a8ca7, 0xffffff), new StampInfo("2n", EnumPostage.P_2, "ingotCopper", 0xe8c814, 0xffffff),
new StampInfo("5n", EnumPostage.P_5, "ingotTin", 0x9c0707, 0xffffff), new StampInfo("10n", EnumPostage.P_10, Items.gold_ingot, 0x7bd1b8, 0xffffff),
new StampInfo("20n", EnumPostage.P_20, Items.diamond, 0xff9031, 0xfff7dd), new StampInfo("50n", EnumPostage.P_50, Items.emerald, 0x6431d7, 0xfff7dd),
new StampInfo("1n", EnumPostage.P_1, ForestryItem.apatite, 0x4a8ca7, 0xffffff),
new StampInfo("2n", EnumPostage.P_2, "ingotCopper", 0xe8c814, 0xffffff),
new StampInfo("5n", EnumPostage.P_5, "ingotTin", 0x9c0707, 0xffffff),
new StampInfo("10n", EnumPostage.P_10, Items.gold_ingot, 0x7bd1b8, 0xffffff),
new StampInfo("20n", EnumPostage.P_20, Items.diamond, 0xff9031, 0xfff7dd),
new StampInfo("50n", EnumPostage.P_50, Items.emerald, 0x6431d7, 0xfff7dd),
new StampInfo("100n", EnumPostage.P_100, Items.nether_star, 0xd731ba, 0xfff7dd)}; //new StampInfo("200n", EnumPostage.P_200, Item.netherStar, 0xcd9831, 0xfff7dd)};
/* STAMPS */
@@ -43,7 +43,6 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.oredict.OreDictionary;
@@ -61,6 +60,7 @@ import forestry.api.storage.StorageManager;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.config.LocalizedConfiguration;
import forestry.core.fluids.Fluids;
import forestry.core.interfaces.IPickupHandler;
import forestry.core.interfaces.IResupplyHandler;
@@ -68,6 +68,7 @@ import forestry.core.items.ItemCrated;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
import forestry.factory.gadgets.MachineCarpenter;
import forestry.storage.BackpackDefinition;
import forestry.storage.BackpackHelper;
@@ -165,7 +166,7 @@ public class PluginStorage extends ForestryPlugin {
}
}
Configuration config = new Configuration(configFile);
LocalizedConfiguration config = new LocalizedConfiguration(configFile, "1.0.0");
handleBackpackConfig(config, "miner");
handleBackpackConfig(config, "digger");
@@ -413,7 +414,7 @@ public class PluginStorage extends ForestryPlugin {
}
}
private static void handleBackpackConfig(Configuration config, String backpackName) {
private static void handleBackpackConfig(LocalizedConfiguration config, String backpackName) {
BackpackDefinition backpackDefinition = (BackpackDefinition) BackpackManager.definitions.get(backpackName);
List<ItemStack> backpackItems;
@@ -424,8 +425,8 @@ public class PluginStorage extends ForestryPlugin {
Collections.sort(validItems);
String[] defaultValidItems = validItems.toArray(new String[validItems.size()]);
Property backpackConf = config.get("backpacks." + backpackName, "itemStacks", defaultValidItems);
backpackConf.comment = "Add itemStacks for the " + backpackName + "'s backpack here in the format 'modid:name:meta'. For wildcard metadata the format is 'modid:name'.";
Property backpackConf = config.get("backpacks." + backpackName, "item.stacks", defaultValidItems);
backpackConf.comment = StringUtil.localizeAndFormat("config.backpacks.item.stacks.format", backpackName);
String[] backpackItemList = backpackConf.getStringList();
backpackItems = StackUtils.parseItemStackStrings(backpackItemList, OreDictionary.WILDCARD_VALUE);
@@ -444,8 +445,8 @@ public class PluginStorage extends ForestryPlugin {
Collections.sort(defaultOreNamesList);
defaultOreNames = defaultOreNamesList.toArray(new String[defaultOreNamesList.size()]);
Property backpackConf = config.get("backpacks." + backpackName, "oreDict", defaultOreNames);
backpackConf.comment = "Add ore dictionary names for the " + backpackName + "'s backpack here in the format 'oreDictName'.";
Property backpackConf = config.get("backpacks." + backpackName, "ore.dict", defaultOreNames);
backpackConf.comment = StringUtil.localizeAndFormat("config.backpacks.ore.dict.format", backpackName);
String[] oreDictNameList = backpackConf.getStringList();
Collections.addAll(backpackOreDict, oreDictNameList);