Update for ForgeSPI change, revert back to VersionStatus checking

This commit is contained in:
ichttt 2019-01-27 20:51:35 +01:00
parent c2a7fe4019
commit da33233762
4 changed files with 16 additions and 13 deletions

View File

@ -35,7 +35,6 @@ public class ModFileInfo implements IModFileInfo
{ {
private final UnmodifiableConfig config; private final UnmodifiableConfig config;
private final ModFile modFile; private final ModFile modFile;
private final URL updateJSONURL;
private final URL issueURL; private final URL issueURL;
private final String modLoader; private final String modLoader;
private final VersionRange modLoaderVersion; private final VersionRange modLoaderVersion;
@ -59,7 +58,6 @@ public class ModFileInfo implements IModFileInfo
throw new InvalidModFileException("Missing mods list", this); throw new InvalidModFileException("Missing mods list", this);
} }
this.mods = modConfigs.stream().map(mi-> new ModInfo(this, mi)).collect(Collectors.toList()); this.mods = modConfigs.stream().map(mi-> new ModInfo(this, mi)).collect(Collectors.toList());
this.updateJSONURL = config.<String>getOptional("updateJSONURL").map(StringUtils::toURL).orElse(null);
this.issueURL = config.<String>getOptional("issueTrackerURL").map(StringUtils::toURL).orElse(null); this.issueURL = config.<String>getOptional("issueTrackerURL").map(StringUtils::toURL).orElse(null);
} }
@ -80,12 +78,6 @@ public class ModFileInfo implements IModFileInfo
return this.config; return this.config;
} }
@Override
public URL getUpdateURL(IModFileInfo modFileInfo)
{
return this.updateJSONURL;
}
@Override @Override
public String getModLoader() public String getModLoader()
{ {

View File

@ -20,9 +20,11 @@
package net.minecraftforge.fml.loading.moddiscovery; package net.minecraftforge.fml.loading.moddiscovery;
import com.electronwill.nightconfig.core.UnmodifiableConfig; import com.electronwill.nightconfig.core.UnmodifiableConfig;
import net.minecraftforge.fml.loading.StringUtils;
import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.fml.loading.StringSubstitutor; import net.minecraftforge.fml.loading.StringSubstitutor;
import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -48,6 +50,7 @@ public class ModInfo implements IModInfo
private final ArtifactVersion version; private final ArtifactVersion version;
private final String displayName; private final String displayName;
private final String description; private final String description;
private final URL updateJSONURL;
private final List<IModInfo.ModVersion> dependencies; private final List<IModInfo.ModVersion> dependencies;
private final Map<String,Object> properties; private final Map<String,Object> properties;
private final UnmodifiableConfig modConfig; private final UnmodifiableConfig modConfig;
@ -71,6 +74,7 @@ public class ModInfo implements IModInfo
map(DefaultArtifactVersion::new).orElse(DEFAULT_VERSION); map(DefaultArtifactVersion::new).orElse(DEFAULT_VERSION);
this.displayName = modConfig.<String>getOptional("displayName").orElse(null); this.displayName = modConfig.<String>getOptional("displayName").orElse(null);
this.description = modConfig.get("description"); this.description = modConfig.get("description");
this.updateJSONURL = modConfig.<String>getOptional("updateJSONURL").map(StringUtils::toURL).orElse(null);
if (owningFile != null) { if (owningFile != null) {
this.dependencies = owningFile.getConfig().<List<UnmodifiableConfig>>getOptional(Arrays.asList("dependencies", this.modId)). this.dependencies = owningFile.getConfig().<List<UnmodifiableConfig>>getOptional(Arrays.asList("dependencies", this.modId)).
orElse(Collections.emptyList()).stream().map(dep -> new ModVersion(this, dep)).collect(Collectors.toList()); orElse(Collections.emptyList()).stream().map(dep -> new ModVersion(this, dep)).collect(Collectors.toList());
@ -103,6 +107,7 @@ public class ModInfo implements IModInfo
{ {
return this.description; return this.description;
} }
@Override @Override
public ArtifactVersion getVersion() { public ArtifactVersion getVersion() {
return version; return version;
@ -128,6 +133,11 @@ public class ModInfo implements IModInfo
return this.properties; return this.properties;
} }
@Override
public URL getUpdateURL() {
return this.updateJSONURL;
}
public Optional<String> getLogoFile() public Optional<String> getLogoFile()
{ {
return this.owningFile != null ? this.owningFile.getConfig().getOptional("logoFile") : this.modConfig.getOptional("logoFile"); return this.owningFile != null ? this.owningFile.getConfig().getOptional("logoFile") : this.modConfig.getOptional("logoFile");

View File

@ -298,7 +298,8 @@ public class ForgeHooksClient
public static void renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height) public static void renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height)
{ {
if (ForgeVersion.getVersion().getMinorVersion() == 0) VersionChecker.Status status = ForgeVersion.getStatus();
if (status == BETA || status == BETA_OUTDATED)
{ {
// render a warning at the top of the screen, // render a warning at the top of the screen,
String line = I18n.format("forge.update.beta.1", TextFormatting.RED, TextFormatting.RESET); String line = I18n.format("forge.update.beta.1", TextFormatting.RED, TextFormatting.RESET);
@ -308,7 +309,7 @@ public class ForgeHooksClient
} }
String line = null; String line = null;
switch(ForgeVersion.getStatus()) switch(status)
{ {
//case FAILED: line = " Version check failed"; break; //case FAILED: line = " Version check failed"; break;
//case UP_TO_DATE: line = "Forge up to date"}; break; //case UP_TO_DATE: line = "Forge up to date"}; break;

View File

@ -36,7 +36,7 @@ public class ForgeVersion
// This is Forge's Mod Id, used for the ForgeMod and resource locations // This is Forge's Mod Id, used for the ForgeMod and resource locations
public static final String MOD_ID = "forge"; public static final String MOD_ID = "forge";
private static final ArtifactVersion forgeVersion; private static final String forgeVersion;
private static final String forgeSpec; private static final String forgeSpec;
private static final String forgeGroup; private static final String forgeGroup;
@ -50,7 +50,7 @@ public class ForgeVersion
if (group == null) { if (group == null) {
group = "net.minecraftforge"; // If all else fails, Our normal group group = "net.minecraftforge"; // If all else fails, Our normal group
} }
forgeVersion = new DefaultArtifactVersion(vers); forgeVersion = vers;
forgeSpec = spec; forgeSpec = spec;
forgeGroup = group; forgeGroup = group;
LOGGER.debug(CORE, "Found Forge version {}", forgeVersion); LOGGER.debug(CORE, "Found Forge version {}", forgeVersion);
@ -58,7 +58,7 @@ public class ForgeVersion
LOGGER.debug(CORE, "Found Forge group {}", forgeGroup); LOGGER.debug(CORE, "Found Forge group {}", forgeGroup);
} }
public static ArtifactVersion getVersion() public static String getVersion()
{ {
return forgeVersion; return forgeVersion;
} }