Skip to content

Commit 6a910da

Browse files
Fix AbstractGui#getAllInventories missing inventories
1 parent 4d8c07d commit 6a910da

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

invui-core/src/main/java/xyz/xenondevs/invui/gui/AbstractGui.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ protected int putIntoFirstInventory(UpdateReason updateReason, ItemStack itemSta
466466
* @return A map of all {@link Inventory Inventories} and their slots that are visible.
467467
*/
468468
public Map<Inventory, Set<Integer>> getAllInventorySlots(Inventory... ignored) {
469-
TreeMap<Inventory, Set<Integer>> slots = new TreeMap<>(Comparator.comparingInt(Inventory::getGuiPriority).reversed());
469+
HashMap<Inventory, Set<Integer>> slots = new HashMap<>();
470470
Set<Inventory> ignoredSet = Arrays.stream(ignored).collect(Collectors.toSet());
471471

472472
for (SlotElement element : slotElements) {
@@ -484,7 +484,9 @@ public Map<Inventory, Set<Integer>> getAllInventorySlots(Inventory... ignored) {
484484
}
485485
}
486486

487-
return slots;
487+
return slots.entrySet().stream()
488+
.sorted(Comparator.<Map.Entry<Inventory, Set<Integer>>>comparingInt(entry -> entry.getKey().getGuiPriority()).reversed())
489+
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> a, LinkedHashMap::new));
488490
}
489491

490492
/**

invui-core/src/main/java/xyz/xenondevs/invui/inventory/ObscuredInventory.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,14 @@ public void setPreUpdateHandler(@Nullable Consumer<@NotNull ItemPreUpdateEvent>
127127
throw new UnsupportedOperationException("Update handlers need to be set in the backing inventory");
128128
}
129129

130+
@Override
131+
public int getGuiPriority() {
132+
return inventory.getGuiPriority();
133+
}
134+
135+
@Override
136+
public void setGuiPriority(int guiPriority) {
137+
throw new UnsupportedOperationException("Gui priority needs to be set in the backing inventory");
138+
}
139+
130140
}

0 commit comments

Comments
 (0)