2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("UpdateChecker.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.update;
|
2015-04-26 21:09:25 +02:00
|
|
|
|
2018-05-10 11:38:58 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
2016-07-03 20:57:00 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.client.resources.language.I18n;
|
|
|
|
import net.minecraft.network.chat.Component;
|
|
|
|
import net.minecraft.world.entity.player.Player;
|
2024-03-04 20:21:48 +01:00
|
|
|
import net.neoforged.api.distmarker.Dist;
|
|
|
|
import net.neoforged.api.distmarker.OnlyIn;
|
|
|
|
import net.neoforged.bus.api.SubscribeEvent;
|
|
|
|
import net.neoforged.neoforge.common.NeoForge;
|
|
|
|
import net.neoforged.neoforge.event.TickEvent;
|
2015-04-26 21:09:25 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class UpdateChecker {
|
2015-04-26 21:09:25 +02:00
|
|
|
|
2016-02-03 18:16:24 +01:00
|
|
|
public static final String DOWNLOAD_LINK = "http://ellpeck.de/actadddownload";
|
2016-05-16 22:52:27 +02:00
|
|
|
public static final String CHANGELOG_LINK = "http://ellpeck.de/actaddchangelog";
|
2015-10-28 18:28:30 +01:00
|
|
|
public static boolean checkFailed;
|
|
|
|
public static boolean needsUpdateNotify;
|
2016-01-10 20:59:13 +01:00
|
|
|
public static int updateVersionInt;
|
|
|
|
public static String updateVersionString;
|
2018-07-11 01:10:26 +02:00
|
|
|
public static boolean threadFinished = false;
|
2016-07-03 20:57:00 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public UpdateChecker() {
|
2021-11-21 22:03:07 +01:00
|
|
|
// if (CommonConfig.OTHER.DO_UPDATE_CHECK.get() && !Util.isDevVersion()) {
|
|
|
|
// ActuallyAdditions.LOGGER.info("Initializing Update Checker...");
|
|
|
|
// new ThreadUpdateChecker();
|
|
|
|
// MinecraftForge.EVENT_BUS.register(this);
|
|
|
|
// }
|
2016-07-03 20:57:00 +02:00
|
|
|
}
|
|
|
|
|
2021-02-26 22:15:48 +01:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2016-07-03 20:57:00 +02:00
|
|
|
@SubscribeEvent(receiveCanceled = true)
|
2019-05-02 09:10:29 +02:00
|
|
|
public void onTick(TickEvent.ClientTickEvent event) {
|
2021-02-26 22:15:48 +01:00
|
|
|
if (Minecraft.getInstance().player != null) {
|
2024-03-02 21:23:08 +01:00
|
|
|
Player player = Minecraft.getInstance().player;
|
2019-05-02 09:10:29 +02:00
|
|
|
if (UpdateChecker.checkFailed) {
|
2024-03-02 21:23:08 +01:00
|
|
|
player.displayClientMessage(Component.Serializer.fromJson(I18n.get("info." + ActuallyAdditions.MODID + ".update.failed")), false);
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (UpdateChecker.needsUpdateNotify) {
|
2024-03-02 21:23:08 +01:00
|
|
|
player.displayClientMessage(Component.Serializer.fromJson(I18n.get("info." + ActuallyAdditions.MODID + ".update.generic")), false);
|
|
|
|
player.displayClientMessage(Component.Serializer.fromJson(I18n.get("info." + ActuallyAdditions.MODID + ".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString)), false);
|
|
|
|
player.displayClientMessage(Component.Serializer.fromJson(I18n.get("info." + ActuallyAdditions.MODID + ".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK)), false);
|
2018-07-11 01:10:26 +02:00
|
|
|
}
|
2021-02-26 22:15:48 +01:00
|
|
|
if (threadFinished) {
|
2024-03-04 20:21:48 +01:00
|
|
|
NeoForge.EVENT_BUS.unregister(this);
|
2021-02-26 22:15:48 +01:00
|
|
|
}
|
2015-09-29 17:08:47 +02:00
|
|
|
}
|
2015-04-26 21:09:25 +02:00
|
|
|
}
|
2021-02-26 22:15:48 +01:00
|
|
|
}
|