mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Changed up the Update Checker. Awesome.
This commit is contained in:
parent
0d3ab98e44
commit
cc17a27b52
4 changed files with 91 additions and 65 deletions
|
@ -59,7 +59,6 @@ public class BlockPhantomface extends BlockContainerBase implements INameableIte
|
||||||
TileEntity tile = world.getTileEntity(x, y, z);
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
if(tile instanceof TileEntityPhantomface){
|
if(tile instanceof TileEntityPhantomface){
|
||||||
player.addChatComponentMessage(new ChatComponentText(""));
|
|
||||||
TileEntityPhantomface phantom = (TileEntityPhantomface)tile;
|
TileEntityPhantomface phantom = (TileEntityPhantomface)tile;
|
||||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
||||||
if(phantom.hasBoundTile()){
|
if(phantom.hasBoundTile()){
|
||||||
|
@ -70,12 +69,10 @@ public class BlockPhantomface extends BlockContainerBase implements INameableIte
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
|
||||||
}
|
}
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
||||||
player.addChatComponentMessage(new ChatComponentText(""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(tile instanceof TileEntityPhantomPlacer){
|
else if(tile instanceof TileEntityPhantomPlacer){
|
||||||
if(player.isSneaking()){
|
if(player.isSneaking()){
|
||||||
player.addChatComponentMessage(new ChatComponentText(""));
|
|
||||||
TileEntityPhantomPlacer phantom = (TileEntityPhantomPlacer)tile;
|
TileEntityPhantomPlacer phantom = (TileEntityPhantomPlacer)tile;
|
||||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
||||||
if(phantom.hasBoundPosition()){
|
if(phantom.hasBoundPosition()){
|
||||||
|
@ -86,7 +83,6 @@ public class BlockPhantomface extends BlockContainerBase implements INameableIte
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
|
||||||
}
|
}
|
||||||
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
||||||
player.addChatComponentMessage(new ChatComponentText(""));
|
|
||||||
}
|
}
|
||||||
else player.openGui(ActuallyAdditions.instance, GuiHandler.PHANTOM_PLACER_ID, world, x, y, z);
|
else player.openGui(ActuallyAdditions.instance, GuiHandler.PHANTOM_PLACER_ID, world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class WorldDecorationEvent{
|
||||||
int genX = event.chunkX+event.rand.nextInt(16)+8;
|
int genX = event.chunkX+event.rand.nextInt(16)+8;
|
||||||
int genZ = event.chunkZ+event.rand.nextInt(16)+8;
|
int genZ = event.chunkZ+event.rand.nextInt(16)+8;
|
||||||
int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ)-1;
|
int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ)-1;
|
||||||
|
|
||||||
if(event.world.getBlock(genX, genY, genZ).getMaterial() == blockBelow){
|
if(event.world.getBlock(genX, genY, genZ).getMaterial() == blockBelow){
|
||||||
event.world.setBlock(genX, genY+1, genZ, plant, meta, 2);
|
event.world.setBlock(genX, genY+1, genZ, plant, meta, 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package ellpeck.actuallyadditions.update;
|
||||||
|
|
||||||
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class ThreadUpdateChecker extends Thread{
|
||||||
|
|
||||||
|
public ThreadUpdateChecker(){
|
||||||
|
this.setName(ModUtil.MOD_ID + " Update Checker");
|
||||||
|
this.setDaemon(true);
|
||||||
|
this.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(){
|
||||||
|
ModUtil.LOGGER.info("Starting Update Check...");
|
||||||
|
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();
|
||||||
|
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();
|
||||||
|
|
||||||
|
ModUtil.LOGGER.info("Update Check done!");
|
||||||
|
}
|
||||||
|
catch(Exception e){
|
||||||
|
this.checkFailed(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!UpdateChecker.checkFailed){
|
||||||
|
try{
|
||||||
|
UpdateChecker.updateVersion = Integer.parseInt(UpdateChecker.updateVersionS.replace("-", "").replace(".", ""));
|
||||||
|
UpdateChecker.clientVersion = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", ""));
|
||||||
|
}
|
||||||
|
catch(Exception e){
|
||||||
|
this.checkFailed(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
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!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateChecker.doneChecking = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkFailed(Exception e){
|
||||||
|
UpdateChecker.checkFailed = true;
|
||||||
|
ModUtil.LOGGER.error("Update Check failed!", e);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,86 +10,48 @@ import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
public class UpdateChecker{
|
public class UpdateChecker{
|
||||||
|
|
||||||
public boolean doneChecking = false;
|
public static boolean doneChecking = false;
|
||||||
public boolean checkFailed = false;
|
public static boolean checkFailed = false;
|
||||||
public boolean notified = false;
|
private static boolean notified = false;
|
||||||
public String onlineVersion;
|
public static String updateVersionS;
|
||||||
public String changelog;
|
public static int updateVersion;
|
||||||
|
public static int clientVersion;
|
||||||
|
public static String changelog;
|
||||||
|
|
||||||
|
public static final String DOWNLOAD_LINK = "http://minecraft.curseforge.com/mc-mods/228404-actually-additions/files";
|
||||||
|
|
||||||
public void init(){
|
public void init(){
|
||||||
ModUtil.LOGGER.info("Initializing Update Checker...");
|
ModUtil.LOGGER.info("Initializing Update Checker...");
|
||||||
Util.registerEvent(this);
|
Util.registerEvent(this);
|
||||||
new UpdateCheckThread();
|
new ThreadUpdateChecker();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent(receiveCanceled = true)
|
@SubscribeEvent(receiveCanceled = true)
|
||||||
public void onTick(TickEvent.ClientTickEvent event){
|
public void onTick(TickEvent.ClientTickEvent event){
|
||||||
if(doneChecking && event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().thePlayer != null && !notified){
|
if(!notified && doneChecking && event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().thePlayer != null){
|
||||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
if(checkFailed){
|
if(checkFailed){
|
||||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".update.failed.desc")));
|
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".update.failed.desc")));
|
||||||
}
|
}
|
||||||
else if(onlineVersion.length() > 0){
|
else{
|
||||||
try{
|
if(updateVersion > clientVersion){
|
||||||
int update = Integer.parseInt(onlineVersion.replace("-", "").replace(".", ""));
|
String notice1 = "info."+ModUtil.MOD_ID_LOWER+".update.generic.desc";
|
||||||
int client = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", ""));
|
String notice2 = "info."+ModUtil.MOD_ID_LOWER+".update.versionComp.desc";
|
||||||
|
String notice3 = "info."+ModUtil.MOD_ID_LOWER+".update.changelog.desc";
|
||||||
if(update > client){
|
String notice4 = "info."+ModUtil.MOD_ID_LOWER+".update.download.desc";
|
||||||
String notice1 = "info."+ModUtil.MOD_ID_LOWER+".update.generic.desc";
|
player.addChatComponentMessage(new ChatComponentText(""));
|
||||||
String notice2 = "info."+ModUtil.MOD_ID_LOWER+".update.versionComp.desc";
|
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal(notice1)));
|
||||||
String notice3 = "info."+ModUtil.MOD_ID_LOWER+".update.changelog.desc";
|
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice2, ModUtil.VERSION, updateVersionS)));
|
||||||
String notice4 = "info."+ModUtil.MOD_ID_LOWER+".update.download.desc";
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(notice3, changelog)));
|
||||||
player.addChatComponentMessage(new ChatComponentText(""));
|
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice4, DOWNLOAD_LINK)));
|
||||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal(notice1)));
|
player.addChatComponentMessage(new ChatComponentText(""));
|
||||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice2, ModUtil.VERSION, onlineVersion)));
|
|
||||||
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(notice3, changelog)));
|
|
||||||
player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice4, "http://minecraft.curseforge.com/mc-mods/228404-actually-additions/files")));
|
|
||||||
player.addChatComponentMessage(new ChatComponentText(""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception e){
|
|
||||||
ModUtil.LOGGER.error("Sending the Update Check Information to the Chat failed!", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notified = true;
|
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(){
|
|
||||||
ModUtil.LOGGER.info("Starting Update Check...");
|
|
||||||
try{
|
|
||||||
URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/newestVersion.txt");
|
|
||||||
BufferedReader newestReader = new BufferedReader(new InputStreamReader(newestURL.openStream()));
|
|
||||||
onlineVersion = 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()));
|
|
||||||
changelog = changeReader.readLine();
|
|
||||||
changeReader.close();
|
|
||||||
|
|
||||||
ModUtil.LOGGER.info("Update Check done!");
|
|
||||||
}
|
|
||||||
catch(Exception e){
|
|
||||||
checkFailed = true;
|
|
||||||
ModUtil.LOGGER.error("Update Check failed!", e);
|
|
||||||
}
|
|
||||||
doneChecking = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue