This commit is contained in:
Minecon724 2024-10-27 18:25:24 +01:00
parent 648bf9267f
commit 10293be169
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
3 changed files with 26 additions and 2 deletions

View file

@ -57,7 +57,7 @@
<dependency>
<groupId>eu.m724</groupId>
<artifactId>jarupdater</artifactId>
<version>0.1.5</version>
<version>0.1.7</version>
</dependency>
</dependencies>

View file

@ -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

View file

@ -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();