diff --git a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java index 4becc3f7e..5f1d6c4e7 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java @@ -54,6 +54,7 @@ import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.base.Splitter; import com.google.common.collect.Lists; +import com.google.common.collect.ObjectArrays; /* * Like {@link com.electronwill.nightconfig.core.ConfigSpec} except in builder format, and extended to acept comments, language keys, @@ -247,6 +248,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper public > ConfigValue defineInRange(List path, Supplier defaultSupplier, V min, V max, Class clazz) { Range range = new Range<>(clazz, min, max); context.setRange(range); + context.setComment(ObjectArrays.concat(context.getComment(), "Range: " + range.toString())); if (min.compareTo(max) > 0) throw new IllegalArgumentException("Range min most be less then max."); return define(path, defaultSupplier, range); @@ -539,7 +541,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper @SuppressWarnings("unused") private static class Range> implements Predicate { - private final Class clazz; + private final Class clazz; private final V min; private final V max; @@ -550,7 +552,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper this.max = max; } - public Class getClazz() { return clazz; } + public Class getClazz() { return clazz; } public V getMin() { return min; } public V getMax() { return max; } @@ -561,6 +563,19 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper V c = clazz.cast(t); return c.compareTo(min) >= 0 && c.compareTo(max) <= 0; } + + @Override + public String toString() + { + if (clazz == Integer.class) { + if (max.equals(Integer.MAX_VALUE)) { + return "> " + min; + } else if (min.equals(Integer.MIN_VALUE)) { + return "< " + max; + } + } // TODO add more special cases? + return min + " ~ " + max; + } } public static class ValueSpec