mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-21 12:42:50 +00:00
Getting some work done on the version checker.
This commit is contained in:
1 parent
a0f02e7c9d
commit
909e6f2403
10 files changed
+211
-19
No files matched your search
@@ -31,6 +31,7 @@ public final class ConfigHandler {
|
||||
public static boolean blockBreakParticles = true;
|
||||
public static boolean blockBreakParticlesTool = true;
|
||||
|
||||
public static boolean versionCheckEnabled = true;
|
||||
public static int spreaderPositionShift = 1;
|
||||
|
||||
public static int flowerQuantity = 3;
|
||||
@@ -72,6 +73,9 @@ public final class ConfigHandler {
|
||||
desc = "Set to false to remove the block breaking particles from the Mana Shatterer, as there can be a good amount in higher levels.";
|
||||
blockBreakParticlesTool = loadPropBool("blockBreakingParticlesTool.enabled", desc, blockBreakParticlesTool);
|
||||
|
||||
desc = "Set to false to disable checking and alerting when new Botania versions come out.";
|
||||
versionCheckEnabled = loadPropBool("versionChecking.enabled", desc, versionCheckEnabled);
|
||||
|
||||
desc = "Do not ever touch this value if not asked to. Possible symptoms of doing so include your head turning backwards, the appearance of Titans near the walls or you being trapped in a game of Sword Art Online.";
|
||||
spreaderPositionShift = loadPropInt("spreader.posShift", desc, spreaderPositionShift);
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [May 31, 2014, 9:58:26 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.core.handler;
|
||||
|
||||
public final class VersionChecker {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [May 31, 2014, 10:22:44 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.core.version;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
/**
|
||||
* @author Vazkii, TheWhiteWolves
|
||||
*/
|
||||
public class ThreadDownloadMod extends Thread {
|
||||
|
||||
public static int amountOfDownloadResourceThreads = 0;
|
||||
public static List<String> downloadings = new LinkedList();
|
||||
|
||||
URL downloadUrl;
|
||||
String modName;
|
||||
|
||||
long downloadStartTime;
|
||||
long downloadFinishTime;
|
||||
|
||||
byte[] buffer = new byte[10240];
|
||||
|
||||
int totalBytesDownloaded;
|
||||
int bytesJustDownloaded;
|
||||
|
||||
InputStream webReader;
|
||||
|
||||
public ThreadDownloadMod(String urlToFind, String modName) {
|
||||
if (urlToFind == null)
|
||||
return;
|
||||
|
||||
setName("Botania Download File Thread " + ++amountOfDownloadResourceThreads);
|
||||
|
||||
this.modName = modName;
|
||||
try {
|
||||
downloadUrl = getUrlFromFile(urlToFind);
|
||||
downloadUrl.openConnection();
|
||||
webReader = downloadUrl.openStream();
|
||||
downloadings.add(modName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setDaemon(true);
|
||||
start();
|
||||
}
|
||||
|
||||
URL getUrlFromFile(String file) {
|
||||
URL url;
|
||||
try {
|
||||
url = new URL(file);
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
String s = r.readLine();
|
||||
r.close();
|
||||
return new URL(s);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
File dir = new File(".", "mods");
|
||||
File f = new File(dir, modName + ".jar");
|
||||
f.createNewFile();
|
||||
System.out.println("[Botania] Starting to download file: " + modName + ".zip to " + f.getAbsolutePath() + ".");
|
||||
FileOutputStream outputStream = new FileOutputStream(f.getAbsolutePath());
|
||||
|
||||
downloadStartTime = System.currentTimeMillis();
|
||||
|
||||
while ((bytesJustDownloaded = webReader.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, bytesJustDownloaded);
|
||||
buffer = new byte[10240];
|
||||
totalBytesDownloaded += bytesJustDownloaded;
|
||||
}
|
||||
|
||||
downloadFinishTime = System.currentTimeMillis();
|
||||
|
||||
if (Minecraft.getMinecraft().thePlayer != null)
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("botania.versioning.doneDownloading", modName, (downloadFinishTime - downloadStartTime) / 1000));
|
||||
|
||||
outputStream.close();
|
||||
webReader.close();
|
||||
--amountOfDownloadResourceThreads;
|
||||
downloadings.remove(modName);
|
||||
finalize();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
--amountOfDownloadResourceThreads;
|
||||
downloadings.remove(modName);
|
||||
try {
|
||||
finalize();
|
||||
} catch (Throwable e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* 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("http://raw.githubusercontent.com/Vazkii/Botania/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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [May 31, 2014, 9:58:26 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.core.version;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
|
||||
public final class VersionChecker {
|
||||
|
||||
public static boolean doneChecking = false;
|
||||
public static String onlineVersion = "";
|
||||
public static boolean triedToWarnPlayer = false;
|
||||
|
||||
public void init() {
|
||||
new ThreadVersionChecker();
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(ClientTickEvent event) {
|
||||
if(doneChecking && event.phase == Phase.END && Minecraft.getMinecraft().thePlayer != null && !triedToWarnPlayer) {
|
||||
if(!onlineVersion.isEmpty()) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
triedToWarnPlayer = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@
|
||||
<entry key="build_number" type="int" operation="+" default="1"/>
|
||||
</propertyfile>
|
||||
<concat destfile="${build.dir.repo}\web\versions.ini" append="true" fixlastline="true">${line.separator}${build.version}-${build.build_number}=${build.mc_version}</concat>
|
||||
<echo file="${build.dir.repo}\version\${build.mc_version}.txt">${build.build_number}</echo>
|
||||
<echo file="${build.dir.repo}\version\${build.mc_version}.txt">${build.version}-${build.build_number}</echo>
|
||||
</target>
|
||||
|
||||
<target name="prep">
|
||||
|
||||
@@ -53,6 +53,9 @@ botania.rank3=&aA
|
||||
botania.rank4=&dS
|
||||
botania.rank5=&6SS
|
||||
|
||||
# -- VERSION CHECKING
|
||||
botania.versioning.doneDownloading=Finished downloading file: %s, took %i seconds. Reload your game to update.
|
||||
|
||||
# BAUBLE TOOLTIPS
|
||||
botania.baubletype.amulet=Equippable in the &aAmulet&7 slot
|
||||
botania.baubletype.ring=Equippable in the &aRing&7 slot
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
16
|
||||
@@ -0,0 +1 @@
|
||||
beta-16
|
||||
+1
-1
@@ -1 +1 @@
|
||||
40
|
||||
beta-40
|
||||
Reference in new issue
Block a user