From 53fe67cf61ad54bb14c65b8cadb0ea806d30ba47 Mon Sep 17 00:00:00 2001 From: Andrew2448 Date: Thu, 27 Jun 2013 23:13:33 -0400 Subject: [PATCH] Moved the lang files to the resources folder and moved the config to a new location. --- .../mmmPowersuits}/lang/en_US.lang | 0 .../machinemuse/powersuits/common/Config.java | 7 ++++--- .../powersuits/common/ModularPowersuits.java | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) rename {src/minecraft/net/machinemuse/general => mods/mmmPowersuits}/lang/en_US.lang (100%) diff --git a/src/minecraft/net/machinemuse/general/lang/en_US.lang b/mods/mmmPowersuits/lang/en_US.lang similarity index 100% rename from src/minecraft/net/machinemuse/general/lang/en_US.lang rename to mods/mmmPowersuits/lang/en_US.lang diff --git a/src/minecraft/net/machinemuse/powersuits/common/Config.java b/src/minecraft/net/machinemuse/powersuits/common/Config.java index 556448d..e95515a 100644 --- a/src/minecraft/net/machinemuse/powersuits/common/Config.java +++ b/src/minecraft/net/machinemuse/powersuits/common/Config.java @@ -46,6 +46,7 @@ public class Config { public static final String RESOURCE_PREFIX = "/mods/mmmPowersuits/"; public static final String TEXTURE_PREFIX = RESOURCE_PREFIX + "textures/"; public static final String SOUND_PREFIX = RESOURCE_PREFIX + "sound/"; + public static final String LANG_PREFIX = RESOURCE_PREFIX + "lang/"; // public static final String SEBK_ICON_PATH = // "/mods/mmmPowersuits//machinemuse/sebkicons.png"; public static final String SEBK_ARMOR_PATH = TEXTURE_PREFIX + "models/sebkarmor.png"; @@ -63,7 +64,7 @@ public class Config { public static final String CITIZENJOE_ARMORPANTS_PATH = TEXTURE_PREFIX + "models/joearmorpants.png"; public static final String GLASS_TEXTURE = TEXTURE_PREFIX + "gui/glass.png"; - public static final String LANG_PATH = "/net/machinemuse/general/lang/"; + //public static final String LANG_PATH = "/net/machinemuse/general/lang/"; public static String[] languages = {"en_US"}; @@ -319,12 +320,12 @@ public class Config { public static boolean canUseShaders = false; public static void setConfigFolderBase(File folder) { - configFolder = new File(folder.getAbsolutePath() + "/net/machinemuse/general/"); + configFolder = new File(folder.getAbsolutePath() + "/machinemuse"); } public static void extractLang(String[] langauges) { for (String lang : langauges) { - InputStream inputStream = ModularPowersuits.INSTANCE.getClass().getResourceAsStream(LANG_PATH + lang + ".lang"); + InputStream inputStream = ModularPowersuits.INSTANCE.getClass().getResourceAsStream(LANG_PREFIX + lang + ".lang"); try { File file = new File(configFolder.getAbsolutePath() + "/lang/" + lang + ".lang"); if (!file.exists()) { diff --git a/src/minecraft/net/machinemuse/powersuits/common/ModularPowersuits.java b/src/minecraft/net/machinemuse/powersuits/common/ModularPowersuits.java index 90ce111..17b55a5 100644 --- a/src/minecraft/net/machinemuse/powersuits/common/ModularPowersuits.java +++ b/src/minecraft/net/machinemuse/powersuits/common/ModularPowersuits.java @@ -13,6 +13,7 @@ import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.EntityRegistry; +import net.machinemuse.general.MuseLogger; import net.machinemuse.general.recipe.RecipeManager; import net.machinemuse.powersuits.block.BlockLuxCapacitor; import net.machinemuse.powersuits.block.BlockTinkerTable; @@ -26,6 +27,10 @@ import net.machinemuse.powersuits.network.MusePacketHandler; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.MinecraftForge; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; + /** * Main mod class. This is what Forge loads to get the mod up and running, both * server- and client-side. @@ -93,7 +98,19 @@ public class ModularPowersuits { @PreInit public void preInit(FMLPreInitializationEvent event) { INSTANCE = this; - Config.init(new Configuration(event.getSuggestedConfigurationFile())); + Path oldPath = event.getSuggestedConfigurationFile().toPath(); + File newConfig = new File(event.getModConfigurationDirectory() + "/machinemuse/mmmPowersuits.cfg"); + if (Files.exists(oldPath)) { + try { + Path newPath = newConfig.toPath(); + Files.move(oldPath, newPath); + Files.deleteIfExists(oldPath); + } catch (Exception e) { + e.printStackTrace(); + MuseLogger.logError("Error initializing MPS config."); + } + } + Config.init(new Configuration(newConfig)); Config.setConfigFolderBase(event.getModConfigurationDirectory()); Config.extractLang(Config.languages);