Update Checker!

This commit is contained in:
Ellpeck 2015-04-26 21:09:25 +02:00
parent 835c682246
commit 9110724bec
8 changed files with 96 additions and 4 deletions

View file

@ -61,7 +61,7 @@ processResources{
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info' include 'mcmod.info'
expand 'version':project.version, 'mcversion':project.minecraft.version expand 'update':project.version, 'mcversion':project.minecraft.version
} }
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {

View file

@ -1 +1 @@
1.7.10-5.5.5 1.7.10-0.0.4

View file

@ -10,7 +10,8 @@ public enum ConfigCategories{
MACHINE_VALUES("machine values"), MACHINE_VALUES("machine values"),
MOB_DROPS("mob drops"), MOB_DROPS("mob drops"),
WORLD_GEN("world gen"), WORLD_GEN("world gen"),
POTION_RING_CRAFTING("ring crafting"); POTION_RING_CRAFTING("ring crafting"),
OTHER("other");
public final String name; public final String name;

View file

@ -18,7 +18,9 @@ public enum ConfigBoolValues{
HEART_DROP("Heart Parts", ConfigCategories.MOB_DROPS, false, "If the Heart Parts drop from Mobs"), HEART_DROP("Heart Parts", ConfigCategories.MOB_DROPS, false, "If the Heart Parts drop from Mobs"),
SUBSTANCE_DROP("Unknown Substance", ConfigCategories.MOB_DROPS, false, "If the Unknown Substance drops from Mobs"), SUBSTANCE_DROP("Unknown Substance", ConfigCategories.MOB_DROPS, false, "If the Unknown Substance drops from Mobs"),
PEARL_SHARD_DROP("Ender Pearl Shard", ConfigCategories.MOB_DROPS, true, "If the Ender Pearl Shard drops from Mobs"), PEARL_SHARD_DROP("Ender Pearl Shard", ConfigCategories.MOB_DROPS, true, "If the Ender Pearl Shard drops from Mobs"),
EMERALD_SHARD_CROP("Emerald Shard", ConfigCategories.MOB_DROPS, true, "If the Emerald Shard drops from Mobs"); EMERALD_SHARD_CROP("Emerald Shard", ConfigCategories.MOB_DROPS, true, "If the Emerald Shard drops from Mobs"),
DO_UPDATE_CHECK("Do Update Check", ConfigCategories.OTHER, true, "If Actually Additions should check for an Update on joining a World");
public final String name; public final String name;
public final String category; public final String category;

View file

@ -5,11 +5,13 @@ import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.common.registry.VillagerRegistry;
import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.blocks.render.*; import ellpeck.actuallyadditions.blocks.render.*;
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues;
import ellpeck.actuallyadditions.event.RenderPlayerEventAA; import ellpeck.actuallyadditions.event.RenderPlayerEventAA;
import ellpeck.actuallyadditions.tile.TileEntityCompost; import ellpeck.actuallyadditions.tile.TileEntityCompost;
import ellpeck.actuallyadditions.tile.TileEntityFishingNet; import ellpeck.actuallyadditions.tile.TileEntityFishingNet;
import ellpeck.actuallyadditions.tile.TileEntityFurnaceSolar; import ellpeck.actuallyadditions.tile.TileEntityFurnaceSolar;
import ellpeck.actuallyadditions.update.UpdateChecker;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.Util;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -40,6 +42,7 @@ public class ClientProxy implements IProxy{
VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png")); VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png"));
Util.registerEvent(new RenderPlayerEventAA()); Util.registerEvent(new RenderPlayerEventAA());
if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()) new UpdateChecker().init();
} }
@Override @Override

View file

