Merge pull request #7 from GTNewHorizons/versioncheck

Versioncheck
This commit is contained in:
Martin Robertz authored and GitHub committed 2021-12-13 17:24:15 +01:00
commit d4aa4adcf9
9 files changed
+24 -314

No files matched your search

+15 -19
View File
@@ -3,7 +3,7 @@ buildscript {
mavenCentral()
maven {
name = "GT"
url = "http://gregtech.overminddl1.com/"
url = "https://gregtech.overminddl1.com/"
}
maven {
name = "sonatype"
@@ -14,11 +14,11 @@ buildscript {
url = "https://jitpack.io"
}
maven {
url "https://plugins.gradle.org/m2/"
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.github.GTNH2:ForgeGradle:FG_1.2-SNAPSHOT'
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
classpath 'org.ajoberstar:gradle-git:0.10.1'
classpath "de.undercouch:gradle-download-task:3.1.2"
}
@@ -51,24 +51,20 @@ if (new File(projectDir, '.git').exists()) {
repositories {
maven { //Tinker's and Mantle
name 'DVS1 Maven FS'
url 'http://dvs1.progwml6.com/files/maven'
}
maven { // the repo from which to get NEI and stuff
name 'CB Repo'
url "http://chickenbones.net/maven/"
}
maven { //WAILA
name "ProfMobius Maven FS"
url "http://mobiusstrip.eu/maven"
url 'https://dvs1.progwml6.com/files/maven'
}
maven {
name = "gt"
url = "http://gregtech.overminddl1.com/"
url = "https://gregtech.overminddl1.com/"
}
ivy {
name = "gtnh_download_source"
artifactPattern("http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]-[revision].[ext]")
}
maven {
name = "jitpack"
url = "https://jitpack.io"
}
}
minecraft {
@@ -80,13 +76,13 @@ minecraft {
}
dependencies {
compile "codechicken:CodeChickenLib:" + config.mc_version + "-" + config.ccLib_version + ":dev"
compile "codechicken:CodeChickenCore:" + config.mc_version + "-" + config.ccc_version + ":dev"
compile "codechicken:NotEnoughItems:" + config.mc_version + "-" + config.nei_version + ":dev"
compile "codechicken:ForgeMultipart:" + config.mc_version + "-" + config.forgeMultipart_version + ":dev"
compile "mcp.mobius.waila:Waila:" + config.waila_version + "_" + config.mc_version + ":dev"
compile "com.github.GTNewHorizons:NotEnoughItems:master-SNAPSHOT:dev"
compile "com.github.GTNewHorizons:ForgeMultipart:master-SNAPSHOT:dev"
compile "com.github.GTNewHorizons:waila:master-SNAPSHOT:dev"
compile("com.github.GTNewHorizons:TinkersConstruct:master-SNAPSHOT:dev") {
transitive = false
}
compile "mantle:Mantle:1.7.10-0.3.2.jenkins187:deobf"
compile "tconstruct:TConstruct:" + config.mc_version + "-" + config.tconstruct_version + ":deobf"
compile "info.amerifrance.guideapi:Guide-API:" + config.mc_version + "-" + config.guideapi_version + ":deobf"
compile "com.azanor.baubles:Baubles:1.7.10-" + config.baubles_version + ":deobf"
compile fileTree(dir: 'libs', include: '*.jar')
Vendored Regular → Executable
View File
File mode changed.
@@ -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;
@@ -88,10 +87,10 @@ public class BloodArsenalConfig
config.addCustomCategoryComment(lpSettings, "Change the LP costs for things");
config.addCustomCategoryComment(misc, "Random stuffs");
vampiricAuraID = config.get(potionId, "Vampiric Aura", 50).getInt(vampiricAuraID);
bleedingID = config.get(potionId, "Bleeding", 51).getInt(bleedingID);
swimmingID = config.get(potionId, "Swimming", 52).getInt(swimmingID);
soulBurnID = config.get(potionId, "Soul Burn", 53).getInt(soulBurnID);
vampiricAuraID = config.get(potionId, "Vampiric Aura", 120).getInt(vampiricAuraID);
bleedingID = config.get(potionId, "Bleeding", 121).getInt(bleedingID);
swimmingID = config.get(potionId, "Swimming", 122).getInt(swimmingID);
soulBurnID = config.get(potionId, "Soul Burn", 123).getInt(soulBurnID);
ritualDisabledWither = config.get(ritualBlacklist, "Ritual of Withering", false).getBoolean(ritualDisabledWither);
ritualDisabledMidas = config.get(ritualBlacklist, "Midas Touch", false).getBoolean(ritualDisabledMidas);
@@ -111,15 +110,14 @@ public class BloodArsenalConfig
bloodInfusedWoodID = config.get(modSettings, "[Tinker's Construct] Material ID for Blood Infused Wood; Default: 250", 250).getInt(bloodInfusedWoodID);
bloodInfusedIronID = config.get(modSettings, "[Tinker's Construct] Material ID for Blood Infused Iron; Default: 251", 251).getInt(bloodInfusedIronID);
sigilSwimmingCost = config.get(lpSettings, "Sigil of Swimming cost; Default: 150", 150).getInt(sigilSwimmingCost);
sigilSwimmingCost = config.get(lpSettings, "Sigil of Swimming cost; Default: 250", 250).getInt(sigilSwimmingCost);
sigilDivinityCost = config.get(lpSettings, "Sigil of Divinity cost; Default: 1000000", 1000000).getInt(sigilDivinityCost);
enderSigilOpenCost = config.get(lpSettings, "Ender Sigil cost (to open the Ender Chest); Default: 200", 200).getInt(enderSigilOpenCost);
enderSigilTeleportMultiplier = config.get(lpSettings, "Ender Sigil cost (to teleport (multiplier)); Default: 250", 250).getInt(enderSigilTeleportMultiplier);
lightningSigilMultiplier = config.get(lpSettings, "Lightning Sigil cost (multiplier); Default: 1000", 1000).getInt(lightningSigilMultiplier);
enderSigilOpenCost = config.get(lpSettings, "Ender Sigil cost (to open the Ender Chest); Default: 400", 400).getInt(enderSigilOpenCost);
enderSigilTeleportMultiplier = config.get(lpSettings, "Ender Sigil cost (to teleport (multiplier)); Default: 500", 500).getInt(enderSigilTeleportMultiplier);
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?", true, "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 incorrectly.").getBoolean(isRedGood);
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;
}
}
}