Compare commits

...

2 commits

Author SHA1 Message Date
be38934c3b
wording 2024-10-31 15:19:55 +01:00
10293be169
end it 2024-10-27 18:25:24 +01:00
3 changed files with 25 additions and 3 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

@ -48,10 +48,10 @@ public class GiantsPlugin extends JavaPlugin implements CommandExecutor {
);
} catch (IOException e) {
getLogger().warning(e.getMessage());
getLogger().warning("Failed checking JAR signature. This is not important right now, but it usually forecasts future problems.");
getLogger().warning("Failed checking JAR signature. This is not important right now, but it usually indicates 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. Please re-download the JAR.");
}
/* 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();