Skip to content

Commit

Permalink
update message sent from ReleaseChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
Jsinco committed Dec 21, 2024
1 parent 6de25a8 commit a5dc53b
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/dre/brewery/configuration/files/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public abstract class ReleaseChecker {


public abstract CompletableFuture<String> resolveLatest();

public abstract CompletableFuture<Boolean> 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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -74,4 +80,9 @@ public CompletableFuture<Boolean> checkForUpdate() {
return isUpdateAvailable();
});
}

@Override
public String getDownloadURL() {
return String.format(CONST_RELEASE_URL, owner, repo, resolvedLatestVersion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -79,4 +84,9 @@ public CompletableFuture<Boolean> checkForUpdate() {
return isUpdateAvailable();
});
}

@Override
public String getDownloadURL() {
return String.format(CONST_RELEASE_URL, owner, repo, resolvedLatestVersion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ public CompletableFuture<Boolean> checkForUpdate() {
public void notify(CommandSender receiver) {
// No implementation
}

@Override
public String getDownloadURL() {
return "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/languages/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 Копирует зелье в твоей руке'
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/tw.yml.unused
Original file line number Diff line number Diff line change
Expand Up @@ -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 複製手中的藥水'
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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复制当前手中的饮品.'
Expand Down

0 comments on commit a5dc53b

Please sign in to comment.