2525import net .coreprotect .utility .BlockUtils ;
2626import net .coreprotect .utility .ItemUtils ;
2727import net .coreprotect .utility .MaterialUtils ;
28+ import net .coreprotect .utility .SyntheticUsernames ;
2829import net .coreprotect .utility .WorldUtils ;
2930import net .coreprotect .utility .serialize .ItemMetaHandler ;
3031
@@ -57,7 +58,13 @@ else if (type == Material.JUKEBOX || type == Material.ARMOR_STAND) {
5758 return ;
5859 }
5960
60- String loggingContainerId = player .toLowerCase (Locale .ROOT ) + "." + location .getBlockX () + "." + location .getBlockY () + "." + location .getBlockZ ();
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 ();
6168 List <ItemStack []> oldList = ConfigHandler .oldContainer .get (loggingContainerId );
6269 ItemStack [] oi1 = oldList .get (0 );
6370 ItemStack [] oldInventory = ItemUtils .getContainerState (oi1 );
@@ -67,7 +74,7 @@ else if (type == Material.JUKEBOX || type == Material.ARMOR_STAND) {
6774 }
6875
6976 // Check if this is a dispenser with no actual changes
70- if (player . equals ( "#dispenser" ) && ItemUtils .compareContainers (oldInventory , newInventory )) {
77+ if ("#dispenser" . equals ( canonicalUser ) && ItemUtils .compareContainers (oldInventory , newInventory )) {
7178 // No changes detected, mark this dispenser in the dispenserNoChange map
7279 // Extract the location key from the loggingContainerId
7380 // Format: #dispenser.x.y.z
@@ -95,7 +102,7 @@ else if (type == Material.JUKEBOX || type == Material.ARMOR_STAND) {
95102
96103 // If we reach here, the dispenser event resulted in changes
97104 // Remove any pending event for this dispenser
98- if (player . equals ( "#dispenser" )) {
105+ if ("#dispenser" . equals ( canonicalUser )) {
99106 String [] parts = loggingContainerId .split ("\\ ." );
100107 if (parts .length >= 4 ) {
101108 int x = Integer .parseInt (parts [1 ]);
@@ -191,12 +198,12 @@ else if (item != null) {
191198 ItemUtils .mergeItems (type , newInventory );
192199
193200 if (type != Material .ENDER_CHEST ) {
194- logTransaction (preparedStmtContainer , batchCount , player , type , faceData , oldInventory , 0 , location );
195- logTransaction (preparedStmtContainer , batchCount , player , type , faceData , newInventory , 1 , location );
201+ logTransaction (preparedStmtContainer , batchCount , canonicalUser , type , faceData , oldInventory , 0 , location );
202+ logTransaction (preparedStmtContainer , batchCount , canonicalUser , type , faceData , newInventory , 1 , location );
196203 }
197204 else { // pass ender chest transactions to item logger
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 );
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 );
200207 }
201208
202209 oldList .remove (0 );
0 commit comments