Test run of a new version checker for Forge
This commit is contained in:
parent
04d3792b02
commit
df2a2c78d0
6 changed files with 145 additions and 12 deletions
|
@ -1,5 +1,11 @@
|
||||||
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;
|
||||||
|
@ -28,9 +34,10 @@ 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;
|
||||||
|
@ -44,9 +51,11 @@ 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=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)
|
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
|
||||||
public class BiomesOPlenty
|
public class BiomesOPlenty
|
||||||
{
|
{
|
||||||
|
@ -65,7 +74,12 @@ public class BiomesOPlenty
|
||||||
configPath = event.getModConfigurationDirectory() + "/biomesoplenty/";
|
configPath = event.getModConfigurationDirectory() + "/biomesoplenty/";
|
||||||
BOPConfiguration.init(configPath);
|
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");
|
tabBiomesOPlenty = new CreativeTabsBOP(CreativeTabs.getNextID(),"tabBiomesOPlenty");
|
||||||
|
|
||||||
|
@ -133,4 +147,27 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -176,7 +176,11 @@ 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),
|
||||||
|
|
|
@ -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.helpers.Version;
|
import biomesoplenty.handlers.versionhandlers.BOPModVersionHandler;
|
||||||
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 (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."));
|
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;
|
nagged = true;
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package biomesoplenty.helpers;
|
package biomesoplenty.handlers.versionhandlers;
|
||||||
|
|
||||||
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 Version implements Runnable {
|
public class BOPModVersionHandler implements Runnable {
|
||||||
private static Version instance = new Version();
|
private static BOPModVersionHandler instance = new BOPModVersionHandler();
|
||||||
|
|
||||||
public enum EnumUpdateState
|
public enum EnumUpdateState
|
||||||
{
|
{
|
||||||
|
@ -23,8 +23,8 @@ public class Version 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/BiomesOPlenty/BiomesOPlenty/master/version.txt";
|
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/BiomesOPlenty/BiomesOPlenty/master/changelog/";
|
private static final String REMOTE_CHANGELOG_ROOT = "https://raw.github.com/Glitchfiend/BiomesOPlenty/master/changelog/";
|
||||||
|
|
||||||
public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT;
|
public static EnumUpdateState currentVersion = EnumUpdateState.CURRENT;
|
||||||
|
|
2
forgeversion.txt
Normal file
2
forgeversion.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
1.6.2:BiomesOPlenty:1.1.2
|
||||||
|
1.6.4:BiomesOPlenty:9.10.1.895
|
Loading…
Reference in a new issue