mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Better error passing from early to game client launch.
This commit is contained in:
1 parent
c6e7bbe18b
commit
d5e04dbcb5
16 files changed
+183
-119
No files matched your search
@@ -0,0 +1,77 @@
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.Restriction;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MavenVersionStringHelper {
|
||||
public static String artifactVersionToString(final ArtifactVersion artifactVersion) {
|
||||
return artifactVersion.toString();
|
||||
}
|
||||
|
||||
public static String versionRangeToString(final VersionRange range) {
|
||||
return range.getRestrictions().stream().map(MavenVersionStringHelper::restrictionToString).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
public static String restrictionToString(final Restriction restriction) {
|
||||
if ( restriction.getLowerBound() == null && restriction.getUpperBound() == null )
|
||||
{
|
||||
return ForgeI18n.parseMessage("fml.messages.version.restriction.any");
|
||||
}
|
||||
else if ( restriction.getLowerBound() != null && restriction.getUpperBound() != null )
|
||||
{
|
||||
if (Objects.equals(artifactVersionToString(restriction.getLowerBound()), artifactVersionToString(restriction.getUpperBound())))
|
||||
{
|
||||
return artifactVersionToString(restriction.getLowerBound());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (restriction.isLowerBoundInclusive() && restriction.isUpperBoundInclusive())
|
||||
{
|
||||
return ForgeI18n.parseMessage("fml.messages.version.restriction.bounded.inclusive", restriction.getLowerBound(), restriction.getUpperBound());
|
||||
}
|
||||
else if (restriction.isLowerBoundInclusive())
|
||||
{
|
||||
return ForgeI18n.parseMessage("fml.messages.version.restriction.bounded.upperexclusive", restriction.getLowerBound(), restriction.getUpperBound());
|
||||
}
|
||||
else if (restriction.isUpperBoundInclusive())
|
||||
{
|
||||
return ForgeI18n.parseMessage("fml.messages.version.restriction.bounded.lowerexclusive", restriction.getLowerBound(), restriction.getUpperBound());
|
||||
}
|
||||
else
|
||||
{
|
||||
return ForgeI18n.parseMessage("fml.messages.version.restriction.bounded.exclusive", restriction.getLowerBound(), restriction.getUpperBound());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( restriction.getLowerBound() != null )
|
||||
{
|
||||
if ( restriction.isLowerBoundInclusive() )
|
||||
{
|
||||
return ForgeI18n.parseMessage("fml.messages.version.restriction.lower.inclusive", restriction.getLowerBound());
|
||||
}
|
||||
else
|
||||
{
|
||||
return ForgeI18n.parseMessage("fml.messages.version.restriction.lower.exclusive", restriction.getLowerBound());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( restriction.isUpperBoundInclusive() )
|
||||
{
|
||||
return ForgeI18n.parseMessage("fml.messages.version.restriction.upper.inclusive", restriction.getUpperBound());
|
||||
}
|
||||
else
|
||||
{
|
||||
return ForgeI18n.parseMessage("fml.messages.version.restriction.upper.exclusive", restriction.getUpperBound());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void parseVersionRange(final String formatString, final StringBuffer stringBuffer, final Object range) {
|
||||
stringBuffer.append(versionRangeToString((VersionRange) range));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user