2015-09-02 20:06:34 +02:00
|
|
|
/*
|
2015-12-30 22:02:15 +01:00
|
|
|
* This file ("UpdateCheckerClientNotificationEvent.java") is part of the Actually Additions Mod for Minecraft.
|
2015-09-02 20:06:34 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-01-03 16:05:51 +01:00
|
|
|
* http://ellpeck.de/actaddlicense/
|
2015-09-02 20:06:34 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-01-03 16:05:51 +01:00
|
|
|
* © 2016 Ellpeck
|
2015-09-02 20:06:34 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.update;
|
2015-09-02 20:06:34 +02:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2015-09-02 20:06:34 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.util.IChatComponent;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
|
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
2015-09-02 20:06:34 +02:00
|
|
|
|
2015-11-23 19:17:17 +01:00
|
|
|
public class UpdateCheckerClientNotificationEvent{
|
2015-09-02 20:06:34 +02:00
|
|
|
|
|
|
|
private static boolean notified = false;
|
2015-11-21 18:04:26 +01:00
|
|
|
private static int ticksElapsedBeforeInfo;
|
2015-09-02 20:06:34 +02:00
|
|
|
|
|
|
|
@SubscribeEvent(receiveCanceled = true)
|
|
|
|
public void onTick(TickEvent.ClientTickEvent event){
|
|
|
|
//Don't notify directly to prevent the Message getting lost in Spam on World Joining
|
2015-11-21 18:04:26 +01:00
|
|
|
if(!notified && Minecraft.getMinecraft().thePlayer != null){
|
|
|
|
ticksElapsedBeforeInfo++;
|
|
|
|
if(ticksElapsedBeforeInfo >= 800){
|
|
|
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
|
|
|
if(UpdateChecker.checkFailed){
|
2016-01-07 23:42:42 +01:00
|
|
|
player.addChatComponentMessage(IChatComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.failed")));
|
2015-12-13 22:57:59 +01:00
|
|
|
notified = true;
|
2015-11-21 18:04:26 +01:00
|
|
|
}
|
|
|
|
else if(UpdateChecker.needsUpdateNotify){
|
2016-01-07 23:42:42 +01:00
|
|
|
player.addChatComponentMessage(IChatComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ModUtil.MOD_ID_LOWER+".update.generic")));
|
2016-01-10 21:00:12 +01:00
|
|
|
player.addChatComponentMessage(IChatComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".update.versionCompare", ModUtil.VERSION, UpdateChecker.updateVersionString)));
|
2016-01-07 23:42:42 +01:00
|
|
|
player.addChatComponentMessage(IChatComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ModUtil.MOD_ID_LOWER+".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK)));
|
2015-12-13 22:57:59 +01:00
|
|
|
notified = true;
|
2015-11-21 18:04:26 +01:00
|
|
|
}
|
|
|
|
ticksElapsedBeforeInfo = 0;
|
2015-09-02 20:06:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|