Added logging and inventory rollback support for thrown/shot items
This commit is contained in:
parent
0d7fa2dd59
commit
b96f47cbac
19 changed files with 271 additions and 105 deletions
|
|
@ -224,10 +224,10 @@ public class Queue {
|
|||
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||
}
|
||||
|
||||
protected static void queueItemTransaction(String user, Location location, int time, int itemId) {
|
||||
protected static void queueItemTransaction(String user, Location location, int time, int offset, int itemId) {
|
||||
int currentConsumer = Consumer.currentConsumer;
|
||||
int consumerId = Consumer.newConsumerId(currentConsumer);
|
||||
addConsumer(currentConsumer, new Object[] { consumerId, Process.ITEM_TRANSACTION, null, 0, null, time, itemId, null });
|
||||
addConsumer(currentConsumer, new Object[] { consumerId, Process.ITEM_TRANSACTION, null, offset, null, time, itemId, null });
|
||||
queueStandardData(consumerId, currentConsumer, new String[] { user, null }, location);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,26 +11,28 @@ import net.coreprotect.database.logger.ItemLogger;
|
|||
|
||||
class ItemTransactionProcess extends Queue {
|
||||
|
||||
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, int forceData, int time, String user, Object object) {
|
||||
static void process(PreparedStatement preparedStmt, int batchCount, int processId, int id, int forceData, int time, int offset, String user, Object object) {
|
||||
if (object instanceof Location) {
|
||||
Location location = (Location) object;
|
||||
String loggingItemId = user.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
|
||||
|
||||
if (ConfigHandler.loggingItem.get(loggingItemId) != null) {
|
||||
int current_chest = ConfigHandler.loggingItem.get(loggingItemId);
|
||||
if (ConfigHandler.itemsDrop.get(loggingItemId) == null && ConfigHandler.itemsPickup.get(loggingItemId) == null) {
|
||||
if (ConfigHandler.itemsPickup.get(loggingItemId) == null && ConfigHandler.itemsDrop.get(loggingItemId) == null && ConfigHandler.itemsThrown.get(loggingItemId) == null && ConfigHandler.itemsShot.get(loggingItemId) == null) {
|
||||
return;
|
||||
}
|
||||
if (current_chest == forceData) {
|
||||
int currentTime = (int) (System.currentTimeMillis() / 1000L);
|
||||
if (currentTime > time) {
|
||||
ItemLogger.log(preparedStmt, batchCount, location, user);
|
||||
ConfigHandler.itemsDrop.remove(loggingItemId);
|
||||
ItemLogger.log(preparedStmt, batchCount, location, offset, user);
|
||||
ConfigHandler.itemsPickup.remove(loggingItemId);
|
||||
ConfigHandler.itemsDrop.remove(loggingItemId);
|
||||
ConfigHandler.itemsThrown.remove(loggingItemId);
|
||||
ConfigHandler.itemsShot.remove(loggingItemId);
|
||||
ConfigHandler.loggingItem.remove(loggingItemId);
|
||||
}
|
||||
else {
|
||||
Queue.queueItemTransaction(user, location, time, forceData);
|
||||
Queue.queueItemTransaction(user, location, time, offset, forceData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ public class Process {
|
|||
ContainerTransactionProcess.process(preparedStmtContainers, preparedStmtItems, i, processId, id, blockType, forceData, user, object);
|
||||
break;
|
||||
case Process.ITEM_TRANSACTION:
|
||||
ItemTransactionProcess.process(preparedStmtItems, i, processId, id, forceData, replaceData, user, object);
|
||||
ItemTransactionProcess.process(preparedStmtItems, i, processId, id, forceData, replaceData, blockData, user, object);
|
||||
break;
|
||||
case Process.STRUCTURE_GROWTH:
|
||||
StructureGrowthProcess.process(statement, preparedStmtBlocks, i, processId, id, user, object, forceData);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue