Fix wiki links being outdated

This commit is contained in:
nossr50
2024-04-06 15:10:02 -07:00
parent ffc6061f8b
commit 4d98d25215
6 changed files with 43 additions and 60 deletions

View File

@ -34,8 +34,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.Iterator;
import static java.util.Objects.requireNonNull;
public final class SkillUtils {
/**
* This is a static utility class, therefore we don't want any instances of

View File

@ -56,18 +56,23 @@ public class TextComponentFactory {
return Component.text(text);
}
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted) {
public static String getSubSkillWikiLink(SubSkillType subSkillType) {
return "https://wiki.mcmmo.org/en/skills/"
+ subSkillType.getParentSkill().toString().toLowerCase(Locale.ENGLISH) + "#"
+ subSkillType.getWikiUrl().toLowerCase(Locale.ENGLISH);
}
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted, SubSkillType subSkillType) {
if (!mcMMO.p.getGeneralConfig().getUrlLinksEnabled())
return;
TextComponent.Builder wikiLinkComponent = Component.text().content(LocaleLoader.getString("Overhaul.mcMMO.MmoInfo.Wiki"));
wikiLinkComponent.decoration(TextDecoration.UNDERLINED, true);
String wikiUrl = "https://wiki.mcmmo.org/" + subskillformatted;
final String subSkillWikiLink = getSubSkillWikiLink(subSkillType);
wikiLinkComponent.clickEvent(ClickEvent.openUrl(subSkillWikiLink));
wikiLinkComponent.clickEvent(ClickEvent.openUrl(wikiUrl));
TextComponent.Builder componentBuilder = Component.text().content(subskillformatted).append(Component.newline()).append(Component.text(wikiUrl)).color(NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, true);
TextComponent.Builder componentBuilder = Component.text().content(subskillformatted).append(Component.newline()).append(Component.text(subSkillWikiLink)).color(NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, true);
wikiLinkComponent.hoverEvent(HoverEvent.showText(componentBuilder.build()));