Revert "Test run of a new version checker for Forge"

This reverts commit df2a2c78d0.
This commit is contained in:
Adubbz 2013-09-26 13:50:38 +10:00
parent 9529a73ca4
commit acb1fb352b
6 changed files with 12 additions and 145 deletions

View file

@ -1,11 +1,5 @@
package biomesoplenty; 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.crash.CallableMinecraftVersion;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
@ -34,10 +28,9 @@ import biomesoplenty.handlers.SoundHandler;
import biomesoplenty.handlers.TickHandlerClient; import biomesoplenty.handlers.TickHandlerClient;
import biomesoplenty.handlers.TickHandlerServer; import biomesoplenty.handlers.TickHandlerServer;
import biomesoplenty.handlers.VillageMaterialEventHandler; import biomesoplenty.handlers.VillageMaterialEventHandler;
import biomesoplenty.handlers.versionhandlers.BOPForgeVersionHandler;
import biomesoplenty.handlers.versionhandlers.BOPModVersionHandler;
import biomesoplenty.helpers.AchievementHelper; import biomesoplenty.helpers.AchievementHelper;
import biomesoplenty.helpers.CreativeTabsBOP; import biomesoplenty.helpers.CreativeTabsBOP;
import biomesoplenty.helpers.Version;
import biomesoplenty.integration.BOPCrossIntegration; import biomesoplenty.integration.BOPCrossIntegration;
import biomesoplenty.world.WorldProviderPromised; import biomesoplenty.world.WorldProviderPromised;
import biomesoplenty.world.WorldTypeSize; import biomesoplenty.world.WorldTypeSize;
@ -51,11 +44,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.TickRegistry; 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; import cpw.mods.fml.relauncher.Side;
@Mod(modid="BiomesOPlenty", name="Biomes O' Plenty", version=BOPModVersionHandler.VERSION) @Mod(modid="BiomesOPlenty", name="Biomes O' Plenty", version=Version.VERSION, dependencies="after:Natura; required-after:Forge@[1.42.666.42.1,)")
@NetworkMod(clientSideRequired=true, serverSideRequired=false) @NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class BiomesOPlenty public class BiomesOPlenty
{ {
@ -74,12 +65,7 @@ public class BiomesOPlenty
configPath = event.getModConfigurationDirectory() + "/biomesoplenty/"; configPath = event.getModConfigurationDirectory() + "/biomesoplenty/";
BOPConfiguration.init(configPath); BOPConfiguration.init(configPath);
BOPForgeVersionHandler.check(); Version.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"); tabBiomesOPlenty = new CreativeTabsBOP(CreativeTabs.getNextID(),"tabBiomesOPlenty");
@ -147,27 +133,4 @@ public class BiomesOPlenty
TickRegistry.registerTickHandler(new TickHandlerClient(), Side.CLIENT); TickRegistry.registerTickHandler(new TickHandlerClient(), Side.CLIENT);
TickRegistry.registerTickHandler(new TickHandlerServer(), Side.SERVER); TickRegistry.registerTickHandler(new TickHandlerServer(), Side.SERVER);
} }
public <T extends Collection<ArtifactVersion>> T processReferences(Object refs, Class<? extends T> retType)
{
T res = null;
try
{
res = retType.newInstance();
}
catch (Exception e)
{
// unpossible
}
if (refs == null)
{
return res;
}
for (String ref : ((List<String>)refs))
{
res.add(VersionParser.parseVersionReference(ref));
}
return res;
}
} }

View file

@ -176,11 +176,7 @@ public class BlockReferences {
deathbloom (Blocks.flowers, 2), deathbloom (Blocks.flowers, 2),
glowFlower (Blocks.flowers, 3), glowFlower (Blocks.flowers, 3),
hydrangea (Blocks.flowers, 4), hydrangea (Blocks.flowers, 4),
@Deprecated
daisy (Blocks.flowers, 5),
cosmos (Blocks.flowers, 5), cosmos (Blocks.flowers, 5),
@Deprecated
tulip (Blocks.flowers, 6),
daffodil (Blocks.flowers, 6), daffodil (Blocks.flowers, 6),
wildFlower (Blocks.flowers, 7), wildFlower (Blocks.flowers, 7),
violet (Blocks.flowers, 8), violet (Blocks.flowers, 8),

View file

@ -3,7 +3,7 @@ package biomesoplenty.handlers;
import java.util.EnumSet; import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import biomesoplenty.handlers.versionhandlers.BOPModVersionHandler; import biomesoplenty.helpers.Version;
import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.TickType;
@ -25,14 +25,14 @@ public class TickHandlerClient implements ITickHandler
EntityPlayer player = (EntityPlayer) tickData[0]; EntityPlayer player = (EntityPlayer) tickData[0];
if (BOPModVersionHandler.needsBOPWorldtypeAndMarkAsSeen(player.worldObj)) if (Version.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.")); 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 (BOPModVersionHandler.needsUpdateNoticeAndMarkAsSeen()) if (Version.needsUpdateNoticeAndMarkAsSeen())
{ {
player.addChatMessage(String.format("\u00A7cA new version of Biomes O Plenty is available: v%s for Minecraft %s", BOPModVersionHandler.getRecommendedVersion(), Loader.instance().getMinecraftModContainer().getVersion())); player.addChatMessage(String.format("\u00A7cA new version of Biomes O Plenty is available: v%s for Minecraft %s", Version.getRecommendedVersion(), Loader.instance().getMinecraftModContainer().getVersion()));
} }
nagged = true; nagged = true;

View file

@ -1,90 +0,0 @@
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();
}
}

View file

@ -1,4 +1,4 @@
package biomesoplenty.handlers.versionhandlers; package biomesoplenty.helpers;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -14,8 +14,8 @@ import biomesoplenty.world.WorldTypeBOP;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
public class BOPModVersionHandler implements Runnable { public class Version implements Runnable {
private static BOPModVersionHandler instance = new BOPModVersionHandler(); private static Version instance = new Version();
public enum EnumUpdateState public enum EnumUpdateState
{ {
@ -23,8 +23,8 @@ public class BOPModVersionHandler implements Runnable {
} }
public static final String VERSION = "@VERSION@"; public static final String VERSION = "@VERSION@";
private static final String REMOTE_VERSION_FILE = "https://raw.github.com/Glitchfiend/BiomesOPlenty/master/version.txt"; 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/Glitchfiend/BiomesOPlenty/master/changelog/"; private static final String REMOTE_CHANGELOG_ROOT = "https://raw.github.com/BiomesOPlenty/BiomesOPlenty/master/changelog/";
public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT; public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT;

View file

@ -1,2 +0,0 @@
1.6.2:BiomesOPlenty:1.1.2
1.6.4:BiomesOPlenty:9.10.1.895