Skip to content

Commit de5a064

Browse files
committed
Fixes for copper golem logging (WIP)
1 parent 1f60dcc commit de5a064

File tree

4 files changed

+267
-73
lines changed

4 files changed

+267
-73
lines changed

src/main/java/net/coreprotect/consumer/process/Process.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ protected static void processConsumer(int processId, boolean lastRun) {
100100
if (data != null) {
101101
String user = data[0];
102102
String uuid = data[1];
103-
String normalizedUser = SyntheticUsernames.normalize(user);
104-
if (normalizedUser != null && ConfigHandler.playerIdCache.get(normalizedUser.toLowerCase(Locale.ROOT)) == null) {
105-
UserStatement.loadId(connection, normalizedUser, uuid);
103+
if (user != null && ConfigHandler.playerIdCache.get(user.toLowerCase(Locale.ROOT)) == null) {
104+
UserStatement.loadId(connection, user, uuid);
106105
}
107106
}
108107
}

src/main/java/net/coreprotect/database/logger/ContainerLogger.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import net.coreprotect.utility.BlockUtils;
2626
import net.coreprotect.utility.ItemUtils;
2727
import net.coreprotect.utility.MaterialUtils;
28-
import net.coreprotect.utility.SyntheticUsernames;
2928
import net.coreprotect.utility.WorldUtils;
3029
import net.coreprotect.utility.serialize.ItemMetaHandler;
3130

@@ -58,13 +57,7 @@ else if (type == Material.JUKEBOX || type == Material.ARMOR_STAND) {
5857
return;
5958
}
6059

61-
String uniqueUser = player;
62-
String canonicalUser = SyntheticUsernames.normalize(uniqueUser);
63-
if (canonicalUser == null) {
64-
canonicalUser = uniqueUser;
65-
}
66-
67-
String loggingContainerId = uniqueUser.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
60+
String loggingContainerId = player.toLowerCase(Locale.ROOT) + "." + location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ();
6861
List<ItemStack[]> oldList = ConfigHandler.oldContainer.get(loggingContainerId);
6962
ItemStack[] oi1 = oldList.get(0);
7063
ItemStack[] oldInventory = ItemUtils.getContainerState(oi1);
@@ -74,7 +67,7 @@ else if (type == Material.JUKEBOX || type == Material.ARMOR_STAND) {
7467
}
7568

7669
// Check if this is a dispenser with no actual changes
77-
if ("#dispenser".equals(canonicalUser) && ItemUtils.compareContainers(oldInventory, newInventory)) {
70+
if ("#dispenser".equals(player) && ItemUtils.compareContainers(oldInventory, newInventory)) {
7871
// No changes detected, mark this dispenser in the dispenserNoChange map
7972
// Extract the location key from the loggingContainerId
8073
// Format: #dispenser.x.y.z
@@ -102,7 +95,7 @@ else if (type == Material.JUKEBOX || type == Material.ARMOR_STAND) {
10295

10396
// If we reach here, the dispenser event resulted in changes
10497
// Remove any pending event for this dispenser
105-
if ("#dispenser".equals(canonicalUser)) {
98+
if ("#dispenser".equals(player)) {
10699
String[] parts = loggingContainerId.split("\\.");
107100
if (parts.length >= 4) {
108101
int x = Integer.parseInt(parts[1]);
@@ -198,12 +191,12 @@ else if (item != null) {
198191
ItemUtils.mergeItems(type, newInventory);
199192

200193
if (type != Material.ENDER_CHEST) {
201-
logTransaction(preparedStmtContainer, batchCount, canonicalUser, type, faceData, oldInventory, 0, location);
202-
logTransaction(preparedStmtContainer, batchCount, canonicalUser, type, faceData, newInventory, 1, location);
194+
logTransaction(preparedStmtContainer, batchCount, player, type, faceData, oldInventory, 0, location);
195+
logTransaction(preparedStmtContainer, batchCount, player, type, faceData, newInventory, 1, location);
203196
}
204197
else { // pass ender chest transactions to item logger
205-
ItemLogger.logTransaction(preparedStmtItems, batchCount, 0, canonicalUser, location, oldInventory, ItemLogger.ITEM_REMOVE_ENDER);
206-
ItemLogger.logTransaction(preparedStmtItems, batchCount, 0, canonicalUser, location, newInventory, ItemLogger.ITEM_ADD_ENDER);
198+
ItemLogger.logTransaction(preparedStmtItems, batchCount, 0, player, location, oldInventory, ItemLogger.ITEM_REMOVE_ENDER);
199+
ItemLogger.logTransaction(preparedStmtItems, batchCount, 0, player, location, newInventory, ItemLogger.ITEM_ADD_ENDER);
207200
}
208201

209202
oldList.remove(0);

0 commit comments

Comments
 (0)