From 33b010a8fa2cb21d0bc41ea4648cbf67b79e5a35 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 20 Jun 2015 23:57:33 -0700 Subject: [PATCH] Fix #536 Add additional Flower Configs for each type Migrate Apiculture config #507 --- api/forestry | 2 +- .../apiculture/flowers/FlowerRegistry.java | 56 ++--- .../forestry/plugins/PluginApiculture.java | 233 ++++++++++++++++-- .../java/forestry/plugins/PluginStorage.java | 15 +- 4 files changed, 239 insertions(+), 67 deletions(-) diff --git a/api/forestry b/api/forestry index a8e10de64..a9092a139 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit a8e10de64200d2b66bf61f3c3ec30adb0e5a142b +Subproject commit a9092a139daf9fe175e4856ec9284aab920849c6 diff --git a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java index 34b69e2cf..635787e33 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java @@ -11,12 +11,16 @@ package forestry.apiculture.flowers; import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.Set; import java.util.TreeMap; import net.minecraft.block.Block; @@ -37,6 +41,17 @@ import forestry.api.genetics.IIndividual; public final class FlowerRegistry implements IFlowerRegistry { + private final Set defaultFlowerTypes = ImmutableSet.of( + FlowerManager.FlowerTypeVanilla, + FlowerManager.FlowerTypeNether, + FlowerManager.FlowerTypeCacti, + FlowerManager.FlowerTypeMushrooms, + FlowerManager.FlowerTypeEnd, + FlowerManager.FlowerTypeJungle, + FlowerManager.FlowerTypeSnow, + FlowerManager.FlowerTypeWheat, + FlowerManager.FlowerTypeGourd + ); private final ArrayListMultimap registeredFlowers; private final ArrayListMultimap growthRules; private final Map> chances; @@ -50,7 +65,6 @@ public final class FlowerRegistry implements IFlowerRegistry { this.hasDeprecatedFlowersImported = false; - registerVanillaFlowers(); registerVanillaGrowthRules(); } @@ -82,7 +96,7 @@ public final class FlowerRegistry implements IFlowerRegistry { Flower newFlower = new Flower(block, meta, weight); Integer index; - + for (String flowerType : flowerTypes) { List flowers = this.registeredFlowers.get(flowerType); @@ -174,6 +188,11 @@ public final class FlowerRegistry implements IFlowerRegistry { return chancesMap.get(chancesMap.lowerKey(rand.nextDouble() * maxKey)); } + @Override + public Collection getFlowerTypes() { + return Sets.union(defaultFlowerTypes, registeredFlowers.keySet()); + } + private TreeMap getChancesMap(String flowerType) { if (!this.chances.containsKey(flowerType)) { TreeMap flowerChances = new TreeMap(); @@ -205,39 +224,6 @@ public final class FlowerRegistry implements IFlowerRegistry { } } - private void registerVanillaFlowers() { - // Register acceptable plants - registerAcceptableFlower(Blocks.red_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(Blocks.yellow_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(Blocks.brown_mushroom, FlowerManager.FlowerTypeMushrooms); - registerAcceptableFlower(Blocks.red_mushroom, FlowerManager.FlowerTypeMushrooms); - registerAcceptableFlower(Blocks.cactus, FlowerManager.FlowerTypeCacti); - - registerAcceptableFlower(Blocks.dragon_egg, FlowerManager.FlowerTypeEnd); - registerAcceptableFlower(Blocks.vine, FlowerManager.FlowerTypeJungle); - registerAcceptableFlower(Blocks.tallgrass, FlowerManager.FlowerTypeJungle); - registerAcceptableFlower(Blocks.wheat, FlowerManager.FlowerTypeWheat); - registerAcceptableFlower(Blocks.pumpkin_stem, FlowerManager.FlowerTypeGourd); - registerAcceptableFlower(Blocks.melon_stem, FlowerManager.FlowerTypeGourd); - registerAcceptableFlower(Blocks.nether_wart, FlowerManager.FlowerTypeNether); - - registerAcceptableFlower(Blocks.double_plant, 0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(Blocks.double_plant, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(Blocks.double_plant, 4, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerAcceptableFlower(Blocks.double_plant, 5, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - - // Register plantable plants - for (int meta = 0; meta <= 8; meta++) { - registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - } - - registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); - registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms); - registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms); - registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti); - - } - private void registerVanillaGrowthRules() { registerGrowthRule(new VanillaDirtGrassGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); registerGrowthRule(new VanillaSnowGrowthRule(), FlowerManager.FlowerTypeSnow); diff --git a/src/main/java/forestry/plugins/PluginApiculture.java b/src/main/java/forestry/plugins/PluginApiculture.java index e25462569..94734c6cb 100644 --- a/src/main/java/forestry/plugins/PluginApiculture.java +++ b/src/main/java/forestry/plugins/PluginApiculture.java @@ -12,8 +12,12 @@ package forestry.plugins; import com.google.common.collect.ImmutableMap; +import java.io.File; +import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Random; import net.minecraft.block.Block; @@ -32,6 +36,8 @@ 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; import cpw.mods.fml.common.FMLCommonHandler; @@ -45,15 +51,19 @@ import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import forestry.Forestry; import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeType; import forestry.api.apiculture.FlowerManager; import forestry.api.apiculture.IBeeGenome; +import forestry.api.apiculture.IBeekeepingMode; import forestry.api.apiculture.hives.HiveManager; import forestry.api.core.Tabs; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IClassification; import forestry.api.genetics.IClassification.EnumClassLevel; +import forestry.api.genetics.IFlower; +import forestry.api.genetics.IFlowerRegistry; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.ICrateRegistry; import forestry.api.storage.StorageManager; @@ -122,11 +132,9 @@ import forestry.apiculture.worldgen.HiveGenHelper; import forestry.apiculture.worldgen.HiveRegistry; import forestry.core.GameMode; import forestry.core.config.Config; -import forestry.core.config.Configuration; import forestry.core.config.Defaults; import forestry.core.config.ForestryBlock; import forestry.core.config.ForestryItem; -import forestry.core.config.Property; import forestry.core.fluids.Fluids; import forestry.core.gadgets.BlockBase; import forestry.core.gadgets.MachineDefinition; @@ -150,9 +158,9 @@ public class PluginApiculture extends ForestryPlugin { @SidedProxy(clientSide = "forestry.apiculture.proxy.ClientProxyApiculture", serverSide = "forestry.apiculture.proxy.ProxyApiculture") public static ProxyApiculture proxy; private static final String CONFIG_CATEGORY = "apiculture"; - private Configuration apicultureConfig; + public static final String[] EMPTY_STRINGS = new String[0]; public static String beekeepingMode = "NORMAL"; - private static float secondPrincessChance = 0; + private static double secondPrincessChance = 0; public static int ticksPerBeeWorkCycle = 550; public static boolean apiarySideSensitive = false; public static boolean fancyRenderedBees = false; @@ -164,6 +172,9 @@ public class PluginApiculture extends ForestryPlugin { public static MachineDefinition definitionBeehouse; public static MachineDefinition definitionAnalyzer; + private final Map defaultAcceptedFlowers = new HashMap(); + private final Map defaultPlantableFlowers = new HashMap(); + @Override @SuppressWarnings({"unchecked", "rawtypes"}) protected void setupAPI() { @@ -261,37 +272,70 @@ public class PluginApiculture extends ForestryPlugin { @Override public void doInit() { - super.doInit(); + final String oldConfig = CONFIG_CATEGORY + ".conf"; + final String newConfig = CONFIG_CATEGORY + ".cfg"; - // Config - apicultureConfig = new Configuration(); + File configFile = new File(Forestry.instance.getConfigFolder(), newConfig); + if (!configFile.exists()) { + setDefaultsForConfig(); + } - Property property = apicultureConfig.get("apiary.sidesensitive", CONFIG_CATEGORY, apiarySideSensitive); + File oldConfigFile = new File(Forestry.instance.getConfigFolder(), oldConfig); + if (oldConfigFile.exists()) { + loadOldConfig(); + + final String oldConfigRenamed = CONFIG_CATEGORY + ".conf.old"; + File oldConfigFileRenamed = new File(Forestry.instance.getConfigFolder(), oldConfigRenamed); + if (oldConfigFile.renameTo(oldConfigFileRenamed)) { + Proxies.log.info("Migrated " + CONFIG_CATEGORY + " settings to the new file '" + newConfig + "' and renamed '" + oldConfig + "' to '" + oldConfigRenamed + "'."); + } + } + + 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 = Boolean.parseBoolean(property.value); + apiarySideSensitive = property.getBoolean(); - property = apicultureConfig.get("render.bees.fancy", CONFIG_CATEGORY, fancyRenderedBees); + property = config.get("render.bees", "fancy", fancyRenderedBees); property.comment = "set to true to enable a fancy butterfly-like renderer for bees. (experimental!)"; - fancyRenderedBees = Boolean.parseBoolean(property.value); + fancyRenderedBees = property.getBoolean(); - property = apicultureConfig.get("beekeeping.mode", CONFIG_CATEGORY, "NORMAL"); - property.comment = "change beekeeping modes here. possible values EASY, NORMAL, HARD, HARDCORE, INSANE. mods may add additional modes."; - beekeepingMode = property.value.trim(); + List 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(); Proxies.log.finer("Beekeeping mode read from config: " + beekeepingMode); - Property secondPrincess = apicultureConfig.get("beekeeping.secondprincess", CONFIG_CATEGORY, secondPrincessChance); - secondPrincess.comment = "percent chance of second princess drop, for limited/skyblock maps. Acceptable values up to 2 decimals."; - secondPrincessChance = Float.parseFloat(secondPrincess.value); + property = config.get("beekeeping", "secondPrincess", secondPrincessChance, "percent chance of a second princess drop, for limited/skyblock maps.", 0.0, 100.0); + secondPrincessChance = property.getDouble(); - property = apicultureConfig.get("beekeeping.flowers.custom", CONFIG_CATEGORY, ""); - property.comment = "add additional flower blocks for apiaries here in the format modid:name or modid:name:meta. separate blocks using ';'. wildcard for metadata: '*'. will be treated like vanilla flowers. not recommended for flowers implemented as tile entities."; - parseAdditionalFlowers(property.value, FlowerManager.plainFlowers); + 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'."; + parseAcceptedFlowers(property, flowerType); - property = apicultureConfig.get("species.blacklist", CONFIG_CATEGORY, ""); - property.comment = "add species to blacklist identified by their uid and seperated with ';'."; - parseBeeBlacklist(property.value); + String[] defaultPlantable = defaultPlantableFlowers.get(flowerType); + if (defaultPlantable == null) { + 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'."; + parsePlantableFlowers(property, flowerType); + } - apicultureConfig.save(); + 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()); + + config.save(); // Genetics createAlleles(); @@ -344,6 +388,98 @@ public class PluginApiculture extends ForestryPlugin { registerDungeonLoot(); } + private void setDefaultsForConfig() { + + IFlowerRegistry flowerRegistry = FlowerManager.flowerRegistry; + + // Register acceptable plants + flowerRegistry.registerAcceptableFlower(Blocks.dragon_egg, FlowerManager.FlowerTypeEnd); + flowerRegistry.registerAcceptableFlower(Blocks.vine, FlowerManager.FlowerTypeJungle); + flowerRegistry.registerAcceptableFlower(Blocks.tallgrass, FlowerManager.FlowerTypeJungle); + flowerRegistry.registerAcceptableFlower(Blocks.wheat, FlowerManager.FlowerTypeWheat); + flowerRegistry.registerAcceptableFlower(Blocks.pumpkin_stem, FlowerManager.FlowerTypeGourd); + flowerRegistry.registerAcceptableFlower(Blocks.melon_stem, FlowerManager.FlowerTypeGourd); + flowerRegistry.registerAcceptableFlower(Blocks.nether_wart, FlowerManager.FlowerTypeNether); + + flowerRegistry.registerAcceptableFlower(Blocks.double_plant, 0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + flowerRegistry.registerAcceptableFlower(Blocks.double_plant, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + flowerRegistry.registerAcceptableFlower(Blocks.double_plant, 4, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + flowerRegistry.registerAcceptableFlower(Blocks.double_plant, 5, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + + // Register plantable plants + for (int meta = 0; meta <= 8; meta++) { + flowerRegistry.registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + } + + flowerRegistry.registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow); + flowerRegistry.registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms); + flowerRegistry.registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms); + flowerRegistry.registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti); + + DecimalFormat weightDecimalFormat = new DecimalFormat("#.000"); + + for (String flowerType : FlowerManager.flowerRegistry.getFlowerTypes()) { + List flowers = FlowerManager.flowerRegistry.getAcceptableFlowers(flowerType); + List acceptedFlowerNames = new ArrayList(); + List plantableFlowerNames = new ArrayList(); + if (flowers != null) { + for (IFlower flower : flowers) { + String name = flower.getBlock().delegate.name(); + int meta = flower.getMeta(); + if (flower.getMeta() != OreDictionary.WILDCARD_VALUE) { + name = name + ':' + meta; + } + + if (flower.isPlantable()) { + double weight = flower.getWeight(); + String weightString = weightDecimalFormat.format(weight); + plantableFlowerNames.add(weightString + ':' + name); + } else { + acceptedFlowerNames.add(name); + } + } + } + + String[] acceptedFlowerNamesArray = acceptedFlowerNames.toArray(new String[acceptedFlowerNames.size()]); + defaultAcceptedFlowers.put(flowerType, acceptedFlowerNamesArray); + + String[] plantableFlowerNamesArray = plantableFlowerNames.toArray(new String[plantableFlowerNames.size()]); + defaultPlantableFlowers.put(flowerType, plantableFlowerNamesArray); + } + } + + private void loadOldConfig() { + // Config + forestry.core.config.Configuration apicultureConfig = new forestry.core.config.Configuration(); + + forestry.core.config.Property property = apicultureConfig.get("apiary.sidesensitive", CONFIG_CATEGORY, apiarySideSensitive); + property.comment = "set to false if apiaries should output all items regardless of side a pipe is attached to"; + apiarySideSensitive = Boolean.parseBoolean(property.value); + + property = apicultureConfig.get("render.bees.fancy", CONFIG_CATEGORY, fancyRenderedBees); + property.comment = "set to true to enable a fancy butterfly-like renderer for bees. (experimental!)"; + fancyRenderedBees = Boolean.parseBoolean(property.value); + + property = apicultureConfig.get("beekeeping.mode", CONFIG_CATEGORY, "NORMAL"); + property.comment = "change beekeeping modes here. possible values EASY, NORMAL, HARD, HARDCORE, INSANE. mods may add additional modes."; + beekeepingMode = property.value.trim(); + Proxies.log.finer("Beekeeping mode read from config: " + beekeepingMode); + + property = apicultureConfig.get("beekeeping.secondprincess", CONFIG_CATEGORY, (float) secondPrincessChance); + property.comment = "percent chance of second princess drop, for limited/skyblock maps. Acceptable values up to 2 decimals."; + secondPrincessChance = Float.parseFloat(property.value); + + property = apicultureConfig.get("beekeeping.flowers.custom", CONFIG_CATEGORY, ""); + property.comment = "add additional flower blocks for apiaries here in the format modid:name or modid:name:meta. separate blocks using ';'. wildcard for metadata: '*'. will be treated like vanilla flowers. not recommended for flowers implemented as tile entities."; + parseAdditionalFlowers(property.value, FlowerManager.plainFlowers); + + property = apicultureConfig.get("species.blacklist", CONFIG_CATEGORY, ""); + property.comment = "add species to blacklist identified by their uid and seperated with ';'."; + parseBeeBlacklist(property.value); + + apicultureConfig.save(); + } + @Override public IGuiHandler getGuiHandler() { return new GuiHandlerApiculture(); @@ -854,7 +990,7 @@ public class PluginApiculture extends ForestryPlugin { Allele.effectMycophilic = new AlleleEffectFungification(); } - public static float getSecondPrincessChance() { + public static double getSecondPrincessChance() { return secondPrincessChance; } @@ -865,7 +1001,10 @@ public class PluginApiculture extends ForestryPlugin { private static void parseBeeBlacklist(String list) { String[] items = list.split("[;]+"); + parseBeeBlacklist(items); + } + private static void parseBeeBlacklist(String[] items) { for (String item : items) { if (item.isEmpty()) { continue; @@ -876,6 +1015,50 @@ public class PluginApiculture extends ForestryPlugin { } } + private static void parseAcceptedFlowers(Property property, String flowerType) { + List acceptedFlowerItemStacks = StackUtils.parseItemStackStrings(property.getStringList(), OreDictionary.WILDCARD_VALUE); + for (ItemStack acceptedFlower : acceptedFlowerItemStacks) { + Block acceptedFlowerBlock = Block.getBlockFromItem(acceptedFlower.getItem()); + int meta = acceptedFlower.getItemDamage(); + if (acceptedFlowerBlock != null) { + FlowerManager.flowerRegistry.registerAcceptableFlower(acceptedFlowerBlock, meta, flowerType); + } else { + Proxies.log.warning("No block found for '" + acceptedFlower + "' in config '" + property.getName() + "'."); + } + } + } + + private static void parsePlantableFlowers(Property property, String flowerType) { + for (String string : property.getStringList()) { + int idx = string.indexOf(':'); + + String weightString = string.substring(0, idx); + double weight; + try { + weight = Double.parseDouble(weightString); + } catch (NumberFormatException e) { + Proxies.log.warning("Invalid weight for plantable flower in config. (" + property.getName() + ')'); + continue; + } + + String itemStackString = string.substring(idx + 1); + ItemStack plantableFlower = StackUtils.parseItemStackString(itemStackString, OreDictionary.WILDCARD_VALUE); + + if (plantableFlower == null) { + Proxies.log.warning("No block found for '" + string + "' in config '" + property.getName() + "'."); + continue; + } + + Block plantableFlowerBlock = Block.getBlockFromItem(plantableFlower.getItem()); + int meta = plantableFlower.getItemDamage(); + if (plantableFlowerBlock != null) { + FlowerManager.flowerRegistry.registerPlantableFlower(plantableFlowerBlock, meta, weight, flowerType); + } else { + Proxies.log.warning("No block found for '" + plantableFlower + "' in config '" + property.getName() + "'."); + } + } + } + @Override public ISaveEventHandler getSaveEventHandler() { return new SaveEventHandlerApiculture(); diff --git a/src/main/java/forestry/plugins/PluginStorage.java b/src/main/java/forestry/plugins/PluginStorage.java index ecdc724ef..486296602 100755 --- a/src/main/java/forestry/plugins/PluginStorage.java +++ b/src/main/java/forestry/plugins/PluginStorage.java @@ -84,6 +84,7 @@ import forestry.storage.proxy.ProxyStorage; public class PluginStorage extends ForestryPlugin { private static final List crates = new ArrayList(); + private static final String CONFIG_CATEGORY = "backpacks"; @SidedProxy(clientSide = "forestry.storage.proxy.ClientProxyStorage", serverSide = "forestry.storage.proxy.ProxyStorage") public static ProxyStorage proxy; @@ -145,18 +146,22 @@ public class PluginStorage extends ForestryPlugin { @Override public void postInit() { - File configFile = new File(Forestry.instance.getConfigFolder(), "backpacks.cfg"); + final String oldConfig = CONFIG_CATEGORY + ".conf"; + final String newConfig = CONFIG_CATEGORY + ".cfg"; + + File configFile = new File(Forestry.instance.getConfigFolder(), newConfig); if (!configFile.exists()) { setDefaultsForConfig(); } - File oldConfigFile = new File(Forestry.instance.getConfigFolder(), "backpacks.conf"); + File oldConfigFile = new File(Forestry.instance.getConfigFolder(), oldConfig); if (oldConfigFile.exists()) { loadOldConfig(); - File oldConfigFileRenamed = new File(Forestry.instance.getConfigFolder(), "backpacks.conf.old"); + final String oldConfigRenamed = CONFIG_CATEGORY + ".conf.old"; + File oldConfigFileRenamed = new File(Forestry.instance.getConfigFolder(), oldConfigRenamed); if (oldConfigFile.renameTo(oldConfigFileRenamed)) { - Proxies.log.info("Migrated backpack settings to the new file 'backpacks.cfg' and renamed 'backpacks.config' to 'backpacks.conf.old'."); + Proxies.log.info("Migrated " + CONFIG_CATEGORY + " settings to the new file '" + newConfig + "' and renamed '" + oldConfig + "' to '" + oldConfigRenamed + "'."); } } @@ -208,8 +213,6 @@ public class PluginStorage extends ForestryPlugin { final forestry.core.config.Configuration config = new forestry.core.config.Configuration(); - final String CONFIG_CATEGORY = "backpacks"; - forestry.core.config.Property backpackConf = config.get("backpacks.miner.items", CONFIG_CATEGORY, ""); backpackConf.comment = "add additional blocks and items for the miner's backpack here in the format modid:name:meta. separate blocks and items using ';'. wildcard for metadata: '*'"; old_parseBackpackItems(backpackConf.value, BackpackManager.definitions.get("miner"));