mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-25 14:34:36 +00:00
Listen scrub, this is my updater.
This commit is contained in:
1 parent
c6f9103b31
commit
309574adc7
5 files changed
+56
-22
No files matched your search
@@ -92,8 +92,7 @@ import vazkii.botania.common.network.PacketHandler;
|
||||
import vazkii.botania.common.world.SkyblockWorldEvents;
|
||||
import vazkii.botania.common.world.WorldTypeSkyblock;
|
||||
|
||||
@Mod(modid = LibMisc.MOD_ID, name = LibMisc.MOD_NAME, version = LibMisc.VERSION, dependencies = LibMisc.DEPENDENCIES,
|
||||
guiFactory = LibMisc.GUI_FACTORY, acceptedMinecraftVersions = LibMisc.MC_VERSIONS, updateJSON = LibMisc.UPDATE_JSON)
|
||||
@Mod(modid = LibMisc.MOD_ID, name = LibMisc.MOD_NAME, version = LibMisc.VERSION, dependencies = LibMisc.DEPENDENCIES, guiFactory = LibMisc.GUI_FACTORY)
|
||||
public class Botania {
|
||||
|
||||
public static boolean gardenOfGlassLoaded = false;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [May 31, 2014, 10:31:46 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.core.version;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class ThreadVersionChecker extends Thread {
|
||||
|
||||
public ThreadVersionChecker() {
|
||||
setName("Botania Version Checker Thread");
|
||||
setDaemon(true);
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://raw.githubusercontent.com/Vazkii/BotaniaV2/master/version/" + MinecraftForge.MC_VERSION + ".txt");
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
VersionChecker.onlineVersion = r.readLine();
|
||||
r.close();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
VersionChecker.doneChecking = true;
|
||||
}
|
||||
}
|
||||
@@ -11,20 +11,16 @@
|
||||
package vazkii.botania.common.core.version;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public final class VersionChecker {
|
||||
|
||||
@@ -33,32 +29,34 @@ public final class VersionChecker {
|
||||
private static final int FLAVOUR_MESSAGES = 65;
|
||||
|
||||
public static boolean doneChecking = false;
|
||||
public static String onlineVersion = "";
|
||||
private static boolean triedToWarnPlayer = false;
|
||||
|
||||
public static boolean startedDownload = false;
|
||||
public static boolean downloadedFile = false;
|
||||
|
||||
public static void init() {
|
||||
new ThreadVersionChecker();
|
||||
MinecraftForge.EVENT_BUS.register(VersionChecker.class);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onTick(ClientTickEvent event) {
|
||||
if(!triedToWarnPlayer && event.phase == Phase.END && Minecraft.getMinecraft().thePlayer != null) {
|
||||
ModContainer botaniaContainer = Loader.instance().getIndexedModList().get(LibMisc.MOD_ID);
|
||||
ForgeVersion.CheckResult result = ForgeVersion.getResult(botaniaContainer);
|
||||
|
||||
if(result.status != ForgeVersion.Status.PENDING)
|
||||
triedToWarnPlayer = true;
|
||||
|
||||
if(result.status == ForgeVersion.Status.OUTDATED) {
|
||||
if(doneChecking && event.phase == Phase.END && Minecraft.getMinecraft().thePlayer != null && !triedToWarnPlayer) {
|
||||
if(!onlineVersion.isEmpty()) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
player.addChatComponentMessage(new TextComponentTranslation("botania.versioning.flavour" + player.worldObj.rand.nextInt(FLAVOUR_MESSAGES)).setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE)));
|
||||
player.addChatComponentMessage(new TextComponentTranslation("botania.versioning.outdated", botaniaContainer.getVersion(), result.target));
|
||||
int onlineBuild = Integer.parseInt(onlineVersion.split("-")[1]);
|
||||
int clientBuild = 10;//LibMisc.BUILD.contains("GRADLE") ? Integer.MAX_VALUE : Integer.parseInt(LibMisc.BUILD);
|
||||
if(onlineBuild > clientBuild) {
|
||||
player.addChatComponentMessage(new TextComponentTranslation("botania.versioning.flavour" + player.worldObj.rand.nextInt(FLAVOUR_MESSAGES)).setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE)));
|
||||
player.addChatComponentMessage(new TextComponentTranslation("botania.versioning.outdated", clientBuild, onlineBuild));
|
||||
|
||||
ITextComponent component = ITextComponent.Serializer.jsonToComponent(I18n.format("botania.versioning.updateMessage", result.target));
|
||||
player.addChatComponentMessage(component);
|
||||
ITextComponent component = ITextComponent.Serializer.fromJsonLenient(I18n.translateToLocal("botania.versioning.updateMessage").replaceAll("%version%", onlineVersion));
|
||||
player.addChatComponentMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
triedToWarnPlayer = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ public final class LibMisc {
|
||||
public static final String BUILD = "GRADLE:BUILD";
|
||||
public static final String VERSION = "GRADLE:VERSION-" + BUILD;
|
||||
public static final String DEPENDENCIES = "required-after:Forge@[12.18.1.2053,];required-after:Baubles;after:Thaumcraft";
|
||||
public static final String MC_VERSIONS = "[1.10.2]";
|
||||
public static final String UPDATE_JSON = "https://raw.githubusercontent.com/williewillus/Botania/HEAD/version/update.json";
|
||||
|
||||
// Network Contants
|
||||
public static final String NETWORK_CHANNEL = MOD_ID;
|
||||
|
||||
Reference in new issue
Block a user