@ -0,0 +1,76 @@
package ellpeck.actuallyadditions.update;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.StatCollector;
import org.apache.logging.log4j.Level;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
public class UpdateChecker{
public boolean doneChecking = false;
public boolean notified = false;
public String onlineVersion;
public void init(){
Util.logInfo("Initializing Update Checker...");
Util.registerEvent(this);
new UpdateCheckThread();
}
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event){
if(doneChecking && event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().thePlayer != null && !notified){
if(onlineVersion.length() > 0){
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
int update = Integer.parseInt(onlineVersion.replace("-", "").replace(".", ""));
int client = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", ""));
if(update > client){
String notice1 = "info." + ModUtil.MOD_ID_LOWER + ".update.generic.desc";
String notice2 = "info." + ModUtil.MOD_ID_LOWER + ".update.versionComp.desc";
String notice3 = "info." + ModUtil.MOD_ID_LOWER + ".update.download.desc";
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal(notice1)));
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice2, ModUtil.VERSION, this.onlineVersion)));
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice3, "http://minecraft.curseforge.com/mc-mods/228404-actually-additions/files")));
}
}
notified = true;
}
}
public class UpdateCheckThread extends Thread{
public UpdateCheckThread(){
this.setName(ModUtil.MOD_ID + " Update Checker");
this.setDaemon(true);
this.start();
}
@Override
public void run(){
Util.logInfo("Starting Update Check...");
try{
URL url = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/newestVersion.txt");
BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream()));
onlineVersion = r.readLine();
r.close();
}
catch(Exception e){
ModUtil.AA_LOGGER.log(Level.ERROR, "Update Check failed!");
e.printStackTrace();
}
doneChecking = true;
}
}
}

View file

@ -40,6 +40,10 @@ public class WailaDataProvider implements IWailaDataProvider{
if(meta <= tile.amountNeededToConvert){ if(meta <= tile.amountNeededToConvert){
String tip1 = StatCollector.translateToLocal(WAILA_PRE_LANG + "compostAmount" + ".name") + ": " + meta + "/" + tile.amountNeededToConvert; String tip1 = StatCollector.translateToLocal(WAILA_PRE_LANG + "compostAmount" + ".name") + ": " + meta + "/" + tile.amountNeededToConvert;
currentTip.add(tip1); currentTip.add(tip1);
if(meta == tile.amountNeededToConvert){
currentTip.add(StatCollector.translateToLocal(WAILA_PRE_LANG + "compostConverting" + ".name"));
}
} }
if(meta == tile.amountNeededToConvert+1){ if(meta == tile.amountNeededToConvert+1){
@ -55,6 +59,7 @@ public class WailaDataProvider implements IWailaDataProvider{
return currentTip; return currentTip;
} }
@Override
public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z){ public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z){
return tag; return tag;
} }

View file

@ -283,6 +283,11 @@ container.actuallyadditions.nei.crushing.name=Crusher
gui.actuallyadditions.waila.compostAmount.name=Amount of Mashed Food gui.actuallyadditions.waila.compostAmount.name=Amount of Mashed Food
gui.actuallyadditions.waila.compostDone.name=Done! gui.actuallyadditions.waila.compostDone.name=Done!
gui.actuallyadditions.waila.compostConverting.name=Converting...
info.actuallyadditions.update.generic.desc=[{"text":"There is an "},{"text":"Update ","bold":"true"},{"text":"for ","bold":"false"},{"text":"Actually Additions ","color":"dark_green","bold":"true"},{"text":"available!","color":"none","bold":"false"}]
info.actuallyadditions.update.versionComp.desc=[{"text":"You have Version "},{"text":"%s","color":"dark_red","italic":"false"},{"text":", the newest one is ","color":"none","italic":"false"},{"text":"%s","color":"dark_green","underlined":"false"},{"text":"!","color":"none","underlined":"false"}]
info.actuallyadditions.update.download.desc=[{"text":"Download the newest Version "},{"text":"here! (Click me!)","color":"dark_green","underlined":"true","clickEvent":{"action":"open_url","value":"%s"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Click here to open your Browser and download the newest Version!"}]}}}]
achievement.actuallyadditions.pickUpSolidXP=Hard and Rich and Stuff achievement.actuallyadditions.pickUpSolidXP=Hard and Rich and Stuff
achievement.actuallyadditions.pickUpSolidXP.desc=Pick up some Solidified Experience achievement.actuallyadditions.pickUpSolidXP.desc=Pick up some Solidified Experience