mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-26 23:13:15 +00:00
Improve the "missing mods" on-screen error message (#2997)
This commit is contained in:
1 parent
aaf1cba776
commit
86d5b5a872
5 files changed
+137
-7
No files matched your search
@@ -20,11 +20,18 @@ public class MissingModsException extends EnhancedRuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
public final Set<ArtifactVersion> missingMods;
|
||||
private final String modName;
|
||||
|
||||
public MissingModsException(Set<ArtifactVersion> missingMods, String id, String name)
|
||||
{
|
||||
super(String.format("Mod %s (%s) requires %s", id, name, missingMods));
|
||||
this.missingMods = missingMods;
|
||||
this.modName = name;
|
||||
}
|
||||
|
||||
public String getModName()
|
||||
{
|
||||
return modName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,8 @@ package net.minecraftforge.fml.common.versioning;
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
/**
|
||||
* Describes a restriction in versioning.
|
||||
*
|
||||
@@ -209,4 +211,45 @@ public class Restriction
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String toStringFriendly()
|
||||
{
|
||||
if ( getLowerBound() == null && getUpperBound() == null )
|
||||
{
|
||||
return I18n.format("fml.messages.version.restriction.any");
|
||||
}
|
||||
else if ( getLowerBound() != null && getUpperBound() != null )
|
||||
{
|
||||
if ( getLowerBound().equals(getUpperBound()) )
|
||||
{
|
||||
return getLowerBound().toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return I18n.format("fml.messages.version.restriction.bounded", getLowerBound(), getUpperBound());
|
||||
}
|
||||
}
|
||||
else if ( getLowerBound() != null )
|
||||
{
|
||||
if ( isLowerBoundInclusive() )
|
||||
{
|
||||
return I18n.format("fml.messages.version.restriction.lower.inclusive", getLowerBound());
|
||||
}
|
||||
else
|
||||
{
|
||||
return I18n.format("fml.messages.version.restriction.lower.exclusive", getLowerBound());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isUpperBoundInclusive() )
|
||||
{
|
||||
return I18n.format("fml.messages.version.restriction.upper.inclusive", getUpperBound());
|
||||
}
|
||||
else
|
||||
{
|
||||
return I18n.format("fml.messages.version.restriction.upper.exclusive", getUpperBound());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -496,6 +496,23 @@ public class VersionRange
|
||||
}
|
||||
}
|
||||
|
||||
public String toStringFriendly()
|
||||
{
|
||||
if ( recommendedVersion != null )
|
||||
{
|
||||
return recommendedVersion.getVersionString();
|
||||
}
|
||||
else
|
||||
{
|
||||
List<String> friendlyRestrictions = new ArrayList<String>(restrictions.size());
|
||||
for (Restriction restriction : restrictions)
|
||||
{
|
||||
friendlyRestrictions.add(restriction.toStringFriendly());
|
||||
}
|
||||
return Joiner.on(", ").join(friendlyRestrictions);
|
||||
}
|
||||
}
|
||||
|
||||
public ArtifactVersion matchVersion( List<ArtifactVersion> versions )
|
||||
{
|
||||
// TODO: could be more efficient by sorting the list and then moving along the restrictions in order?
|
||||
|
||||
Reference in new issue
Block a user