mirror of
https://github.com/GTNewHorizons/BloodArsenal.git
synced 2026-11-20 12:20:02 +00:00
remove version check and download
This commit is contained in:
1 parent
f02b50b9d4
commit
71fb2827c2
7 files changed
-286
No files matched your search
@@ -1,12 +1,10 @@
|
||||
package com.arc.bloodarsenal.client;
|
||||
|
||||
import com.arc.bloodarsenal.common.BloodArsenalConfig;
|
||||
import com.arc.bloodarsenal.common.CommonProxy;
|
||||
import com.arc.bloodarsenal.common.block.ModBlocks;
|
||||
import com.arc.bloodarsenal.common.entity.EntityBloodTNT;
|
||||
import com.arc.bloodarsenal.common.items.ModItems;
|
||||
import com.arc.bloodarsenal.common.items.sigil.SigilUtils;
|
||||
import com.arc.bloodarsenal.common.misc.VersionChecker;
|
||||
import com.arc.bloodarsenal.client.renderer.block.*;
|
||||
import com.arc.bloodarsenal.client.renderer.item.RenderBow;
|
||||
import com.arc.bloodarsenal.client.renderer.block.TilePortableAltarRenderer;
|
||||
@@ -51,11 +49,6 @@ public class ClientProxy extends CommonProxy
|
||||
@Override
|
||||
public void registerEvents()
|
||||
{
|
||||
if (BloodArsenalConfig.versionCheckingAllowed)
|
||||
{
|
||||
new VersionChecker().init();
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new SigilUtils());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.arc.bloodarsenal.common.gui.GuiHandler;
|
||||
import com.arc.bloodarsenal.common.items.ModItems;
|
||||
import com.arc.bloodarsenal.common.items.book.BloodBurnedTome;
|
||||
import com.arc.bloodarsenal.common.items.sigil.holding.AHPacketHandler;
|
||||
import com.arc.bloodarsenal.common.misc.CommandDownloadMod;
|
||||
import com.arc.bloodarsenal.common.potion.PotionBloodArsenal;
|
||||
import com.arc.bloodarsenal.common.rituals.RitualRegistry;
|
||||
import com.arc.bloodarsenal.common.thaumcraft.BloodArsenalThaumcraft;
|
||||
@@ -179,10 +178,4 @@ public class BloodArsenal
|
||||
ModBlocks.registerMultiparts();
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
event.registerServerCommand(new CommandDownloadMod());
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,6 @@ public class BloodArsenalConfig
|
||||
public static int lpMaterializerCost;
|
||||
|
||||
// Miscellaneous
|
||||
public static boolean versionCheckingAllowed;
|
||||
public static boolean isRedGood;
|
||||
public static boolean cakeIsLie;
|
||||
public static boolean isGlassDangerous;
|
||||
@@ -118,7 +117,6 @@ public class BloodArsenalConfig
|
||||
lightningSigilMultiplier = config.get(lpSettings, "Lightning Sigil cost (multiplier); Default: 1500", 1500).getInt(lightningSigilMultiplier);
|
||||
lpMaterializerCost = config.get(lpSettings, "Converts this number to 100LE (from this (SN) to 100 (LE)); Default: 150", 150).getInt(lpMaterializerCost);
|
||||
|
||||
versionCheckingAllowed = config.get(misc, "Is auto-magic version checking allowed?", false, "Allows for your version to be checked against the latest version").getBoolean();
|
||||
isRedGood = config.get(misc, "Is RED > PURPLE?", false, "Purple is always better than Red. But I won't tell you how to live your life. Even if it is incorrect.").getBoolean(isRedGood);
|
||||
cakeIsLie = config.get(misc, "The cake is a lie", false, "The cake is a lie").getBoolean(cakeIsLie);
|
||||
isGlassDangerous = config.get(misc, "Is glass dangerous?", true, "Breaking glass is dangerous unless you're a wimp").getBoolean(isGlassDangerous);
|
||||
|
||||
@@ -1,48 +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 com.arc.bloodarsenal.common.misc;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class CommandDownloadMod extends CommandBase
|
||||
{
|
||||
private static final boolean ENABLED = true;
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "bloodarsenal-download-latest";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender var1)
|
||||
{
|
||||
return "/bloodarsenal-download-latest <version>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender var1, String[] var2)
|
||||
{
|
||||
if (!ENABLED)
|
||||
var1.addChatMessage(new ChatComponentTranslation("ba.versioning.disabled").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
|
||||
else if (var2.length == 1)
|
||||
if (VersionChecker.downloadedFile)
|
||||
var1.addChatMessage(new ChatComponentTranslation("ba.versioning.downloadedAlready").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
else if (VersionChecker.startedDownload)
|
||||
var1.addChatMessage(new ChatComponentTranslation("ba.versioning.downloadingAlready").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
else new ThreadDownloadMod("BloodArsenal " + var2[0] + ".jar");
|
||||
}
|
||||
}
|
||||
@@ -1,106 +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 com.arc.bloodarsenal.common.misc;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
import java.awt.*;
|
||||
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
|
||||
{
|
||||
String fileName;
|
||||
|
||||
byte[] buffer = new byte[10240];
|
||||
|
||||
int totalBytesDownloaded;
|
||||
int bytesJustDownloaded;
|
||||
|
||||
InputStream webReader;
|
||||
|
||||
public ThreadDownloadMod(String fileName)
|
||||
{
|
||||
setName("Blood Arsenal Download File Thread");
|
||||
this.fileName = fileName;
|
||||
setDaemon(true);
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
IChatComponent component = IChatComponent.Serializer.func_150699_a(String.format(StatCollector.translateToLocal("ba.versioning.startingDownload"), fileName));
|
||||
|
||||
if (Minecraft.getMinecraft().thePlayer != null)
|
||||
{
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(component);
|
||||
}
|
||||
|
||||
VersionChecker.startedDownload = true;
|
||||
|
||||
String base = "http://minecraft.curseforge.com/mc-mods/228823-blood-magic-addon-blood-arsenal";
|
||||
URL url = new URL(base + "/files/latest");
|
||||
|
||||
try
|
||||
{
|
||||
url.openStream().close(); // Add to DL Counter
|
||||
}
|
||||
catch(IOException e) {}
|
||||
|
||||
webReader = url.openStream();
|
||||
|
||||
File dir = new File(".", "mods");
|
||||
File f = new File(dir, fileName);
|
||||
f.createNewFile();
|
||||
|
||||
FileOutputStream outputStream = new FileOutputStream(f.getAbsolutePath());
|
||||
|
||||
while ((bytesJustDownloaded = webReader.read(buffer)) > 0)
|
||||
{
|
||||
outputStream.write(buffer, 0, bytesJustDownloaded);
|
||||
buffer = new byte[10240];
|
||||
totalBytesDownloaded += bytesJustDownloaded;
|
||||
}
|
||||
|
||||
if (Minecraft.getMinecraft().thePlayer != null)
|
||||
{
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentTranslation("ba.versioning.doneDownloading", fileName).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)));
|
||||
}
|
||||
|
||||
Desktop.getDesktop().open(dir);
|
||||
VersionChecker.downloadedFile = true;
|
||||
|
||||
outputStream.close();
|
||||
webReader.close();
|
||||
finalize();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void sendError()
|
||||
{
|
||||
if (Minecraft.getMinecraft().thePlayer != null)
|
||||
{
|
||||
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentTranslation("ba.versioning.error").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +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 com.arc.bloodarsenal.common.misc;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
public class ThreadVersionChecker extends Thread
|
||||
{
|
||||
public ThreadVersionChecker()
|
||||
{
|
||||
setName("Blood Arsenal Version Checker Thread");
|
||||
setDaemon(true);
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
URL url = new URL("https://raw.githubusercontent.com/Arcaratus/BloodArsenal/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;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +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 com.arc.bloodarsenal.common.misc;
|
||||
|
||||
import com.arc.bloodarsenal.common.BloodArsenal;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
public class VersionChecker
|
||||
{
|
||||
public static boolean doneChecking = false;
|
||||
public static String onlineVersion = "";
|
||||
public static boolean triedToWarnPlayer = false;
|
||||
|
||||
public static boolean startedDownload = false;
|
||||
public static boolean downloadedFile = false;
|
||||
|
||||
public void init()
|
||||
{
|
||||
new ThreadVersionChecker();
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent event)
|
||||
{
|
||||
if (doneChecking && event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().thePlayer != null && !triedToWarnPlayer)
|
||||
{
|
||||
if (!onlineVersion.isEmpty())
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
int onlineBuild1 = Integer.parseInt(onlineVersion.substring(2, 3));
|
||||
int onlineBuild2 = Integer.parseInt(onlineVersion.substring(3));
|
||||
int clientBuild1 = BloodArsenal.VERSION.equals("@VERSION@") ? 0 : Integer.parseInt(BloodArsenal.VERSION.substring(2, 3));
|
||||
int clientBuild2 = BloodArsenal.VERSION.equals("@VERSION@") ? 0 : Integer.parseInt(BloodArsenal.VERSION.substring(3));
|
||||
|
||||
if (onlineBuild1 > clientBuild1)
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentTranslation("ba.versioning.outdated", BloodArsenal.VERSION, onlineVersion));
|
||||
|
||||
IChatComponent component = IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal("ba.versioning.updateMessage").replaceAll("%version%", onlineVersion));
|
||||
player.addChatComponentMessage(component);
|
||||
}
|
||||
else if (onlineBuild1 == clientBuild1)
|
||||
{
|
||||
if (onlineBuild2 > clientBuild2)
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentTranslation("ba.versioning.outdated", BloodArsenal.VERSION, onlineVersion));
|
||||
|
||||
IChatComponent component = IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal("ba.versioning.updateMessage").replaceAll("%version%", onlineVersion));
|
||||
player.addChatComponentMessage(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
triedToWarnPlayer = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user