Skip to content

Commit af71202

Browse files
committed
Fix the string codec error message pluralization
1 parent 68beda4 commit af71202

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/net/errorcraft/codecium/mixin/mojang/serialization/CodecExtender.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mojang.serialization.*;
44
import net.errorcraft.codecium.serialization.FieldMapCodec;
5+
import net.errorcraft.codecium.util.EnglishUtil;
56
import net.errorcraft.codecium.util.codec.NumberUtil;
67
import org.spongepowered.asm.mixin.Mixin;
78
import org.spongepowered.asm.mixin.Overwrite;
@@ -55,10 +56,10 @@ static Codec<String> string(final int minSize, final int maxSize) {
5556
return Codec.STRING.validate(value -> {
5657
final int length = value.length();
5758
if (length < minSize) {
58-
return DataResult.error(() -> "String must have at least " + minSize + " characters, but got " + length + ": \"" + value + "\"");
59+
return DataResult.error(() -> "String must have at least " + minSize + " " + EnglishUtil.pluralize(minSize, "character") + ", but got " + length + ": \"" + value + "\"");
5960
}
6061
if (length > maxSize) {
61-
return DataResult.error(() -> "String must have at most " + maxSize + " characters, but got " + length + ": \"" + value + "\"");
62+
return DataResult.error(() -> "String must have at most " + maxSize + " " + EnglishUtil.pluralize(minSize, "character") + ", but got " + length + ": \"" + value + "\"");
6263
}
6364
return DataResult.success(value);
6465
});

0 commit comments

Comments
 (0)