mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-28 12:55:34 +01:00
Added interaction logging for players clicking item frames
This commit is contained in:
parent
fb79071ee7
commit
c652ce852f
@ -264,7 +264,7 @@ public class CoreProtectAPI extends Queue {
|
||||
if (Config.getGlobal().API_ENABLED) {
|
||||
if (user != null && location != null) {
|
||||
if (user.length() > 0) {
|
||||
Queue.queuePlayerInteraction(user, location.getBlock().getState());
|
||||
Queue.queuePlayerInteraction(user, location.getBlock().getState(), location.getBlock().getType());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -296,10 +296,10 @@ public class Queue {
|
||||
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 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);
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,17 @@ package net.coreprotect.consumer.process;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import net.coreprotect.database.logger.PlayerInteractLogger;
|
||||
|
||||
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) {
|
||||
BlockState block = (BlockState) object;
|
||||
PlayerInteractLogger.log(preparedStmt, batchCount, user, block);
|
||||
PlayerInteractLogger.log(preparedStmt, batchCount, user, block, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class Process {
|
||||
ContainerBreakProcess.process(preparedStmtContainers, i, processId, id, blockType, user, object);
|
||||
break;
|
||||
case Process.PLAYER_INTERACTION:
|
||||
PlayerInteractionProcess.process(preparedStmtBlocks, i, user, object);
|
||||
PlayerInteractionProcess.process(preparedStmtBlocks, i, user, object, blockType);
|
||||
break;
|
||||
case Process.CONTAINER_TRANSACTION:
|
||||
ContainerTransactionProcess.process(preparedStmtContainers, preparedStmtItems, i, processId, id, blockType, forceData, user, object);
|
||||
|
@ -19,9 +19,9 @@ public class PlayerInteractLogger {
|
||||
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 {
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
|
@ -62,6 +62,10 @@ public final class PlayerInteractEntityListener extends Queue implements Listene
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user