use of io.github.wysohn.triggerreactor.sponge.bridge.SpongeItemStack in project TriggerReactor by wysohn.
the class InventoryEditManager method saveEdit.
@Override
public void saveEdit(IPlayer player) {
UUID u = player.getUniqueId();
if (!suspended.containsKey(u)) {
return;
}
Inventory inv = suspended.get(u).get();
InventoryTrigger trigger = sessions.get(u);
int size = inv.capacity();
IItemStack[] iitems = new IItemStack[size];
for (Inventory slot : inv.slots()) {
slot.getInventoryProperty(SlotIndex.class).ifPresent(slotIndex -> slot.peek().ifPresent(itemStack -> iitems[slotIndex.getValue()] = new SpongeItemStack(itemStack)));
}
// TODO this causes an error waaay down the call chain. replaceItems also saves the inventory trigger manager
// but while trying to write the new data, NPE is thrown. Starting a new edit shows that the new data at least
// gets written to the trigger, but reloading will throw away the edits.
// None of the items I want to save are null, so that isn't the source of the NPE.
// I know this because item.createSnapshot() in the sponge InventoryTriggerManager.writeItemsList() succeeds.
// please investigate this wysohn, because I have no idea at all why it can't save.
replaceItems(trigger, iitems);
stopEdit(player);
player.sendMessage("Saved edits");
}
Aggregations