mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
New Update Checker System & New Versioning! o/
This commit is contained in:
parent
723b44833f
commit
b1d070595b
9 changed files with 55 additions and 73 deletions
|
@ -18,7 +18,7 @@ buildscript {
|
|||
apply plugin: 'forge'
|
||||
apply plugin: 'maven'
|
||||
|
||||
version = "1.7.10-0.0.9.4"
|
||||
version = "1.7.10-r1"
|
||||
group = "ellpeck.actuallyadditions"
|
||||
archivesBaseName = "ActuallyAdditions"
|
||||
|
||||
|
|
|
@ -99,11 +99,6 @@ public class InitBlocks{
|
|||
|
||||
public static Block blockLaserRelay;
|
||||
|
||||
//TODO: Plan for Laser Power Transmitters:
|
||||
//TODO: When there is a block in the way, they don't render their laser and don't transmit
|
||||
//TODO: They stay connected and can be connected together even though they're blocked
|
||||
//TODO: If blocked, they display the block coords blocking them on right-click
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Blocks...");
|
||||
|
||||
|
|
|
@ -16,10 +16,7 @@ import ellpeck.actuallyadditions.booklet.page.BookletPage;
|
|||
import ellpeck.actuallyadditions.config.GuiConfiguration;
|
||||
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
||||
import ellpeck.actuallyadditions.update.UpdateChecker;
|
||||
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import ellpeck.actuallyadditions.util.Util;
|
||||
import ellpeck.actuallyadditions.util.*;
|
||||
import ellpeck.actuallyadditions.util.playerdata.PersistentClientData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
@ -27,6 +24,7 @@ import net.minecraft.client.gui.GuiScreen;
|
|||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -149,21 +147,17 @@ public class GuiBooklet extends GuiScreen{
|
|||
}
|
||||
//Update Checker Hover Text
|
||||
if(x >= this.guiLeft-11 && x <= this.guiLeft-11+10 && y >= this.guiTop-11 && y <= this.guiTop-11+10){
|
||||
if(UpdateChecker.doneChecking){
|
||||
ArrayList list = new ArrayList();
|
||||
if(UpdateChecker.checkFailed){
|
||||
list.add(EnumChatFormatting.DARK_RED+"The Update Check failed!");
|
||||
list.add("Check your log for more Information!");
|
||||
list.add(IChatComponent.Serializer.func_150699_a(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.failed")).getFormattedText());
|
||||
}
|
||||
else if(UpdateChecker.updateVersion > UpdateChecker.clientVersion){
|
||||
list.add(EnumChatFormatting.GOLD+"There is an Update available!");
|
||||
list.add(EnumChatFormatting.ITALIC+"You have: "+ModUtil.VERSION+", Newest: "+UpdateChecker.updateVersionS);
|
||||
list.addAll(this.fontRendererObj.listFormattedStringToWidth(EnumChatFormatting.ITALIC+"Updates include: "+UpdateChecker.changelog, TOOLTIP_SPLIT_LENGTH));
|
||||
list.add(EnumChatFormatting.GRAY+"Click this button to visit the download page!");
|
||||
else if(UpdateChecker.needsUpdateNotify){
|
||||
list.add(IChatComponent.Serializer.func_150699_a(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.generic")).getFormattedText());
|
||||
list.add(IChatComponent.Serializer.func_150699_a(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".update.versionCompare", ModUtil.VERSION, UpdateChecker.updateVersion)).getFormattedText());
|
||||
list.add(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.buttonOptions"));
|
||||
}
|
||||
this.func_146283_a(list, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
this.fontRendererObj.setUnicodeFlag(unicodeBefore);
|
||||
|
||||
|
@ -219,11 +213,16 @@ public class GuiBooklet extends GuiScreen{
|
|||
}
|
||||
}
|
||||
else if(button == this.buttonUpdate){
|
||||
if(UpdateChecker.doneChecking && UpdateChecker.updateVersion > UpdateChecker.clientVersion){
|
||||
if(UpdateChecker.needsUpdateNotify){
|
||||
try{
|
||||
if(Desktop.isDesktopSupported()){
|
||||
if(KeyUtil.isShiftPressed()){
|
||||
Desktop.getDesktop().browse(new URI(UpdateChecker.DOWNLOAD_LINK));
|
||||
}
|
||||
else{
|
||||
Desktop.getDesktop().browse(new URI(UpdateChecker.CHANGELOG_LINK));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.error("Something bad happened when trying to open a URL!", e);
|
||||
|
@ -335,7 +334,7 @@ public class GuiBooklet extends GuiScreen{
|
|||
this.buttonList.add(this.buttonPreviouslyOpenedGui);
|
||||
|
||||
this.buttonUpdate = new TexturedButton(4, this.guiLeft-11, this.guiTop-11, 245, 0, 11, 11);
|
||||
this.buttonUpdate.visible = UpdateChecker.doneChecking && UpdateChecker.updateVersion > UpdateChecker.clientVersion;
|
||||
this.buttonUpdate.visible = UpdateChecker.needsUpdateNotify;
|
||||
this.buttonList.add(this.buttonUpdate);
|
||||
|
||||
this.buttonTwitter = new TexturedButton(5, this.guiLeft, this.guiTop, 213, 0, 8, 8);
|
||||
|
@ -385,7 +384,7 @@ public class GuiBooklet extends GuiScreen{
|
|||
this.currentPage.updateScreen(this.ticksElapsed);
|
||||
}
|
||||
|
||||
boolean buttonThere = UpdateChecker.doneChecking && UpdateChecker.updateVersion > UpdateChecker.clientVersion;
|
||||
boolean buttonThere = UpdateChecker.needsUpdateNotify;
|
||||
this.buttonUpdate.visible = buttonThere;
|
||||
if(buttonThere){
|
||||
if(this.ticksElapsed%8 == 0){
|
||||
|
|
|
@ -49,7 +49,6 @@ public class GuiOreMagnet extends GuiContainer{
|
|||
if(x >= guiLeft+117 && y >= guiTop+6 && x <= guiLeft+132 && y <= guiTop+88){
|
||||
this.func_146283_a(Collections.singletonList(text2), x, y);
|
||||
}
|
||||
//TODO Upgrade Slot Joke
|
||||
if(x >= guiLeft+70 && y >= guiTop+42 && x <= guiLeft+70+18 && y <= guiTop+42+18){
|
||||
this.func_146283_a(Arrays.asList("@SuppressWarnings(\"unused\")", "This slot is currently unused. Ignore it."), x, y);
|
||||
}
|
||||
|
|
|
@ -30,18 +30,22 @@ public class ThreadUpdateChecker extends Thread{
|
|||
try{
|
||||
URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/newestVersion.txt");
|
||||
BufferedReader newestReader = new BufferedReader(new InputStreamReader(newestURL.openStream()));
|
||||
UpdateChecker.updateVersionS = newestReader.readLine();
|
||||
UpdateChecker.updateVersion = newestReader.readLine();
|
||||
newestReader.close();
|
||||
|
||||
URL changeURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/changelog.txt");
|
||||
BufferedReader changeReader = new BufferedReader(new InputStreamReader(changeURL.openStream()));
|
||||
UpdateChecker.changelog = changeReader.readLine();
|
||||
changeReader.close();
|
||||
//Legacy Versions
|
||||
if(!ModUtil.VERSION.contains("r")){
|
||||
UpdateChecker.needsUpdateNotify = true;
|
||||
}
|
||||
else{
|
||||
int updateVersion = Integer.parseInt(UpdateChecker.updateVersion.replace("-", "").replace(".", "").replace("r", ""));
|
||||
int clientVersion = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", "").replace("r", ""));
|
||||
if(updateVersion > clientVersion){
|
||||
UpdateChecker.needsUpdateNotify = true;
|
||||
}
|
||||
}
|
||||
|
||||
ModUtil.LOGGER.info("Update Check done!");
|
||||
|
||||
UpdateChecker.updateVersion = Integer.parseInt(UpdateChecker.updateVersionS.replace("-", "").replace(".", ""));
|
||||
UpdateChecker.clientVersion = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", ""));
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.error("Update Check failed!", e);
|
||||
|
@ -49,18 +53,15 @@ public class ThreadUpdateChecker extends Thread{
|
|||
}
|
||||
|
||||
if(!UpdateChecker.checkFailed){
|
||||
if(UpdateChecker.updateVersion > UpdateChecker.clientVersion){
|
||||
ModUtil.LOGGER.info("There is an Update for "+ModUtil.MOD_ID+" available!");
|
||||
ModUtil.LOGGER.info("The installed Version is "+ModUtil.VERSION+", but the newest Version is "+UpdateChecker.updateVersionS+"!");
|
||||
ModUtil.LOGGER.info("The Changes are: "+UpdateChecker.changelog);
|
||||
ModUtil.LOGGER.info("Download the newest Version at "+UpdateChecker.DOWNLOAD_LINK);
|
||||
if(UpdateChecker.needsUpdateNotify){
|
||||
ModUtil.LOGGER.info("There is an Update for "+ModUtil.NAME+" available!");
|
||||
ModUtil.LOGGER.info("Current Version: "+ModUtil.VERSION+", newest Version: "+UpdateChecker.updateVersion+"!");
|
||||
ModUtil.LOGGER.info("View the Changelog at "+UpdateChecker.CHANGELOG_LINK);
|
||||
ModUtil.LOGGER.info("Download at "+UpdateChecker.DOWNLOAD_LINK);
|
||||
}
|
||||
else{
|
||||
ModUtil.LOGGER.info("There is no new Update for "+ModUtil.MOD_ID+" available!");
|
||||
ModUtil.LOGGER.info("That's cool. You're really up to date, you have all of the latest awesome Features!");
|
||||
ModUtil.LOGGER.info(ModUtil.NAME+" is up to date!");
|
||||
}
|
||||
}
|
||||
|
||||
UpdateChecker.doneChecking = true;
|
||||
}
|
||||
}
|
|
@ -17,12 +17,10 @@ import ellpeck.actuallyadditions.util.Util;
|
|||
public class UpdateChecker{
|
||||
|
||||
public static final String DOWNLOAD_LINK = "http://minecraft.curseforge.com/mc-mods/228404-actually-additions/files";
|
||||
public static boolean doneChecking = false;
|
||||
public static boolean checkFailed = false;
|
||||
public static String updateVersionS;
|
||||
public static int updateVersion;
|
||||
public static int clientVersion;
|
||||
public static String changelog;
|
||||
public static final String CHANGELOG_LINK = "https://github.com/Ellpeck/ActuallyAdditions/blob/master/update/changelog.md";
|
||||
public static boolean checkFailed;
|
||||
public static boolean needsUpdateNotify;
|
||||
public static String updateVersion;
|
||||
|
||||
public void init(){
|
||||
if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()){
|
||||
|
|
|
@ -16,7 +16,6 @@ import ellpeck.actuallyadditions.util.ModUtil;
|
|||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public class UpdateCheckerClientNotifier{
|
||||
|
@ -26,24 +25,15 @@ public class UpdateCheckerClientNotifier{
|
|||
@SubscribeEvent(receiveCanceled = true)
|
||||
public void onTick(TickEvent.ClientTickEvent event){
|
||||
//Don't notify directly to prevent the Message getting lost in Spam on World Joining
|
||||
if(Minecraft.getSystemTime()%300 == 0 && !notified && UpdateChecker.doneChecking && Minecraft.getMinecraft().thePlayer != null){
|
||||
if(Minecraft.getSystemTime()%300 == 0 && !notified && Minecraft.getMinecraft().thePlayer != null){
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if(UpdateChecker.checkFailed){
|
||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.failed.desc")));
|
||||
}
|
||||
else{
|
||||
if(UpdateChecker.updateVersion > UpdateChecker.clientVersion){
|
||||
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.changelog.desc";
|
||||
String notice4 = "info."+ModUtil.MOD_ID_LOWER+".update.download.desc";
|
||||
player.addChatComponentMessage(new ChatComponentText(""));
|
||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StringUtil.localize(notice1)));
|
||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StringUtil.localizeFormatted(notice2, ModUtil.VERSION, UpdateChecker.updateVersionS)));
|
||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localizeFormatted(notice3, UpdateChecker.changelog)));
|
||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StringUtil.localizeFormatted(notice4, UpdateChecker.DOWNLOAD_LINK)));
|
||||
player.addChatComponentMessage(new ChatComponentText(""));
|
||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.failed")));
|
||||
}
|
||||
else if(UpdateChecker.needsUpdateNotify){
|
||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.generic")));
|
||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".update.versionCompare", ModUtil.VERSION, UpdateChecker.updateVersion)));
|
||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK)));
|
||||
}
|
||||
notified = true;
|
||||
}
|
||||
|
|
|
@ -363,11 +363,11 @@ container.actuallyadditions.directionalBreaker.name=Long-Range Breaker
|
|||
container.actuallyadditions.rangedCollector.name=Ranged Collector
|
||||
|
||||
#Update Information
|
||||
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!"}]}}}]
|
||||
info.actuallyadditions.update.failed.desc=[{"text":"The Update Check for "},{"text":"Actually Additions ","color":"dark_green","bold":"true"},{"text":"failed! Check your Internet Connection and the Logs for more Info!","color":"none"}]
|
||||
info.actuallyadditions.update.changelog.desc=Updates: %s
|
||||
info.actuallyadditions.update.generic=[{"text":"There is an Update for "},{"text":"Actually Additions ","color":"dark_green"},{"text":"available!","color":"none"}]
|
||||
info.actuallyadditions.update.versionCompare=[{"text":"Current Version: "},{"text":"%s","color":"dark_red"},{"text":", newest Version: ","color":"none"},{"text":"%s","color":"dark_green"}]
|
||||
info.actuallyadditions.update.buttons=[{"text":"["},{"text":"Click for Changelog","color":"green","clickEvent":{"action":"open_url","value":"%s"}},{"text":"] [","color":"none"},{"text":"Click for Download","color":"green","clickEvent":{"action":"open_url","value":"%s"}},{"text":"]","color":"none"}]
|
||||
info.actuallyadditions.update.buttonOptions=Click for Changelog, Shift-Click for Download!
|
||||
info.actuallyadditions.update.failed=[{"text":"The Update Check for "},{"text":"Actually Additions ","color":"dark_green"},{"text":"failed! Check Logs for more Info!","color":"none"}]
|
||||
|
||||
#Achievements
|
||||
achievement.actuallyadditions.pickUpSolidXP=Square and yummy!
|
||||
|
|
|
@ -1 +1 @@
|
|||
1.7.10-r1
|
||||
1.7.10-0.0.9.4
|
Loading…
Reference in a new issue