|
6 | 6 | import com.wizardlybump17.wlib.inventory.item.InventoryNavigator; |
7 | 7 | import com.wizardlybump17.wlib.inventory.item.ItemButton; |
8 | 8 | import com.wizardlybump17.wlib.inventory.listener.InventoryListener; |
| 9 | +import com.wizardlybump17.wlib.item.ItemBuilder; |
9 | 10 | import com.wizardlybump17.wlib.util.MapUtils; |
10 | 11 | import com.wizardlybump17.wlib.util.ObjectUtil; |
11 | 12 | import lombok.AccessLevel; |
@@ -113,6 +114,37 @@ public PaginatedInventoryBuilder shapeReplacements(@NonNull Map<Character, ItemB |
113 | 114 | return this; |
114 | 115 | } |
115 | 116 |
|
| 117 | + public @NotNull PaginatedInventoryBuilder setReplacementItemStackByCustomData(@NotNull Object key, @Nullable Object value, @NotNull Supplier<ItemStack> itemSupplier) { |
| 118 | + for (ItemButton button : shapeReplacements.values()) |
| 119 | + if (Objects.equals(button.getCustomData().get(key), value)) |
| 120 | + button.setItem(itemSupplier); |
| 121 | + return this; |
| 122 | + } |
| 123 | + |
| 124 | + public @NotNull PaginatedInventoryBuilder setReplacementItemStackByCustomData(@NotNull Object key, @Nullable Object value, @NotNull ItemStack item) { |
| 125 | + Supplier<ItemStack> itemSupplier = () -> item; |
| 126 | + for (ItemButton button : shapeReplacements.values()) |
| 127 | + if (Objects.equals(button.getCustomData().get(key), value)) |
| 128 | + button.setItem(itemSupplier); |
| 129 | + return this; |
| 130 | + } |
| 131 | + |
| 132 | + public @NotNull PaginatedInventoryBuilder setReplacementItemByCustomData(@NotNull Object key, @Nullable Object value, @NotNull Supplier<ItemBuilder> itemSupplier) { |
| 133 | + Supplier<ItemStack> itemStackSupplier = () -> itemSupplier.get().build(); |
| 134 | + for (ItemButton button : shapeReplacements.values()) |
| 135 | + if (Objects.equals(button.getCustomData().get(key), value)) |
| 136 | + button.setItem(itemStackSupplier); |
| 137 | + return this; |
| 138 | + } |
| 139 | + |
| 140 | + public @NotNull PaginatedInventoryBuilder setReplacementItemByCustomData(@NotNull Object key, @Nullable Object value, @NotNull ItemBuilder item) { |
| 141 | + Supplier<ItemStack> itemSupplier = item::build; |
| 142 | + for (ItemButton button : shapeReplacements.values()) |
| 143 | + if (Objects.equals(button.getCustomData().get(key), value)) |
| 144 | + button.setItem(itemSupplier); |
| 145 | + return this; |
| 146 | + } |
| 147 | + |
116 | 148 | public PaginatedInventoryBuilder content(@Nullable List<ItemButton> content) { |
117 | 149 | this.content = content == null ? new ArrayList<>() : content; |
118 | 150 | checkNullContent(); |
|
0 commit comments