diff --git a/common/biomesoplenty/BiomesOPlenty.java b/common/biomesoplenty/BiomesOPlenty.java index d918be173..70ac28761 100644 --- a/common/biomesoplenty/BiomesOPlenty.java +++ b/common/biomesoplenty/BiomesOPlenty.java @@ -1,5 +1,11 @@ package biomesoplenty; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static argo.jdom.JsonNodeBuilders.aStringBuilder; + import net.minecraft.crash.CallableMinecraftVersion; import net.minecraft.creativetab.CreativeTabs; import net.minecraftforge.common.DimensionManager; @@ -28,9 +34,10 @@ import biomesoplenty.handlers.SoundHandler; import biomesoplenty.handlers.TickHandlerClient; import biomesoplenty.handlers.TickHandlerServer; import biomesoplenty.handlers.VillageMaterialEventHandler; +import biomesoplenty.handlers.versionhandlers.BOPForgeVersionHandler; +import biomesoplenty.handlers.versionhandlers.BOPModVersionHandler; import biomesoplenty.helpers.AchievementHelper; import biomesoplenty.helpers.CreativeTabsBOP; -import biomesoplenty.helpers.Version; import biomesoplenty.integration.BOPCrossIntegration; import biomesoplenty.world.WorldProviderPromised; import biomesoplenty.world.WorldTypeSize; @@ -44,9 +51,11 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.TickRegistry; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.VersionParser; import cpw.mods.fml.relauncher.Side; -@Mod(modid="BiomesOPlenty", name="Biomes O' Plenty", version=Version.VERSION, dependencies="after:Natura; required-after:Forge@[1.42.666.42.1,)") +@Mod(modid="BiomesOPlenty", name="Biomes O' Plenty", version=BOPModVersionHandler.VERSION) @NetworkMod(clientSideRequired=true, serverSideRequired=false) public class BiomesOPlenty { @@ -65,7 +74,12 @@ public class BiomesOPlenty configPath = event.getModConfigurationDirectory() + "/biomesoplenty/"; BOPConfiguration.init(configPath); - Version.check(); + BOPForgeVersionHandler.check(); + + String dependancies = "after:Natura;required-after:Forge@[" + BOPForgeVersionHandler.recommendedVersion + ",)"; + event.getModMetadata().dependencies.add(VersionParser.parseVersionReference(dependancies)); + + BOPModVersionHandler.check(); tabBiomesOPlenty = new CreativeTabsBOP(CreativeTabs.getNextID(),"tabBiomesOPlenty"); @@ -133,4 +147,27 @@ public class BiomesOPlenty TickRegistry.registerTickHandler(new TickHandlerClient(), Side.CLIENT); TickRegistry.registerTickHandler(new TickHandlerServer(), Side.SERVER); } + + public > T processReferences(Object refs, Class retType) + { + T res = null; + try + { + res = retType.newInstance(); + } + catch (Exception e) + { + // unpossible + } + + if (refs == null) + { + return res; + } + for (String ref : ((List)refs)) + { + res.add(VersionParser.parseVersionReference(ref)); + } + return res; + } } \ No newline at end of file diff --git a/common/biomesoplenty/api/BlockReferences.java b/common/biomesoplenty/api/BlockReferences.java index ac1e86637..beb515775 100644 --- a/common/biomesoplenty/api/BlockReferences.java +++ b/common/biomesoplenty/api/BlockReferences.java @@ -176,7 +176,11 @@ public class BlockReferences { deathbloom (Blocks.flowers, 2), glowFlower (Blocks.flowers, 3), hydrangea (Blocks.flowers, 4), + @Deprecated + daisy (Blocks.flowers, 5), cosmos (Blocks.flowers, 5), + @Deprecated + tulip (Blocks.flowers, 6), daffodil (Blocks.flowers, 6), wildFlower (Blocks.flowers, 7), violet (Blocks.flowers, 8), diff --git a/common/biomesoplenty/handlers/TickHandlerClient.java b/common/biomesoplenty/handlers/TickHandlerClient.java index 16994ab3f..1992dc214 100644 --- a/common/biomesoplenty/handlers/TickHandlerClient.java +++ b/common/biomesoplenty/handlers/TickHandlerClient.java @@ -3,7 +3,7 @@ package biomesoplenty.handlers; import java.util.EnumSet; import net.minecraft.entity.player.EntityPlayer; -import biomesoplenty.helpers.Version; +import biomesoplenty.handlers.versionhandlers.BOPModVersionHandler; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.TickType; @@ -25,14 +25,14 @@ public class TickHandlerClient implements ITickHandler EntityPlayer player = (EntityPlayer) tickData[0]; - if (Version.needsBOPWorldtypeAndMarkAsSeen(player.worldObj)) + if (BOPModVersionHandler.needsBOPWorldtypeAndMarkAsSeen(player.worldObj)) { player.addChatMessage(String.format("\u00A7cThe Biomes O Plenty world type must be used in order for the new biomes to generate. This message will only display once.")); } - if (Version.needsUpdateNoticeAndMarkAsSeen()) + if (BOPModVersionHandler.needsUpdateNoticeAndMarkAsSeen()) { - player.addChatMessage(String.format("\u00A7cA new version of Biomes O Plenty is available: v%s for Minecraft %s", Version.getRecommendedVersion(), Loader.instance().getMinecraftModContainer().getVersion())); + player.addChatMessage(String.format("\u00A7cA new version of Biomes O Plenty is available: v%s for Minecraft %s", BOPModVersionHandler.getRecommendedVersion(), Loader.instance().getMinecraftModContainer().getVersion())); } nagged = true; diff --git a/common/biomesoplenty/handlers/versionhandlers/BOPForgeVersionHandler.java b/common/biomesoplenty/handlers/versionhandlers/BOPForgeVersionHandler.java new file mode 100644 index 000000000..2694af6f5 --- /dev/null +++ b/common/biomesoplenty/handlers/versionhandlers/BOPForgeVersionHandler.java @@ -0,0 +1,90 @@ +package biomesoplenty.handlers.versionhandlers; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.logging.Level; + +import net.minecraft.world.World; +import net.minecraft.world.WorldType; +import net.minecraftforge.common.ForgeVersion; +import net.minecraftforge.common.Property; +import biomesoplenty.configuration.configfile.BOPConfigurationMain; +import biomesoplenty.world.WorldTypeBOP; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; + +public class BOPForgeVersionHandler implements Runnable +{ + private static BOPForgeVersionHandler instance = new BOPForgeVersionHandler(); + + private static final String REMOTE_VERSION_FILE = "https://raw.github.com/Glitchfiend/BiomesOPlenty/master/forgeversion.txt"; + + private static boolean hasFailed = false; + + public static String recommendedVersion = "1.42.666.42.1"; + + public static void versionCheck() + { + try + { + String location = REMOTE_VERSION_FILE; + HttpURLConnection conn = null; + while (location != null && !location.isEmpty()) { + URL url = new URL(location); + conn = (HttpURLConnection) url.openConnection(); + conn.setRequestProperty( + "User-Agent", + "Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)"); + conn.connect(); + location = conn.getHeaderField("Location"); + } + + BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + + String line = null; + String mcVersion = Loader.instance().getMinecraftModContainer().getVersion(); + + while ((line = reader.readLine()) != null) + { + if (line.startsWith(mcVersion)) { + if (line.contains("BiomesOPlenty")) + { + String[] tokens = line.split(":"); + + recommendedVersion = tokens[2]; + } + } + } + + } + catch (Exception e) + { + FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, "[BiomesOPlenty] Unable to read from remote version authority."); + FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, e.toString()); + + hasFailed = true; + } + } + + @Override + public void run() + { + FMLCommonHandler.instance().getFMLLogger().log(Level.INFO, "[BiomesOPlenty] Beginning Forge version check"); + + versionCheck(); + + if (hasFailed) + { + FMLCommonHandler.instance().getFMLLogger().log(Level.INFO, "[BiomesOPlenty] Version check failed"); + } + } + + public static void check() + { + new Thread(instance).start(); + } +} diff --git a/common/biomesoplenty/helpers/Version.java b/common/biomesoplenty/handlers/versionhandlers/BOPModVersionHandler.java similarity index 94% rename from common/biomesoplenty/helpers/Version.java rename to common/biomesoplenty/handlers/versionhandlers/BOPModVersionHandler.java index 832b9c36f..8cba1c753 100644 --- a/common/biomesoplenty/helpers/Version.java +++ b/common/biomesoplenty/handlers/versionhandlers/BOPModVersionHandler.java @@ -1,4 +1,4 @@ -package biomesoplenty.helpers; +package biomesoplenty.handlers.versionhandlers; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -14,8 +14,8 @@ import biomesoplenty.world.WorldTypeBOP; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; -public class Version implements Runnable { - private static Version instance = new Version(); +public class BOPModVersionHandler implements Runnable { + private static BOPModVersionHandler instance = new BOPModVersionHandler(); public enum EnumUpdateState { @@ -23,8 +23,8 @@ public class Version implements Runnable { } public static final String VERSION = "@VERSION@"; - private static final String REMOTE_VERSION_FILE = "https://raw.github.com/BiomesOPlenty/BiomesOPlenty/master/version.txt"; - private static final String REMOTE_CHANGELOG_ROOT = "https://raw.github.com/BiomesOPlenty/BiomesOPlenty/master/changelog/"; + private static final String REMOTE_VERSION_FILE = "https://raw.github.com/Glitchfiend/BiomesOPlenty/master/version.txt"; + private static final String REMOTE_CHANGELOG_ROOT = "https://raw.github.com/Glitchfiend/BiomesOPlenty/master/changelog/"; public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT; diff --git a/forgeversion.txt b/forgeversion.txt new file mode 100644 index 000000000..1bf0c4950 --- /dev/null +++ b/forgeversion.txt @@ -0,0 +1,2 @@ +1.6.2:BiomesOPlenty:1.1.2 +1.6.4:BiomesOPlenty:9.10.1.895