From 10293be16930a5dcb626a118ae98aa84b3771c5c Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Sun, 27 Oct 2024 18:25:24 +0100 Subject: [PATCH] end it --- pom.xml | 2 +- .../java/eu/m724/giants/GiantsPlugin.java | 4 +++- .../eu/m724/giants/updater/UpdateCommand.java | 22 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ff17d6a..e96f916 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ eu.m724 jarupdater - 0.1.5 + 0.1.7 diff --git a/src/main/java/eu/m724/giants/GiantsPlugin.java b/src/main/java/eu/m724/giants/GiantsPlugin.java index 1fd19cc..26c3332 100644 --- a/src/main/java/eu/m724/giants/GiantsPlugin.java +++ b/src/main/java/eu/m724/giants/GiantsPlugin.java @@ -51,7 +51,9 @@ public class GiantsPlugin extends JavaPlugin implements CommandExecutor { getLogger().warning("Failed checking JAR signature. This is not important right now, but it usually forecasts future problems."); } catch (JarVerifier.VerificationException e) { getLogger().warning(e.getMessage()); - getLogger().warning("Plugin JAR is of invalid signature. It's possible that the signature has changed, in which case it's normal. But I can't verify that, you must see the version changelog yourself."); + getLogger().warning("Plugin JAR is of invalid signature. It's possible that the signature has changed, in which case it's normal. Please see changelog on SpigotMC."); + getLogger().warning("If updating from 2.0.7, this is unfortunately expected. That version has a critical bug."); + getLogger().warning("Please move plugins/.paper-remapped/giants-2.0.7.jar to plugins/ (notice they differ in size a lot) or redownload *2.0.9* from SpigotMC"); } /* bStats is optional. not anymore diff --git a/src/main/java/eu/m724/giants/updater/UpdateCommand.java b/src/main/java/eu/m724/giants/updater/UpdateCommand.java index d0d55e0..a6fcd2d 100644 --- a/src/main/java/eu/m724/giants/updater/UpdateCommand.java +++ b/src/main/java/eu/m724/giants/updater/UpdateCommand.java @@ -1,7 +1,12 @@ package eu.m724.giants.updater; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import java.nio.file.NoSuchFileException; import java.time.LocalDate; @@ -17,6 +22,21 @@ public class UpdateCommand { this.updater = updater; } + private void sendChangelogMessage(CommandSender sender, String changelogUrl) { + if (changelogUrl != null) { + if (sender instanceof Player) { + TextComponent textComponent = new TextComponent("Click here to open changelog"); + textComponent.setUnderlined(true); + textComponent.setColor(ChatColor.AQUA); + textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(changelogUrl))); + textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, changelogUrl)); + sender.spigot().sendMessage(textComponent); + } else { + sender.sendMessage("Changelog: " + changelogUrl); + } + } + } + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { sender.sendMessage("Please wait..."); sender.sendMessage("Channel: " + updater.getEnvironment().getChannel()); @@ -30,11 +50,13 @@ public class UpdateCommand { if (metadata != null) { sender.sendMessage("An update is available!"); sender.sendMessage("Giants " + metadata.getLabel() + " released " + formatDate(metadata.getTimestamp())); + sendChangelogMessage(sender, metadata.getChangelogUrl()); sender.sendMessage("To download: /giants update download"); } else { sender.sendMessage("No new updates"); updater.getCurrentVersion().thenAccept(metadata2 -> { sender.sendMessage("You're on Giants " + metadata2.getLabel() + " released " + formatDate(metadata2.getTimestamp())); + sendChangelogMessage(sender, metadata2.getChangelogUrl()); }).exceptionally(e -> { sender.sendMessage("Error retrieving information about current version, see console for details. " + e.getMessage()); e.printStackTrace();