diff --git a/core/src/main/java/cc/dreamcode/menu/DreamMenuBuilder.java b/core/src/main/java/cc/dreamcode/menu/DreamMenuBuilder.java index cb5ae01..4a073ae 100644 --- a/core/src/main/java/cc/dreamcode/menu/DreamMenuBuilder.java +++ b/core/src/main/java/cc/dreamcode/menu/DreamMenuBuilder.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.stream.Stream; @Getter @RequiredArgsConstructor @@ -39,6 +40,71 @@ public DreamMenuBuilder fillBackground(@NonNull I i) { return this; } + public DreamMenuBuilder fillTop(@NonNull I i) { + Stream.of( + MenuUtil.countSlot(1, 1), + MenuUtil.countSlot(1, 2), + MenuUtil.countSlot(1, 3), + MenuUtil.countSlot(1, 4), + MenuUtil.countSlot(1, 5), + MenuUtil.countSlot(1, 6), + MenuUtil.countSlot(1, 7), + MenuUtil.countSlot(1, 8), + MenuUtil.countSlot(1, 9) + ).forEach(slot -> { + if (!this.items.containsKey(slot)) { + this.items.put(slot, i); + } + }); + + return this; + } + + public DreamMenuBuilder fillBottom(@NonNull I i) { + Stream.of( + MenuUtil.countSlot(this.rows, 1), + MenuUtil.countSlot(this.rows, 2), + MenuUtil.countSlot(this.rows, 3), + MenuUtil.countSlot(this.rows, 4), + MenuUtil.countSlot(this.rows, 5), + MenuUtil.countSlot(this.rows, 6), + MenuUtil.countSlot(this.rows, 7), + MenuUtil.countSlot(this.rows, 8), + MenuUtil.countSlot(this.rows, 9) + ).forEach(slot -> { + if (!this.items.containsKey(slot)) { + this.items.put(slot, i); + } + }); + + return this; + } + + public DreamMenuBuilder fillTopAndBottom(@NonNull I i) { + this.fillTop(i); + this.fillBottom(i); + + return this; + } + + public DreamMenuBuilder fillMargin(@NonNull I i) { + this.fillTop(i); + this.fillBottom(i); + + for (int row = 2; row < this.rows; row++) { + Stream.of( + MenuUtil.countSlot(row, 1), + MenuUtil.countSlot(row, 9) + ).forEach(slot -> { + if (!this.items.containsKey(slot)) { + this.items.put(slot, i); + } + }); + } + + return this; + } + public abstract B buildEmpty(); public abstract B buildEmpty(@NonNull Map replaceMap); public abstract B buildWithItems();