From a5dc53b4811a83c5f61e26db6c660e248a71538e Mon Sep 17 00:00:00 2001 From: Jsinco Date: Sat, 21 Dec 2024 05:35:22 -0500 Subject: [PATCH] update message sent from ReleaseChecker --- .../com/dre/brewery/configuration/files/Lang.java | 6 +++--- .../dre/brewery/utility/releases/ReleaseChecker.java | 6 +++--- .../utility/releases/impl/GitHubReleaseChecker.java | 11 +++++++++++ .../releases/impl/GithubSnapshotsReleaseChecker.java | 10 ++++++++++ .../utility/releases/impl/NoImplReleaseChecker.java | 5 +++++ .../utility/releases/impl/SpigotReleaseChecker.java | 8 ++++++++ src/main/resources/languages/de.yml | 2 +- src/main/resources/languages/en.yml | 2 +- src/main/resources/languages/es.yml | 2 +- src/main/resources/languages/fr.yml | 2 +- src/main/resources/languages/it.yml | 2 +- src/main/resources/languages/ru.yml | 2 +- src/main/resources/languages/tw.yml.unused | 2 +- src/main/resources/languages/zh.yml | 2 +- 14 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/dre/brewery/configuration/files/Lang.java b/src/main/java/com/dre/brewery/configuration/files/Lang.java index 464c1910..61ec8d9b 100644 --- a/src/main/java/com/dre/brewery/configuration/files/Lang.java +++ b/src/main/java/com/dre/brewery/configuration/files/Lang.java @@ -41,7 +41,7 @@ import java.util.Map; // Our bind file for this class should vary based on what language the user has set in the config. -@OkaeriConfigFileOptions(useLangFileName = true) +@OkaeriConfigFileOptions(useLangFileName = true, removeOrphans = true) @Header({"!!! IMPORTANT: BreweryX configuration files do NOT support external comments! If you add any comments, they will be overwritten !!!", "Translations for BreweryX"}) @DefaultCommentSpace(1) @@ -241,8 +241,8 @@ public String getEntry(String key, boolean color, Object... args) { private String etcUsage; @CustomKey("Etc_SealingTable") private String etcSealingTable; - @CustomKey("Etc_UpdateAvailable") - private String etcUpdateAvailable; + @CustomKey("Etc_NewRelease") + private String etcNewRelease; @Comment("Help") diff --git a/src/main/java/com/dre/brewery/utility/releases/ReleaseChecker.java b/src/main/java/com/dre/brewery/utility/releases/ReleaseChecker.java index 06f9eed0..479fca7a 100644 --- a/src/main/java/com/dre/brewery/utility/releases/ReleaseChecker.java +++ b/src/main/java/com/dre/brewery/utility/releases/ReleaseChecker.java @@ -43,14 +43,14 @@ public abstract class ReleaseChecker { public abstract CompletableFuture resolveLatest(); - public abstract CompletableFuture checkForUpdate(); + public abstract String getDownloadURL(); public void notify(CommandSender receiver) { if (receiver.hasPermission("brewery.update") && isUpdateAvailable()) { - ConfigManager.getConfig(Lang.class) - .sendEntry(receiver, "Etc_UpdateAvailable", "v" + localVersion(), "v" + resolvedLatestVersion); + Lang lang = ConfigManager.getConfig(Lang.class); + lang.sendEntry(receiver, "Etc_NewRelease", "v" + localVersion(), "v" + resolvedLatestVersion, getDownloadURL()); } } diff --git a/src/main/java/com/dre/brewery/utility/releases/impl/GitHubReleaseChecker.java b/src/main/java/com/dre/brewery/utility/releases/impl/GitHubReleaseChecker.java index 1ec586bf..d916434d 100644 --- a/src/main/java/com/dre/brewery/utility/releases/impl/GitHubReleaseChecker.java +++ b/src/main/java/com/dre/brewery/utility/releases/impl/GitHubReleaseChecker.java @@ -24,6 +24,7 @@ import com.dre.brewery.utility.releases.ReleaseChecker; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import org.bukkit.command.CommandSender; import java.io.IOException; import java.net.URI; @@ -35,12 +36,17 @@ public class GitHubReleaseChecker extends ReleaseChecker { private static final String CONST_URL = "https://api.github.com/repos/%s/%s/releases/latest"; + private static final String CONST_RELEASE_URL = "https://github.com/%s/%s/releases/tag/%s"; private static final String CONST_JSON_FIELD = "tag_name"; private final String link; + private final String owner; + private final String repo; public GitHubReleaseChecker(String owner, String repo) { this.link = String.format(CONST_URL, owner, repo); + this.owner = owner; + this.repo = repo; } @Override @@ -74,4 +80,9 @@ public CompletableFuture checkForUpdate() { return isUpdateAvailable(); }); } + + @Override + public String getDownloadURL() { + return String.format(CONST_RELEASE_URL, owner, repo, resolvedLatestVersion); + } } diff --git a/src/main/java/com/dre/brewery/utility/releases/impl/GithubSnapshotsReleaseChecker.java b/src/main/java/com/dre/brewery/utility/releases/impl/GithubSnapshotsReleaseChecker.java index 77fefe43..e9b87738 100644 --- a/src/main/java/com/dre/brewery/utility/releases/impl/GithubSnapshotsReleaseChecker.java +++ b/src/main/java/com/dre/brewery/utility/releases/impl/GithubSnapshotsReleaseChecker.java @@ -36,12 +36,17 @@ public class GithubSnapshotsReleaseChecker extends ReleaseChecker { private static final String CONST_URL = "https://api.github.com/repos/%s/%s/releases"; + private static final String CONST_RELEASE_URL = "https://github.com/%s/%s/releases/tag/%s"; private static final String CONST_JSON_FIELD = "tag_name"; private final String link; + private final String owner; + private final String repo; public GithubSnapshotsReleaseChecker(String owner, String repo) { this.link = String.format(CONST_URL, owner, repo); + this.owner = owner; + this.repo = repo; } @Override @@ -79,4 +84,9 @@ public CompletableFuture checkForUpdate() { return isUpdateAvailable(); }); } + + @Override + public String getDownloadURL() { + return String.format(CONST_RELEASE_URL, owner, repo, resolvedLatestVersion); + } } diff --git a/src/main/java/com/dre/brewery/utility/releases/impl/NoImplReleaseChecker.java b/src/main/java/com/dre/brewery/utility/releases/impl/NoImplReleaseChecker.java index b41fa082..2409a531 100644 --- a/src/main/java/com/dre/brewery/utility/releases/impl/NoImplReleaseChecker.java +++ b/src/main/java/com/dre/brewery/utility/releases/impl/NoImplReleaseChecker.java @@ -47,4 +47,9 @@ public CompletableFuture checkForUpdate() { public void notify(CommandSender receiver) { // No implementation } + + @Override + public String getDownloadURL() { + return ""; + } } diff --git a/src/main/java/com/dre/brewery/utility/releases/impl/SpigotReleaseChecker.java b/src/main/java/com/dre/brewery/utility/releases/impl/SpigotReleaseChecker.java index 894fec46..f7f2a35e 100644 --- a/src/main/java/com/dre/brewery/utility/releases/impl/SpigotReleaseChecker.java +++ b/src/main/java/com/dre/brewery/utility/releases/impl/SpigotReleaseChecker.java @@ -31,11 +31,14 @@ public class SpigotReleaseChecker extends ReleaseChecker { private static final String CONST_URL = "https://api.spigotmc.org/legacy/update.php?resource=%s/~"; + private static final String CONST_RELEASE_URL = "https://www.spigotmc.org/resources/%s"; private final String link; + private final int resourceId; public SpigotReleaseChecker(int resourceId) { this.link = String.format(CONST_URL, resourceId); + this.resourceId = resourceId; } @Override @@ -63,4 +66,9 @@ public String failedToResolve() { this.resolvedLatestVersion = CONST_UNRESOLVED; return CONST_UNRESOLVED; } + + @Override + public String getDownloadURL() { + return String.format(CONST_RELEASE_URL, resourceId); + } } diff --git a/src/main/resources/languages/de.yml b/src/main/resources/languages/de.yml index 966fc285..a6d212eb 100644 --- a/src/main/resources/languages/de.yml +++ b/src/main/resources/languages/de.yml @@ -58,7 +58,7 @@ Etc_Page: Seite Etc_Usage: 'Benutzung:' Etc_Barrel: Fass Etc_SealingTable: Trankversiegler -Etc_UpdateAvailable: 'Update available: &a&v1 &f-> &a&v2 &bhttps://www.spigotmc.org/resources/breweryx.114777/' +Etc_NewRelease: '&rA new release of BreweryX is available! &2&v1 &r-> &2&v2&r Download&7: &2&v3' # Help Help_Copy: '&6/brew Copy [Anzahl]&9 Kopiert den Trank in deiner Hand' diff --git a/src/main/resources/languages/en.yml b/src/main/resources/languages/en.yml index ca5b0e51..65d1fc8e 100644 --- a/src/main/resources/languages/en.yml +++ b/src/main/resources/languages/en.yml @@ -58,7 +58,7 @@ Etc_Barrel: Barrel Etc_Page: Page Etc_Usage: 'Usage:' Etc_SealingTable: Brew Sealing Table -Etc_UpdateAvailable: 'Update available: &a&v1 &f-> &a&v2 &bhttps://www.spigotmc.org/resources/breweryx.114777/' +Etc_NewRelease: '&rA new release of BreweryX is available! &2&v1 &r-> &2&v2&r Download&7: &2&v3' # Help Help_Copy: '&6/brew copy [Quantity]&9 Copies the potion in your hand' diff --git a/src/main/resources/languages/es.yml b/src/main/resources/languages/es.yml index b5a7ee73..f33c49fd 100644 --- a/src/main/resources/languages/es.yml +++ b/src/main/resources/languages/es.yml @@ -58,7 +58,7 @@ Etc_Barrel: Tonel Etc_Page: Página Etc_Usage: 'Uso:' Etc_SealingTable: Mesa de sellado de bebidas -Etc_UpdateAvailable: 'Actualización disponible: &a&v1 &f-> &a&v2 &bhttps://www.spigotmc.org/resources/breweryx.114777/' +Etc_NewRelease: '&rA new release of BreweryX is available! &2&v1 &r-> &2&v2&r Download&7: &2&v3' # Ayuda Help_Copy: '&6/brew copy [Cantidad]&9 Copia la bebida en tu mano' diff --git a/src/main/resources/languages/fr.yml b/src/main/resources/languages/fr.yml index 9d6be2c1..7344911e 100644 --- a/src/main/resources/languages/fr.yml +++ b/src/main/resources/languages/fr.yml @@ -63,7 +63,7 @@ Etc_Barrel: 'Baril' Etc_Page: 'Page' Etc_Usage: 'Utilise :' Etc_SealingTable: 'Table de scellage des boissons' -Etc_UpdateAvailable: 'Mise à jour disponible : &a&v1 &f-> &a&v2 &bhttps://www.spigotmc.org/resources/breweryx.114777/' +Etc_NewRelease: '&rA new release of BreweryX is available! &2&v1 &r-> &2&v2&r Download&7: &2&v3' # Aide Help_Copy: '&6/brew copy [Quantity]&9 Copie la potion qui est dans votre main' diff --git a/src/main/resources/languages/it.yml b/src/main/resources/languages/it.yml index 12eab0af..61d06c6d 100644 --- a/src/main/resources/languages/it.yml +++ b/src/main/resources/languages/it.yml @@ -58,7 +58,7 @@ Etc_Barrel: Barile Etc_Page: Pagina Etc_Usage: 'Utilizzo:' Etc_SealingTable: Brew Sealing Table -Etc_UpdateAvailable: 'Update available: &a&v1 &f-> &a&v2 &bhttps://www.spigotmc.org/resources/breweryx.114777/' +Etc_NewRelease: '&rA new release of BreweryX is available! &2&v1 &r-> &2&v2&r Download&7: &2&v3' # Aiuto Help_Copy: '&6/brew copy [Quantità]&9 Copia la pozione che tieni in mano' diff --git a/src/main/resources/languages/ru.yml b/src/main/resources/languages/ru.yml index e5003dab..fc3f60f6 100644 --- a/src/main/resources/languages/ru.yml +++ b/src/main/resources/languages/ru.yml @@ -57,7 +57,7 @@ Etc_Barrel: 'Бочка' Etc_Page: 'Страница' Etc_Usage: 'Использование:' Etc_SealingTable: 'Стол закупорки бражки.' -Etc_UpdateAvailable: 'Доступно обновление: &a&v1 &f-> &a&v2 &bhttps://www.spigotmc.org/resources/breweryx.114777/' +Etc_NewRelease: '&rA new release of BreweryX is available! &2&v1 &r-> &2&v2&r Download&7: &2&v3' # Help Help_Copy: '&6/brew copy [Quantity]&9 Копирует зелье в твоей руке' diff --git a/src/main/resources/languages/tw.yml.unused b/src/main/resources/languages/tw.yml.unused index 7d66f430..4c8cf3cd 100644 --- a/src/main/resources/languages/tw.yml.unused +++ b/src/main/resources/languages/tw.yml.unused @@ -56,7 +56,7 @@ Etc_Barrel: 釀造桶 Etc_Page: 頁數 Etc_Usage: '用法:' Etc_SealingTable: Brew Sealing Table -Etc_UpdateAvailable: 'Update available: &a&v1 &f-> &a&v2 &bhttps://www.spigotmc.org/resources/breweryx.114777/' +Etc_NewRelease: '&rA new release of BreweryX is available! &2&v1 &r-> &2&v2&r Download&7: &2&v3' # Help Help_Copy: '&6/brew copy [數量]&9 複製手中的藥水' diff --git a/src/main/resources/languages/zh.yml b/src/main/resources/languages/zh.yml index 13fb67b5..50b91b84 100644 --- a/src/main/resources/languages/zh.yml +++ b/src/main/resources/languages/zh.yml @@ -56,7 +56,7 @@ Etc_Barrel: 酒桶 Etc_Page: 页 Etc_Usage: '用途:' Etc_SealingTable: 沖泡密封台 -Etc_UpdateAvailable: '新版本已发布: &a&v1 &f-> &a&v2 &bhttps://www.spigotmc.org/resources/breweryx.114777/' +Etc_NewRelease: '&rA new release of BreweryX is available! &2&v1 &r-> &2&v2&r Download&7: &2&v3' # Help Help_Copy: '&6/brew copy [数量] &9复制当前手中的饮品.'