mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-09-28 04:17:41 +02:00
Added logging for droppers adding items to other containers
This commit is contained in:
parent
37fc9af300
commit
aa2ee7225c
@ -18,7 +18,7 @@ import net.coreprotect.utility.Util;
|
|||||||
|
|
||||||
public final class HopperPullListener {
|
public final class HopperPullListener {
|
||||||
|
|
||||||
static void processHopperPull(Location location, InventoryHolder sourceHolder, InventoryHolder destinationHolder, ItemStack item) {
|
static void processHopperPull(Location location, String user, InventoryHolder sourceHolder, InventoryHolder destinationHolder, ItemStack item) {
|
||||||
String loggingChestId = "#hopper-pull." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
|
String loggingChestId = "#hopper-pull." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
|
||||||
Object[] lastAbort = ConfigHandler.hopperAbort.get(loggingChestId);
|
Object[] lastAbort = ConfigHandler.hopperAbort.get(loggingChestId);
|
||||||
if (lastAbort != null) {
|
if (lastAbort != null) {
|
||||||
@ -91,7 +91,7 @@ public final class HopperPullListener {
|
|||||||
|
|
||||||
originalSource[inventoryContents.length] = movedItem;
|
originalSource[inventoryContents.length] = movedItem;
|
||||||
InventoryChangeListener.checkTasks(taskStarted);
|
InventoryChangeListener.checkTasks(taskStarted);
|
||||||
InventoryChangeListener.onInventoryInteract("#hopper", sourceInventory, originalSource, null, sourceInventory.getLocation(), true);
|
InventoryChangeListener.onInventoryInteract(user, sourceInventory, originalSource, null, sourceInventory.getLocation(), true);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -18,7 +18,7 @@ import net.coreprotect.utility.Util;
|
|||||||
|
|
||||||
public final class HopperPushListener {
|
public final class HopperPushListener {
|
||||||
|
|
||||||
static void processHopperPush(Location location, InventoryHolder sourceHolder, InventoryHolder destinationHolder, ItemStack item) {
|
static void processHopperPush(Location location, String user, InventoryHolder sourceHolder, InventoryHolder destinationHolder, ItemStack item) {
|
||||||
Location destinationLocation = destinationHolder.getInventory().getLocation();
|
Location destinationLocation = destinationHolder.getInventory().getLocation();
|
||||||
if (destinationLocation == null) {
|
if (destinationLocation == null) {
|
||||||
return;
|
return;
|
||||||
@ -97,7 +97,7 @@ public final class HopperPushListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InventoryChangeListener.checkTasks(taskStarted);
|
InventoryChangeListener.checkTasks(taskStarted);
|
||||||
InventoryChangeListener.onInventoryInteract("#hopper", destinationInventory, originalDestination, null, destinationInventory.getLocation(), true);
|
InventoryChangeListener.onInventoryInteract(user, destinationInventory, originalDestination, null, destinationInventory.getLocation(), true);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -344,10 +344,16 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||||||
|
|
||||||
if (hopperTransactions) {
|
if (hopperTransactions) {
|
||||||
if (Validate.isHopper(destinationHolder) && (Validate.isContainer(sourceHolder) && !Validate.isHopper(sourceHolder))) {
|
if (Validate.isHopper(destinationHolder) && (Validate.isContainer(sourceHolder) && !Validate.isHopper(sourceHolder))) {
|
||||||
HopperPullListener.processHopperPull(location, sourceHolder, destinationHolder, event.getItem());
|
HopperPullListener.processHopperPull(location, "#hopper", sourceHolder, destinationHolder, event.getItem());
|
||||||
}
|
}
|
||||||
else if (Validate.isHopper(sourceHolder) && (Validate.isContainer(destinationHolder) && !Validate.isHopper(destinationHolder))) {
|
else if (Validate.isHopper(sourceHolder) && (Validate.isContainer(destinationHolder) && !Validate.isHopper(destinationHolder))) {
|
||||||
HopperPushListener.processHopperPush(location, sourceHolder, destinationHolder, event.getItem());
|
HopperPushListener.processHopperPush(location, "#hopper", sourceHolder, destinationHolder, event.getItem());
|
||||||
|
}
|
||||||
|
else if (Validate.isDropper(sourceHolder) && (Validate.isContainer(destinationHolder))) {
|
||||||
|
HopperPullListener.processHopperPull(location, "#dropper", sourceHolder, destinationHolder, event.getItem());
|
||||||
|
if (!Validate.isHopper(destinationHolder)) {
|
||||||
|
HopperPushListener.processHopperPush(location, "#dropper", sourceHolder, destinationHolder, event.getItem());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -362,6 +368,6 @@ public final class InventoryChangeListener extends Queue implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HopperPullListener.processHopperPull(location, sourceHolder, destinationHolder, event.getItem());
|
HopperPullListener.processHopperPull(location, "#hopper", sourceHolder, destinationHolder, event.getItem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.coreprotect.utility;
|
package net.coreprotect.utility;
|
||||||
|
|
||||||
import org.bukkit.block.DoubleChest;
|
import org.bukkit.block.DoubleChest;
|
||||||
|
import org.bukkit.block.Dropper;
|
||||||
import org.bukkit.block.Hopper;
|
import org.bukkit.block.Hopper;
|
||||||
import org.bukkit.entity.minecart.HopperMinecart;
|
import org.bukkit.entity.minecart.HopperMinecart;
|
||||||
import org.bukkit.inventory.BlockInventoryHolder;
|
import org.bukkit.inventory.BlockInventoryHolder;
|
||||||
@ -16,6 +17,10 @@ public class Validate {
|
|||||||
return (inventoryHolder instanceof Hopper || inventoryHolder instanceof HopperMinecart);
|
return (inventoryHolder instanceof Hopper || inventoryHolder instanceof HopperMinecart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isDropper(InventoryHolder inventoryHolder) {
|
||||||
|
return (inventoryHolder instanceof Dropper);
|
||||||
|
}
|
||||||
|
|
||||||
/* check if valid hopper destination */
|
/* check if valid hopper destination */
|
||||||
public static boolean isContainer(InventoryHolder inventoryHolder) {
|
public static boolean isContainer(InventoryHolder inventoryHolder) {
|
||||||
return (inventoryHolder instanceof BlockInventoryHolder || inventoryHolder instanceof DoubleChest);
|
return (inventoryHolder instanceof BlockInventoryHolder || inventoryHolder instanceof DoubleChest);
|
||||||
|
Loading…
Reference in New Issue
Block a user