Skip to content

Commit

Permalink
v3.5.0.3
Browse files Browse the repository at this point in the history
-fix KamiMenu.fill not working

Took 6 minutes
  • Loading branch information
Jake-Moore committed Aug 30, 2024
1 parent d795633 commit fb7bbff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java.util.*

@Suppress("PropertyName")
var VERSION = "3.5.0.2"
var VERSION = "3.5.0.3"

plugins { // needed for the subprojects section to work
id("java")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,27 +208,29 @@ public void placeItems() {
}

public void placeItems(@Nullable Predicate<MenuItem> filter) {
int size = this.getSize();
for (MenuItem tickedItem : this.menuItems.values()) {
if (filter != null && !filter.test(tickedItem)) { continue; }
@Nullable ItemSlot itemSlot = tickedItem.getItemSlot();
if (itemSlot == null) { continue; }

// Build the new item, storing it back in the TickedItem for comparison on clicks
ItemStack item = tickedItem.buildItem();
if (item != null && item.getAmount() > 64) { item.setAmount(64); }
tickedItem.setLastItem(item);

// Update the inventory slots
for (int slot : itemSlot.get(this)) {
if (slot < 0 || slot >= size) { continue; }
super.setItem(slot, item);
}
}
this.menuItems.values().forEach(item -> this.placeItem(filter, item));
// Automatically fill using filler item, which can be set to null to disable
this.fill();
}

private void placeItem(@Nullable Predicate<MenuItem> filter, @NotNull MenuItem tickedItem) {
if (filter != null && !filter.test(tickedItem)) { return; }
@Nullable ItemSlot itemSlot = tickedItem.getItemSlot();
if (itemSlot == null) { return; }

// Build the new item, storing it back in the TickedItem for comparison on clicks
ItemStack item = tickedItem.buildItem();
if (item != null && item.getAmount() > 64) { item.setAmount(64); }
tickedItem.setLastItem(item);

// Update the inventory slots
int size = this.getSize();
for (int slot : itemSlot.get(this)) {
if (slot < 0 || slot >= size) { continue; }
super.setItem(slot, item);
}
}

// ------------------------------------------------------------ //
// Item Management (by ID) //
// ------------------------------------------------------------ //
Expand Down Expand Up @@ -325,7 +327,9 @@ private KamiMenu fill() {
if (excludedFillSlots.contains(i)) { continue; }
ItemStack here = getInventory().getItem(i);
if (here == null || here.getType() == Material.AIR) {
this.addMenuItem(new MenuItem(new StaticItemSlot(i), fillerItem.getIBuilders()));
MenuItem item = new MenuItem(new StaticItemSlot(i), fillerItem.getIBuilders());
this.addMenuItem(item); // Cache so it gets updated like other items
this.placeItem(null, item); // Set the item in the inventory
}
}

Expand Down

0 comments on commit fb7bbff

Please sign in to comment.