From 302fc4d6189a68220119ece812759ec7587ea7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ales=CC=8C=20Fabia=CC=81nek?= Date: Sun, 4 Dec 2022 09:38:11 +0100 Subject: [PATCH] 1.6.3 --- .github/versions.json | 6 +- CHANGELOG.md | 4 + .../mixin/ClientPlayNetworkHandlerMixin.java | 2 +- .../friendsandfoes/util/UpdateChecker.java | 99 ++++++++++++------- .../fabric/FriendsAndFoesFabric.java | 2 +- .../forge/FriendsAndFoesForge.java | 2 +- gradle.properties | 2 +- .../quilt/FriendsAndFoesQuilt.java | 2 +- 8 files changed, 75 insertions(+), 44 deletions(-) diff --git a/.github/versions.json b/.github/versions.json index d65717452..2cfd3df39 100644 --- a/.github/versions.json +++ b/.github/versions.json @@ -1,7 +1,7 @@ { - "1.19.2": "1.6.2", - "1.19.1": "1.6.2", - "1.19": "1.6.2", + "1.19.2": "1.6.3", + "1.19.1": "1.6.3", + "1.19": "1.6.3", "1.18.2": "1.4.5", "1.18.1": "1.2.5", "1.18": "1.2.5" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b0702979..febe61837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## mc1.19.2-1.6.3, December 04, 2022 + +- Fixed server crash + ## mc1.19.2-1.6.2, December 03, 2022 - Greatly improved glare performance and AI diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/ClientPlayNetworkHandlerMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/ClientPlayNetworkHandlerMixin.java index 52183c6c7..84531b902 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/mixin/ClientPlayNetworkHandlerMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/ClientPlayNetworkHandlerMixin.java @@ -28,6 +28,6 @@ private void friendsandfoesShowUpdateMessage(GameJoinS2CPacket arg, CallbackInfo return; } - UpdateChecker.checkForNewUpdates(this.client.player); + UpdateChecker.checkForNewUpdatesInGame(this.client.player); } } \ No newline at end of file diff --git a/common/src/main/java/com/faboslav/friendsandfoes/util/UpdateChecker.java b/common/src/main/java/com/faboslav/friendsandfoes/util/UpdateChecker.java index 65c416a9e..5dbaaea93 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/util/UpdateChecker.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/util/UpdateChecker.java @@ -25,44 +25,71 @@ public final class UpdateChecker { private static final Gson gson = new Gson(); - public static void checkForNewUpdates(@Nullable ClientPlayerEntity clientPlayerEntity) { + public static void checkForNewUpdatesInGame(ClientPlayerEntity clientPlayerEntity) { CompletableFuture.runAsync(() -> { - if (FriendsAndFoes.getConfig().checkForNewUpdates) { - Version latestVersion = UpdateChecker.getLatestVersion(); - - if (latestVersion == null) { - return; - } - - String modVersion = ModVersion.getModVersion(); - - if (modVersion == null) { - return; - } - - if (latestVersion.compareTo(Version.parse(modVersion)) > 0) { - if (clientPlayerEntity != null) { - String updateMessageString = MessageFormat.format( - "Friend&Foes update is available! You are using {0} version, but the latest version is {1}. You can download it at ", - modVersion, - latestVersion.toString() - ); - MutableText updateMessage = Text.literal(updateMessageString); - MutableText curseforgeLink = Text.literal("CurseForge").styled(arg -> arg.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, ProjectUrlProvider.getCurseForgeProjectLink())).withUnderline(true)); - MutableText updateMessageSecondPart = Text.literal(" or "); - MutableText modrinthLink = Text.literal("Modrinth").styled(arg -> arg.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, ProjectUrlProvider.getModrinthProjectLink())).withUnderline(true)); - MutableText updateMessageThirdPart = Text.literal("."); - updateMessage.append(curseforgeLink).append(updateMessageSecondPart).append(modrinthLink).append(updateMessageThirdPart); - clientPlayerEntity.sendMessage(updateMessage, false); - } else { - FriendsAndFoes.getLogger().info( - "[Friends&Foes] An update is available! You are using {} version, but the latest version is {}.", - modVersion, - latestVersion.toString() - ); - } - } + if (FriendsAndFoes.getConfig().checkForNewUpdates == false) { + return; } + + Version latestVersion = UpdateChecker.getLatestVersion(); + if (latestVersion == null) { + return; + } + + String modVersion = ModVersion.getModVersion(); + if (modVersion == null) { + return; + } + + if (latestVersion.compareTo(Version.parse(modVersion)) <= 0) { + return; + } + + String updateMessageString = MessageFormat.format( + "Friend&Foes update is available! You are using {0} version, but the latest version is {1}. You can download it at ", + modVersion, + latestVersion.toString() + ); + MutableText updateMessage = Text.literal(updateMessageString); + MutableText curseforgeLink = Text.literal("CurseForge").styled(arg -> arg.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, ProjectUrlProvider.getCurseForgeProjectLink())).withUnderline(true)); + MutableText updateMessageSecondPart = Text.literal(" or "); + MutableText modrinthLink = Text.literal("Modrinth").styled(arg -> arg.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, ProjectUrlProvider.getModrinthProjectLink())).withUnderline(true)); + MutableText updateMessageThirdPart = Text.literal("."); + updateMessage.append(curseforgeLink).append(updateMessageSecondPart).append(modrinthLink).append(updateMessageThirdPart); + clientPlayerEntity.sendMessage(updateMessage, false); + FriendsAndFoes.getLogger().info( + "[Friends&Foes] An update is available! You are using {} version, but the latest version is {}.", + modVersion, + latestVersion.toString() + ); + }); + } + + public static void checkForNewUpdates() { + CompletableFuture.runAsync(() -> { + if (FriendsAndFoes.getConfig().checkForNewUpdates == false) { + return; + } + + Version latestVersion = UpdateChecker.getLatestVersion(); + if (latestVersion == null) { + return; + } + + String modVersion = ModVersion.getModVersion(); + if (modVersion == null) { + return; + } + + if (latestVersion.compareTo(Version.parse(modVersion)) <= 0) { + return; + } + + FriendsAndFoes.getLogger().info( + "[Friends&Foes] An update is available! You are using {} version, but the latest version is {}.", + modVersion, + latestVersion.toString() + ); }); } diff --git a/fabric/src/main/java/com/faboslav/friendsandfoes/fabric/FriendsAndFoesFabric.java b/fabric/src/main/java/com/faboslav/friendsandfoes/fabric/FriendsAndFoesFabric.java index b7a1fa96e..27921ff23 100644 --- a/fabric/src/main/java/com/faboslav/friendsandfoes/fabric/FriendsAndFoesFabric.java +++ b/fabric/src/main/java/com/faboslav/friendsandfoes/fabric/FriendsAndFoesFabric.java @@ -18,7 +18,7 @@ public final class FriendsAndFoesFabric implements ModInitializer { @Override public void onInitialize() { - UpdateChecker.checkForNewUpdates(null); + UpdateChecker.checkForNewUpdates(); FriendsAndFoes.init(); FriendsAndFoes.postInit(); FriendsAndFoesPointOfInterestTypes.postInit(); diff --git a/forge/src/main/java/com/faboslav/friendsandfoes/forge/FriendsAndFoesForge.java b/forge/src/main/java/com/faboslav/friendsandfoes/forge/FriendsAndFoesForge.java index 03416cdf2..dbda7c50a 100644 --- a/forge/src/main/java/com/faboslav/friendsandfoes/forge/FriendsAndFoesForge.java +++ b/forge/src/main/java/com/faboslav/friendsandfoes/forge/FriendsAndFoesForge.java @@ -38,7 +38,7 @@ public final class FriendsAndFoesForge { public FriendsAndFoesForge() { - UpdateChecker.checkForNewUpdates(null); + UpdateChecker.checkForNewUpdates(); FriendsAndFoes.init(); if (FMLEnvironment.dist == Dist.CLIENT) { diff --git a/gradle.properties b/gradle.properties index 0f5596a2c..a7d4f0091 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.configureondemand=false # Mod mod_name=Friends&Foes mod_id=friendsandfoes -mod_version=1.6.2 +mod_version=1.6.3 mod_author=Faboslav mod_description=Adds outvoted and forgotten mobs from the mob votes in a believable vanilla plus style. maven_group=com.faboslav.friendsandfoes diff --git a/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuilt.java b/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuilt.java index 25e1a5c7c..8c766e084 100644 --- a/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuilt.java +++ b/quilt/src/main/java/com/faboslav/friendsandfoes/quilt/FriendsAndFoesQuilt.java @@ -19,7 +19,7 @@ public final class FriendsAndFoesQuilt implements ModInitializer { @Override public void onInitialize(ModContainer mod) { - UpdateChecker.checkForNewUpdates(null); + UpdateChecker.checkForNewUpdates(); FriendsAndFoes.init(); FriendsAndFoes.postInit(); FriendsAndFoesPointOfInterestTypes.postInit();