Fixed dropper transactions not being logged when using Paper

This commit is contained in:
Intelli 2023-08-08 16:57:51 -06:00
parent d7910262be
commit 1b6d2ec667
2 changed files with 7 additions and 1 deletions

View File

@ -49,7 +49,7 @@ public final class BlockDispenseListener extends Queue implements Listener {
boolean dispenseSuccess = !event.getVelocity().equals(new Vector()); // true if velocity is set
boolean dispenseRelative = newBlock.getLocation().equals(velocityLocation); // true if velocity location matches relative location
if (!BlockPreDispenseListener.useBlockPreDispenseEvent) {
if (!BlockPreDispenseListener.useBlockPreDispenseEvent || (!BlockPreDispenseListener.useForDroppers && block.getType() == Material.DROPPER)) {
if (dispenseRelative || material.equals(Material.FLINT_AND_STEEL) || material.equals(Material.SHEARS)) {
forceItem = false;
}

View File

@ -1,5 +1,6 @@
package net.coreprotect.paper.listener;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
@ -18,6 +19,7 @@ import net.coreprotect.listener.player.InventoryChangeListener;
public final class BlockPreDispenseListener extends Queue implements Listener {
public static boolean useBlockPreDispenseEvent = true;
public static boolean useForDroppers = false;
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPreDispense(BlockPreDispenseEvent event) {
@ -29,6 +31,10 @@ public final class BlockPreDispenseListener extends Queue implements Listener {
BlockData blockData = block.getBlockData();
if (blockData instanceof Dispenser) {
if (!useForDroppers && block.getType() == Material.DROPPER) {
useForDroppers = true;
}
String user = "#dispenser";
ItemStack[] inventory = ((InventoryHolder) block.getState()).getInventory().getStorageContents();
InventoryChangeListener.inventoryTransaction(user, block.getLocation(), inventory);