fix(download): incorrect mcmod url for modpacks. Closes #1525.
This commit is contained in:
@@ -261,7 +261,7 @@ public class DownloadPage extends Control implements DecoratorPage {
|
||||
|
||||
if (getSkinnable().mod != null) {
|
||||
JFXHyperlink openMcmodButton = new JFXHyperlink(i18n("mods.mcmod"));
|
||||
openMcmodButton.setOnAction(e -> FXUtils.openLink(ModManager.getMcmodUrl(getSkinnable().mod.getMcmod())));
|
||||
openMcmodButton.setOnAction(e -> FXUtils.openLink(getSkinnable().translations.getMcmodUrl(getSkinnable().mod)));
|
||||
descriptionPane.getChildren().add(openMcmodButton);
|
||||
|
||||
if (StringUtils.isNotBlank(getSkinnable().mod.getMcbbs())) {
|
||||
|
||||
@@ -261,7 +261,7 @@ class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
mcmodButton.setText(i18n("mods.mcmod.page"));
|
||||
mcmodButton.setOnAction(e -> {
|
||||
fireEvent(new DialogCloseEvent());
|
||||
FXUtils.openLink(ModManager.getMcmodUrl(modInfo.getMod().getMcmod()));
|
||||
FXUtils.openLink(ModTranslations.MOD.getMcmodUrl(modInfo.getMod()));
|
||||
});
|
||||
getActions().add(mcmodButton);
|
||||
}
|
||||
|
||||
@@ -36,10 +36,25 @@ import static org.jackhuang.hmcl.util.Pair.pair;
|
||||
*
|
||||
* @see <a href="https://www.mcmod.cn">mcmod.cn</a>
|
||||
*/
|
||||
public final class ModTranslations {
|
||||
public static ModTranslations MOD = new ModTranslations("/assets/mod_data.txt");
|
||||
public static ModTranslations MODPACK = new ModTranslations("/assets/modpack_data.txt");
|
||||
public static ModTranslations EMPTY = new ModTranslations("");
|
||||
public enum ModTranslations {
|
||||
MOD("/assets/mod_data.txt") {
|
||||
@Override
|
||||
public String getMcmodUrl(Mod mod) {
|
||||
return String.format("https://www.mcmod.cn/class/%s.html", mod.getMcmod());
|
||||
}
|
||||
},
|
||||
MODPACK("/assets/modpack_data.txt") {
|
||||
@Override
|
||||
public String getMcmodUrl(Mod mod) {
|
||||
return String.format("https://www.mcmod.cn/modpack/%s.html", mod.getMcmod());
|
||||
}
|
||||
},
|
||||
EMPTY("") {
|
||||
@Override
|
||||
public String getMcmodUrl(Mod mod) {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
public static ModTranslations getTranslationsByRepositoryType(RemoteModRepository.Type type) {
|
||||
switch (type) {
|
||||
@@ -59,7 +74,7 @@ public final class ModTranslations {
|
||||
private List<Pair<String, Mod>> keywords;
|
||||
private int maxKeywordLength = -1;
|
||||
|
||||
private ModTranslations(String resourceName) {
|
||||
ModTranslations(String resourceName) {
|
||||
this.resourceName = resourceName;
|
||||
}
|
||||
|
||||
@@ -77,6 +92,8 @@ public final class ModTranslations {
|
||||
return modIdMap.get(id);
|
||||
}
|
||||
|
||||
public abstract String getMcmodUrl(Mod mod);
|
||||
|
||||
public List<Mod> searchMod(String query) {
|
||||
if (!loadKeywords()) return Collections.emptyList();
|
||||
|
||||
|
||||
@@ -305,10 +305,6 @@ public final class ModManager {
|
||||
return getModsDirectory().resolve(fileName);
|
||||
}
|
||||
|
||||
public static String getMcmodUrl(String mcmodId) {
|
||||
return String.format("https://www.mcmod.cn/class/%s.html", mcmodId);
|
||||
}
|
||||
|
||||
public static String getMcbbsUrl(String mcbbsId) {
|
||||
return String.format("https://www.mcbbs.net/thread-%s-1-1.html", mcbbsId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user