delete unused versionchecker code

This commit is contained in:
Vincent Lee committed 2019-08-04 09:54:00 -07:00
1 parent 2f53768495
commit f671faf20a
3 files changed
-206

No files matched your search

@@ -1,98 +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 the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [May 31, 2014, 10:22:44 PM (GMT)]
*/
package vazkii.botania.common.core.version;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.TextFormatting;
import java.awt.Desktop;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
public class ThreadDownloadMod extends Thread {
private final String fileName;
private byte[] buffer = new byte[10240];
private int bytesJustDownloaded;
private InputStream webReader;
public ThreadDownloadMod(String fileName) {
setName("Botania Download File Thread");
this.fileName = fileName;
setDaemon(true);
start();
}
@Override
public void run() {
try {
ITextComponent component = ITextComponent.Serializer.fromJson(I18n.format("botania.versioning.startingDownload", fileName));
if(Minecraft.getInstance().player != null)
Minecraft.getInstance().player.sendMessage(component);
VersionChecker.startedDownload = true;
String base = "https://botaniamod.net/";
String file = fileName.replaceAll(" ", "%20");
URL url = new URL(base + "dl.php?file=" + file);
try {
url.openStream().close(); // Add to DL Counter
} catch(IOException ignored) {}
url = new URL(base + "files/" + file);
webReader = url.openStream();
File dir = new File(".", "mods");
File f = new File(dir, fileName + ".dl");
f.createNewFile();
FileOutputStream outputStream = new FileOutputStream(f.getAbsolutePath());
while((bytesJustDownloaded = webReader.read(buffer)) > 0) {
outputStream.write(buffer, 0, bytesJustDownloaded);
buffer = new byte[10240];
}
outputStream.close();
webReader.close();
File f1 = new File(dir, fileName);
if(!f1.exists())
f.renameTo(f1);
if(Minecraft.getInstance().player != null)
Minecraft.getInstance().player.sendMessage(new TranslationTextComponent("botania.versioning.doneDownloading", fileName).setStyle(new Style().setColor(TextFormatting.GREEN)));
Desktop.getDesktop().open(dir);
VersionChecker.downloadedFile = true;
} catch (IOException e) {
e.printStackTrace();
sendError();
}
}
private void sendError() {
if(Minecraft.getInstance().player != null)
Minecraft.getInstance().player.sendMessage(new TranslationTextComponent("botania.versioning.error").setStyle(new Style().setColor(TextFormatting.RED)));
}
}
@@ -1,40 +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 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 net.minecraftforge.common.MinecraftForge;
import vazkii.botania.common.lib.LibMisc;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
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/Botania/master/version/" + LibMisc.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;
}
}
@@ -1,68 +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 the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [May 31, 2014, 9:58:26 PM (GMT)]
*/
package vazkii.botania.common.core.version;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.api.distmarker.Dist;
import vazkii.botania.common.lib.LibMisc;
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID)
public final class VersionChecker {
private VersionChecker() {}
private static final int FLAVOUR_MESSAGES = 65;
public static volatile boolean doneChecking = false;
public static volatile String onlineVersion = "";
private static boolean triedToWarnPlayer = false;
public static volatile boolean startedDownload = false;
public static volatile boolean downloadedFile = false;
public static void init() {
new ThreadVersionChecker();
}
@SubscribeEvent
public static void onTick(ClientTickEvent event) {
if(event.phase == Phase.END && Minecraft.getInstance().player != null && !triedToWarnPlayer && doneChecking) {
if(!onlineVersion.isEmpty()) {
PlayerEntity player = Minecraft.getInstance().player;
int onlineBuild = Integer.parseInt(onlineVersion.split("-")[1]);
int clientBuild = LibMisc.BUILD.contains("GRADLE") ? Integer.MAX_VALUE : Integer.parseInt(LibMisc.BUILD);
if(onlineBuild > clientBuild) {
player.sendMessage(new TranslationTextComponent("botania.versioning.flavour" + player.world.rand.nextInt(FLAVOUR_MESSAGES)).setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE)));
player.sendMessage(new TranslationTextComponent("botania.versioning.outdated", clientBuild, onlineBuild));
// todo 1.13
// ITextComponent component = new TextComponentTranslation("botania.versioning.updateMessage").replaceAll("%version%", onlineVersion);
// player.sendMessage(component);
}
}
triedToWarnPlayer = true;
}
}
}