diff options
author | md_5 <git@md-5.net> | 2017-04-01 12:28:53 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2017-04-01 12:28:53 +1100 |
commit | 4716bcc6f875def8bc7c6121dfa0f06782d7ec38 (patch) | |
tree | 8456853825fb5babcb721d3ad42029b3cc393611 | |
parent | c0d10c54ae8f2f0a875da4c717d55c701fa5b369 (diff) | |
download | bukkit-4716bcc6f875def8bc7c6121dfa0f06782d7ec38.tar bukkit-4716bcc6f875def8bc7c6121dfa0f06782d7ec38.tar.gz bukkit-4716bcc6f875def8bc7c6121dfa0f06782d7ec38.tar.lz bukkit-4716bcc6f875def8bc7c6121dfa0f06782d7ec38.tar.xz bukkit-4716bcc6f875def8bc7c6121dfa0f06782d7ec38.zip |
Fail fast on non rectangular crafting recipes
-rw-r--r-- | src/main/java/org/bukkit/inventory/ShapedRecipe.java | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/src/main/java/org/bukkit/inventory/ShapedRecipe.java index 2796473d..f3532589 100644 --- a/src/main/java/org/bukkit/inventory/ShapedRecipe.java +++ b/src/main/java/org/bukkit/inventory/ShapedRecipe.java @@ -46,9 +46,13 @@ public class ShapedRecipe implements Recipe { Validate.notNull(shape, "Must provide a shape"); Validate.isTrue(shape.length > 0 && shape.length < 4, "Crafting recipes should be 1, 2, 3 rows, not ", shape.length); + int lastLen = -1; for (String row : shape) { Validate.notNull(row, "Shape cannot have null rows"); Validate.isTrue(row.length() > 0 && row.length() < 4, "Crafting rows should be 1, 2, or 3 characters, not ", row.length()); + + Validate.isTrue(lastLen == -1 || lastLen == row.length(), "Crafting recipes must be rectangular"); + lastLen = row.length(); } this.rows = new String[shape.length]; for (int i = 0; i < shape.length; i++) { |