Added interaction logging for players clicking item frames

This commit is contained in:
Intelli 2022-02-17 21:10:49 -07:00
parent fb79071ee7
commit c652ce852f
7 changed files with 14 additions and 9 deletions

View File

@ -264,7 +264,7 @@ public class CoreProtectAPI extends Queue {
if (Config.getGlobal().API_ENABLED) { if (Config.getGlobal().API_ENABLED) {
if (user != null && location != null) { if (user != null && location != null) {
if (user.length() > 0) { if (user.length() > 0) {
Queue.queuePlayerInteraction(user, location.getBlock().getState()); Queue.queuePlayerInteraction(user, location.getBlock().getState(), location.getBlock().getType());
return true; return true;
} }
} }

View File

@ -296,10 +296,10 @@ public class Queue {
queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), null }, new Object[] { timestamp, player.getLocation().clone() }); queueStandardData(consumerId, currentConsumer, new String[] { player.getName(), null }, new Object[] { timestamp, player.getLocation().clone() });
} }
protected static void queuePlayerInteraction(String user, BlockState block) { protected static void queuePlayerInteraction(String user, BlockState block, Material type) {
int currentConsumer = Consumer.currentConsumer; int currentConsumer = Consumer.currentConsumer;
int consumerId = Consumer.newConsumerId(currentConsumer); int consumerId = Consumer.newConsumerId(currentConsumer);
addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_INTERACTION, null, 0, null, 0, 0, null }); addConsumer(currentConsumer, new Object[] { consumerId, Process.PLAYER_INTERACTION, type, 0, null, 0, 0, null });
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block); queueStandardData(consumerId, currentConsumer, new String[] { user, null }, block);
} }

View File

@ -2,16 +2,17 @@ package net.coreprotect.consumer.process;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import org.bukkit.Material;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import net.coreprotect.database.logger.PlayerInteractLogger; import net.coreprotect.database.logger.PlayerInteractLogger;
class PlayerInteractionProcess { class PlayerInteractionProcess {
static void process(PreparedStatement preparedStmt, int batchCount, String user, Object object) { static void process(PreparedStatement preparedStmt, int batchCount, String user, Object object, Material type) {
if (object instanceof BlockState) { if (object instanceof BlockState) {
BlockState block = (BlockState) object; BlockState block = (BlockState) object;
PlayerInteractLogger.log(preparedStmt, batchCount, user, block); PlayerInteractLogger.log(preparedStmt, batchCount, user, block, type);
} }
} }
} }

View File

@ -143,7 +143,7 @@ public class Process {
ContainerBreakProcess.process(preparedStmtContainers, i, processId, id, blockType, user, object); ContainerBreakProcess.process(preparedStmtContainers, i, processId, id, blockType, user, object);
break; break;
case Process.PLAYER_INTERACTION: case Process.PLAYER_INTERACTION:
PlayerInteractionProcess.process(preparedStmtBlocks, i, user, object); PlayerInteractionProcess.process(preparedStmtBlocks, i, user, object, blockType);
break; break;
case Process.CONTAINER_TRANSACTION: case Process.CONTAINER_TRANSACTION:
ContainerTransactionProcess.process(preparedStmtContainers, preparedStmtItems, i, processId, id, blockType, forceData, user, object); ContainerTransactionProcess.process(preparedStmtContainers, preparedStmtItems, i, processId, id, blockType, forceData, user, object);

View File

@ -19,9 +19,9 @@ public class PlayerInteractLogger {
throw new IllegalStateException("Database class"); throw new IllegalStateException("Database class");
} }
public static void log(PreparedStatement preparedStmt, int batchCount, String user, BlockState block) { public static void log(PreparedStatement preparedStmt, int batchCount, String user, BlockState block, Material blockType) {
try { try {
int type = Util.getBlockId(block.getType().name(), true); int type = Util.getBlockId(blockType.name(), true);
if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || Util.getType(type).equals(Material.AIR) || Util.getType(type).equals(Material.CAVE_AIR)) { if (ConfigHandler.blacklist.get(user.toLowerCase(Locale.ROOT)) != null || Util.getType(type).equals(Material.AIR) || Util.getType(type).equals(Material.CAVE_AIR)) {
return; return;
} }

View File

@ -62,6 +62,10 @@ public final class PlayerInteractEntityListener extends Queue implements Listene
return; return;
} }
if (frame.getItem().getType() != Material.AIR && event.getHand().equals(EquipmentSlot.HAND) && Config.getConfig(player.getWorld()).PLAYER_INTERACTIONS) {
Queue.queuePlayerInteraction(player.getName(), entity.getLocation().getBlock().getState(), Material.ITEM_FRAME);
}
if (!Config.getConfig(player.getWorld()).ITEM_TRANSACTIONS) { if (!Config.getConfig(player.getWorld()).ITEM_TRANSACTIONS) {
return; return;
} }

View File

@ -587,7 +587,7 @@ public final class PlayerInteractListener extends Queue implements Listener {
} }
} }
Queue.queuePlayerInteraction(player.getName(), interactBlock.getState()); Queue.queuePlayerInteraction(player.getName(), interactBlock.getState(), type);
} }
} }
else if (BlockGroup.LIGHTABLES.contains(type)) { // extinguishing a lit block such as a campfire else if (BlockGroup.LIGHTABLES.contains(type)) { // extinguishing a lit block such as a campfire