From aef8260877f31fbb50b359c3a8e3167689d8e494 Mon Sep 17 00:00:00 2001 From: Dynious Date: Tue, 10 Jun 2014 16:27:12 +0200 Subject: [PATCH] Made sure Version IMC message is also sent after init phase --- common/buildcraft/core/Version.java | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java index 4780bac6..b348b1e9 100644 --- a/common/buildcraft/core/Version.java +++ b/common/buildcraft/core/Version.java @@ -19,6 +19,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.Loader; import net.minecraftforge.common.config.Property; @@ -225,24 +226,27 @@ public class Version implements Runnable { /** * This is an integration with Dynious Version Checker See - * http://www.minecraftforum.net/topic/2721902-172 + * http://www.minecraftforum.net/topic/2721902- */ public static void sendIMCOutdatedMessage() { - NBTTagCompound compound = new NBTTagCompound(); - compound.setString("modDisplayName", "BuildCraft"); - compound.setString("oldVersion", VERSION); - compound.setString("newVersion", getRecommendedVersion()); + if (Loader.isModLoaded("VersionChecker")) { + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("modDisplayName", "BuildCraft"); + compound.setString("oldVersion", VERSION); + compound.setString("newVersion", getRecommendedVersion()); - compound.setString("updateUrl", "http://www.mod-buildcraft.com/download/"); - compound.setBoolean("isDirectLink", false); + compound.setString("updateUrl", "http://www.mod-buildcraft.com/download/"); + compound.setBoolean("isDirectLink", false); - String changeLogString = ""; - for (String changeLogLine : getChangelog()) { - changeLogString = changeLogString + changeLogLine + "\n"; + StringBuilder stringBuilder = new StringBuilder(); + for (String changeLogLine : getChangelog()) { + stringBuilder.append(changeLogLine).append("\n"); + } + compound.setString("changeLog", stringBuilder.toString()); + + FMLInterModComms.sendRuntimeMessage("BuildCraft|Core", "VersionChecker", "addUpdate", compound); + sentIMCOutdatedMessage = true; } - compound.setString("changeLog", changeLogString); - - sentIMCOutdatedMessage = FMLInterModComms.sendMessage("VersionChecker", "addUpdate", compound); } public static void displayChangelog(ICommandSender sender) {