|
3 | 3 | import com.mojang.blaze3d.systems.RenderSystem; |
4 | 4 | import io.github.codeutilities.CodeUtilities; |
5 | 5 | import io.github.codeutilities.mod.config.Config; |
6 | | -import io.github.codeutilities.mod.events.impl.ReceiveChatMessageEvent; |
7 | 6 | import io.github.codeutilities.mod.events.interfaces.ChatEvents; |
8 | | -import io.github.codeutilities.mod.features.discordrpc.DFDiscordRPC; |
| 7 | +import io.github.codeutilities.mod.features.CPU_UsageText; |
9 | 8 | import io.github.codeutilities.mod.features.keybinds.FlightspeedToggle; |
10 | 9 | import io.github.codeutilities.mod.features.social.chat.message.Message; |
11 | | -import io.github.codeutilities.sys.player.chat.ChatUtil; |
12 | | -import io.github.codeutilities.sys.player.chat.MessageGrabber; |
13 | | -import io.github.codeutilities.mod.features.CPU_UsageText; |
14 | | -import io.github.codeutilities.sys.player.DFInfo; |
15 | 10 | import io.github.codeutilities.sys.networking.State; |
16 | 11 | import io.github.codeutilities.sys.networking.WebUtil; |
| 12 | +import io.github.codeutilities.sys.player.DFInfo; |
| 13 | +import io.github.codeutilities.sys.player.chat.ChatUtil; |
| 14 | +import io.github.codeutilities.sys.util.VersionUtil; |
17 | 15 | import net.minecraft.client.MinecraftClient; |
18 | 16 | import net.minecraft.client.network.ClientPlayNetworkHandler; |
19 | 17 | import net.minecraft.network.MessageType; |
20 | 18 | import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket; |
21 | 19 | import net.minecraft.network.packet.s2c.play.TitleS2CPacket; |
22 | | -import net.minecraft.text.ClickEvent; |
23 | | -import net.minecraft.text.LiteralText; |
24 | | -import net.minecraft.text.Text; |
25 | | -import net.minecraft.text.TextColor; |
| 20 | +import net.minecraft.text.*; |
26 | 21 | import net.minecraft.util.ActionResult; |
27 | 22 | import net.minecraft.util.Formatting; |
28 | 23 | import org.apache.logging.log4j.Level; |
@@ -91,10 +86,26 @@ private void updateVersion(Text component) { |
91 | 86 | minecraftClient.player.sendMessage(new LiteralText(string).styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))), false); |
92 | 87 | } |
93 | 88 |
|
94 | | - String version = WebUtil.getString("https://codeutilities.github.io/data/currentversion.txt").replaceAll("\n", ""); |
95 | | - if (!CodeUtilities.MOD_VERSION.equals(version) && !CodeUtilities.BETA) { |
96 | | - minecraftClient.player.sendMessage(new LiteralText(String.format("A new version of CodeUtilities (%s) is available! Click here to download!", version)).styled(style -> |
97 | | - style.withColor(TextColor.fromFormatting(Formatting.YELLOW))).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://codeutilities.github.io/"))), false); |
| 89 | + if (!CodeUtilities.BETA) { |
| 90 | + int latestVersion = VersionUtil.getLatestVersion(); |
| 91 | + int currentVersion = VersionUtil.getCurrentVersionInt(); |
| 92 | + int versionsBehind = latestVersion - currentVersion; |
| 93 | + |
| 94 | + if (versionsBehind > 10) { |
| 95 | + MutableText message = new LiteralText("") |
| 96 | + .append(new LiteralText(String.format("You are currently on build #%s of CodeUtilities, which is %s versions behind the latest (%s). ", |
| 97 | + currentVersion, versionsBehind, latestVersion)) |
| 98 | + .styled(style -> style.withColor(Formatting.YELLOW))) |
| 99 | + .append(new LiteralText("Click here to download the latest version!") |
| 100 | + .styled(style -> { |
| 101 | + style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://codeutilities.github.io")); |
| 102 | + style.withColor(Formatting.AQUA); |
| 103 | + return style; |
| 104 | + })); |
| 105 | + |
| 106 | + minecraftClient.player.sendMessage(message, false); |
| 107 | + |
| 108 | + } |
98 | 109 | } |
99 | 110 |
|
100 | 111 | } catch (IOException ignored) { |
|
0 commit comments