Added logging for items traded with villagers (MC 1.18+)
This commit is contained in:
parent
7bc95931d2
commit
83fc221bf2
15 changed files with 193 additions and 37 deletions
|
|
@ -450,6 +450,8 @@ public class Lookup extends Queue {
|
|||
actionText = actionText.append(ItemLogger.ITEM_BREAK);
|
||||
actionText.append(",").append(ItemLogger.ITEM_DESTROY);
|
||||
actionText.append(",").append(ItemLogger.ITEM_CREATE);
|
||||
actionText.append(",").append(ItemLogger.ITEM_SELL);
|
||||
actionText.append(",").append(ItemLogger.ITEM_BUY);
|
||||
actionExclude = actionText.toString();
|
||||
}
|
||||
|
||||
|
|
@ -480,6 +482,7 @@ public class Lookup extends Queue {
|
|||
actionText.append(",").append(ItemLogger.ITEM_PICKUP);
|
||||
actionText.append(",").append(ItemLogger.ITEM_REMOVE_ENDER);
|
||||
actionText.append(",").append(ItemLogger.ITEM_CREATE);
|
||||
actionText.append(",").append(ItemLogger.ITEM_BUY);
|
||||
}
|
||||
if (actionTarget == ItemLogger.ITEM_ADD) {
|
||||
actionText.append(",").append(ItemLogger.ITEM_DROP);
|
||||
|
|
@ -488,6 +491,7 @@ public class Lookup extends Queue {
|
|||
actionText.append(",").append(ItemLogger.ITEM_SHOOT);
|
||||
actionText.append(",").append(ItemLogger.ITEM_BREAK);
|
||||
actionText.append(",").append(ItemLogger.ITEM_DESTROY);
|
||||
actionText.append(",").append(ItemLogger.ITEM_SELL);
|
||||
}
|
||||
}
|
||||
// If just looking up drops/pickups, include ender chest transactions
|
||||
|
|
|
|||
|
|
@ -1074,8 +1074,8 @@ public class Rollback extends Queue {
|
|||
}
|
||||
|
||||
int inventoryAction = 0;
|
||||
if (rowAction == ItemLogger.ITEM_DROP || rowAction == ItemLogger.ITEM_PICKUP || rowAction == ItemLogger.ITEM_THROW || rowAction == ItemLogger.ITEM_SHOOT || rowAction == ItemLogger.ITEM_BREAK || rowAction == ItemLogger.ITEM_DESTROY || rowAction == ItemLogger.ITEM_CREATE) {
|
||||
inventoryAction = ((rowAction == ItemLogger.ITEM_PICKUP || rowAction == ItemLogger.ITEM_CREATE) ? 1 : 0);
|
||||
if (rowAction == ItemLogger.ITEM_DROP || rowAction == ItemLogger.ITEM_PICKUP || rowAction == ItemLogger.ITEM_THROW || rowAction == ItemLogger.ITEM_SHOOT || rowAction == ItemLogger.ITEM_BREAK || rowAction == ItemLogger.ITEM_DESTROY || rowAction == ItemLogger.ITEM_CREATE || rowAction == ItemLogger.ITEM_SELL || rowAction == ItemLogger.ITEM_BUY) {
|
||||
inventoryAction = ((rowAction == ItemLogger.ITEM_PICKUP || rowAction == ItemLogger.ITEM_CREATE || rowAction == ItemLogger.ITEM_BUY) ? 1 : 0);
|
||||
}
|
||||
else if (rowAction == ItemLogger.ITEM_REMOVE_ENDER || rowAction == ItemLogger.ITEM_ADD_ENDER) {
|
||||
inventoryAction = (rowAction == ItemLogger.ITEM_REMOVE_ENDER ? 1 : 0);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ public class ItemLogger {
|
|||
public static final int ITEM_BREAK = 8;
|
||||
public static final int ITEM_DESTROY = 9;
|
||||
public static final int ITEM_CREATE = 10;
|
||||
public static final int ITEM_SELL = 11;
|
||||
public static final int ITEM_BUY = 12;
|
||||
|
||||
private ItemLogger() {
|
||||
throw new IllegalStateException("Database class");
|
||||
|
|
@ -78,6 +80,16 @@ public class ItemLogger {
|
|||
itemCreates = createList.toArray(itemCreates);
|
||||
createList.clear();
|
||||
|
||||
List<ItemStack> sellList = ConfigHandler.itemsSell.getOrDefault(loggingItemId, new ArrayList<>());
|
||||
ItemStack[] itemSells = new ItemStack[sellList.size()];
|
||||
itemSells = sellList.toArray(itemSells);
|
||||
sellList.clear();
|
||||
|
||||
List<ItemStack> buyList = ConfigHandler.itemsBuy.getOrDefault(loggingItemId, new ArrayList<>());
|
||||
ItemStack[] itemBuys = new ItemStack[buyList.size()];
|
||||
itemBuys = buyList.toArray(itemBuys);
|
||||
buyList.clear();
|
||||
|
||||
Util.mergeItems(null, itemPickups);
|
||||
Util.mergeItems(null, itemDrops);
|
||||
Util.mergeItems(null, itemThrows);
|
||||
|
|
@ -85,6 +97,8 @@ public class ItemLogger {
|
|||
Util.mergeItems(null, itemBreaks);
|
||||
Util.mergeItems(null, itemDestroys);
|
||||
Util.mergeItems(null, itemCreates);
|
||||
Util.mergeItems(null, itemSells);
|
||||
Util.mergeItems(null, itemBuys);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemPickups, ITEM_PICKUP);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemDrops, ITEM_DROP);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemThrows, ITEM_THROW);
|
||||
|
|
@ -92,6 +106,8 @@ public class ItemLogger {
|
|||
logTransaction(preparedStmt, batchCount, offset, user, location, itemBreaks, ITEM_BREAK);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemDestroys, ITEM_DESTROY);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemCreates, ITEM_CREATE);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemSells, ITEM_SELL);
|
||||
logTransaction(preparedStmt, batchCount, offset, user, location, itemBuys, ITEM_BUY);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue