Skip to content

Commit

Permalink
Fix Fix cache unsync w/ droppers & dispensers vaults
Browse files Browse the repository at this point in the history
  • Loading branch information
GroobleDierne committed Sep 8, 2024
1 parent 358730b commit 2b46a14
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/org/gestern/gringotts/event/AccountListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
Expand Down Expand Up @@ -132,6 +133,22 @@ public void run() {
}
}

@EventHandler
public void onDispenseEvent(BlockDispenseEvent event) {
if (event.getBlock().getState() instanceof InventoryHolder) {
AccountChest chest = getAccountChestFromHolder((InventoryHolder) event.getBlock().getState());
if (chest != null) {
new BukkitRunnable() {
@Override
public void run() {
chest.setCachedBalance(chest.balance(true));
Gringotts.instance.getDao().updateChestBalance(chest, chest.getCachedBalance());
}
}.runTask(Gringotts.instance);
}
}
}

/**
* Get the AccountChest associated with this {@link InventoryHolder}
* @param holder
Expand Down

0 comments on commit 2b46a14

Please sign in to comment.