-
-
Notifications
You must be signed in to change notification settings - Fork 27
Description
What is happening?
Initially, the GUI looks like this — you can see a green book in the third row, and the first row is empty:

When I click on the green book, it moves to the first row and is removed both from the GUI and from the player’s inventory:

Clicking the green book in the first row should give it back to the player and move it to the third row again, returning the GUI to its original state.
The logic behind this is slightly more complex, the third row is dynamically built from the player’s inventory, which is why the green book appears and disappears from that row.
What did you expect to happen?
When I click the green book in the first row, the underlying logic executes correctly, logs confirm that the Set used to populate the first row is properly cleared.
However, the GUI is then redrawn with the green book still visible in the first row. Clicking it again keeps giving new green books to the player’s inventory, even though the internal data structure is empty:


Version
1.6.5-SNAPSHOT
Config
setup:
- " 12345 "
- " "
- " iiiiiii "
- " iiiiiii "
- " "Server/system Version
Paper 1.21.1
Log
This is the output of the .size() on the set before and after having applied the logic.
[21:39:02 INFO]: [TEST-core] SIZE:1
[21:39:02 INFO]: [TEST-core] SIZE:0What other programs/plugins are you running?
I tried with no other plugins
Additional context
This is how I'm creating the GUI's elements:
GuiElementGroup group = new GuiElementGroup('i');
HashMap<Integer, ? extends ItemStack> inv = viewer.getInventory().all(Material.KNOWLEDGE_BOOK);
for(Integer slot : inv.keySet()) {
ItemStack item = inv.get(slot).clone();
if(!item.getItemMeta().hasCustomModelData() || !ItemStorage.getRunes().containsKey(item.getItemMeta().getCustomModelData()))
continue;
WearableItem rune = ItemStorage.getRunes().get(item.getItemMeta().getCustomModelData());
if(rune.cannotBeUsed(target))
continue;
StaticGuiElement element = new StaticGuiElement(
'i',
item,
1,
click -> {
selectRuneLogic(item, false);
return true;
}
);
group.addElement(element);
}
addElement(group);
int i = 1;
Log.debug("SIZE2:{0}", RuneStorage.getEquippedRunes(target.getUniqueId()).size());
for(ItemStack item : RuneStorage.getEquippedRunes(target.getUniqueId())) {
int finalI = i;
DynamicGuiElement element = new DynamicGuiElement(
Character.forDigit(i, 10),
v -> new StaticGuiElement(
Character.forDigit(finalI, 10),
item,
1,
click -> {
selectRuneLogic(item, true);
return true;
}
)
);
addElement(element);
i++;
}
show(viewer);