Skip to content

Commit

Permalink
Fix launchernews link
Browse files Browse the repository at this point in the history
  • Loading branch information
apple502j authored and sfPlayer1 committed Jun 1, 2024
1 parent 047cb24 commit 1362361
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private boolean announce(Version version) {
}

record Version(String type, String name, String title, @Nullable URI image, String shortText, ZonedDateTime date) implements Comparable<Version> {
private static final String URL_PREFIX = "https://www.minecraft.net/en-us/article/minecraft";
private static final String URL_PREFIX = "https://www.minecraft.net/en-us/article";
private static final Predicate<String> SNAPSHOT_PREDICATE = Pattern.compile("^\\d+w\\d+[a-z]+$").asMatchPredicate();
private static final Pattern NON_ALPHANUMERIC = Pattern.compile("[^a-z0-9]");

Expand All @@ -230,11 +230,11 @@ EmbedBuilder toEmbed() {

String getUrl() {
if ("release".equals(type)) {
return "%s-java-edition-%s".formatted(URL_PREFIX, name.replace('.', '-'));
return "%s/minecraft-java-edition-%s".formatted(URL_PREFIX, name.replace('.', '-'));
} else if (SNAPSHOT_PREDICATE.test(name)) {
return "%s-snapshot-%s".formatted(URL_PREFIX, name);
return "%s/minecraft-snapshot-%s".formatted(URL_PREFIX, name);
} else {
return "%s-%s".formatted(URL_PREFIX, NON_ALPHANUMERIC.matcher(name.toLowerCase(Locale.ROOT)).replaceAll("-"));
return "%s/%s".formatted(URL_PREFIX, NON_ALPHANUMERIC.matcher(title.toLowerCase(Locale.ROOT)).replaceAll("-"));
}
}

Expand Down

0 comments on commit 1362361

Please sign in to comment.