From 41cd50d4c03df6c302185d8f94ee41c1abb02ae9 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 30 Mar 2013 12:12:54 -0400 Subject: [PATCH] Change snooper/crash report brand handling. fmlbranding now loads another string! --- .../cpw/mods/fml/common/FMLCommonHandler.java | 28 ++++++++++++++----- fml/common/cpw/mods/fml/common/Loader.java | 18 ++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index 7f09adc98..f0c6d818d 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -5,7 +5,7 @@ * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * + * * Contributors: * cpw - implementation */ @@ -38,6 +38,7 @@ import net.minecraft.world.World; import net.minecraft.world.storage.SaveHandler; import net.minecraft.world.storage.WorldInfo; +import com.google.common.base.Joiner; import com.google.common.base.Objects; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; @@ -244,12 +245,9 @@ public class FMLCommonHandler { brd.addAll(sidedDelegate.getAdditionalBrandingInformation()); } - try { - Properties props=new Properties(); - props.load(getClass().getClassLoader().getResourceAsStream("fmlbranding.properties")); - brd.add(props.getProperty("fmlbranding")); - } catch (Exception ex) { - // Ignore - no branding file found + if (Loader.instance().getFMLBrandingProperties().containsKey("fmlbranding")) + { + brd.add(Loader.instance().getFMLBrandingProperties().get("fmlbranding")); } int tModCount = Loader.instance().getModList().size(); int aModCount = Loader.instance().getActiveModList().size(); @@ -469,4 +467,20 @@ public class FMLCommonHandler { Loader.instance().serverStopped(); } + + public String getModName() + { + List modNames = Lists.newArrayListWithExpectedSize(3); + modNames.add("fml"); + if (!noForge) + { + modNames.add("forge"); + } + + if (Loader.instance().getFMLBrandingProperties().containsKey("snooperbranding")) + { + modNames.add(Loader.instance().getFMLBrandingProperties().get("snooperbranding")); + } + return Joiner.on(',').join(modNames); + } } diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index 320defe7c..b0bacb748 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -152,6 +152,7 @@ public class Loader private static File minecraftDir; private static List injectedContainers; private File loggingProperties; + private ImmutableMap fmlBrandingProperties; public static Loader instance() { @@ -821,4 +822,21 @@ public class Loader return true; } + public Map getFMLBrandingProperties() + { + if (fmlBrandingProperties == null) + { + Properties loaded = new Properties(); + try + { + loaded.load(getClass().getClassLoader().getResourceAsStream("fmlbranding.properties")); + } + catch (IOException e) + { + // File not found - ignore + } + fmlBrandingProperties = Maps.fromProperties(loaded); + } + return fmlBrandingProperties; + } }