diff --git a/src/main/java/net/coreprotect/database/rollback/RollbackEntityHandler.java b/src/main/java/net/coreprotect/database/rollback/RollbackEntityHandler.java index 64add74..10cdf50 100644 --- a/src/main/java/net/coreprotect/database/rollback/RollbackEntityHandler.java +++ b/src/main/java/net/coreprotect/database/rollback/RollbackEntityHandler.java @@ -46,7 +46,7 @@ public class RollbackEntityHandler { * The username associated with this entity change * @return The number of entities affected (1 if successful, 0 otherwise) */ - public static int processEntity(Object[] row, int rollbackType, String finalUserString, int rowTypeRaw, int rowData, int rowAction, int rowRolledBack, int rowX, int rowY, int rowZ, int rowWorldId, int rowUserId, String rowUser) { + public static int processEntity(Object[] row, int rollbackType, String finalUserString, int oldTypeRaw, int rowTypeRaw, int rowData, int rowAction, int rowRolledBack, int rowX, int rowY, int rowZ, int rowWorldId, int rowUserId, String rowUser) { try { // Entity kill if (rowAction == 3) { @@ -76,12 +76,11 @@ public class RollbackEntityHandler { } } else if (rowTypeRaw <= 0) { - int oldTypeRaw = rowTypeRaw; // Attempt to remove entity if (rowRolledBack == 1) { boolean removed = false; int entityId = -1; - String entityName = EntityUtils.getEntityType(Math.abs(oldTypeRaw)).name(); + String entityName = EntityUtils.getEntityType(oldTypeRaw).name(); String token = "" + rowX + "." + rowY + "." + rowZ + "." + rowWorldId + "." + entityName + ""; Object[] cachedEntity = CacheHandler.entityCache.get(token); @@ -107,7 +106,7 @@ public class RollbackEntityHandler { } } else { - if (entity.getType().equals(EntityUtils.getEntityType(Math.abs(oldTypeRaw)))) { + if (entity.getType().equals(EntityUtils.getEntityType(oldTypeRaw))) { Location entityLocation = entity.getLocation(); int entityx = entityLocation.getBlockX(); int entityY = entityLocation.getBlockY(); diff --git a/src/main/java/net/coreprotect/database/rollback/RollbackProcessor.java b/src/main/java/net/coreprotect/database/rollback/RollbackProcessor.java index 5d84adb..2e719df 100644 --- a/src/main/java/net/coreprotect/database/rollback/RollbackProcessor.java +++ b/src/main/java/net/coreprotect/database/rollback/RollbackProcessor.java @@ -169,7 +169,7 @@ public class RollbackProcessor { } } else if (rowAction == 3) { // entity kill - entityCount += RollbackEntityHandler.processEntity(row, rollbackType, finalUserString, rowTypeRaw, rowData, rowAction, MaterialUtils.rolledBack((Integer) row[9], false), rowX, rowY, rowZ, rowWorldId, (Integer) row[2], rowUser); + entityCount += RollbackEntityHandler.processEntity(row, rollbackType, finalUserString, oldTypeRaw, rowTypeRaw, rowData, rowAction, MaterialUtils.rolledBack((Integer) row[9], false), rowX, rowY, rowZ, rowWorldId, (Integer) row[2], rowUser); } else { String world = WorldUtils.getWorldName(rowWorldId); diff --git a/src/main/java/net/coreprotect/database/rollback/RollbackUtil.java b/src/main/java/net/coreprotect/database/rollback/RollbackUtil.java index fe94662..e9268c3 100644 --- a/src/main/java/net/coreprotect/database/rollback/RollbackUtil.java +++ b/src/main/java/net/coreprotect/database/rollback/RollbackUtil.java @@ -533,16 +533,7 @@ public class RollbackUtil extends Lookup { * Additional data for the entity */ public static void queueEntitySpawn(String user, BlockState block, EntityType type, int data) { - if (Queue.class.getDeclaredMethods() != null) { - try { - java.lang.reflect.Method method = Queue.class.getDeclaredMethod("queueEntitySpawn", String.class, BlockState.class, EntityType.class, int.class); - method.setAccessible(true); - method.invoke(null, user, block, type, data); - } - catch (Exception e) { - e.printStackTrace(); - } - } + Queue.queueEntitySpawn(user, block, type, data); } /** @@ -556,16 +547,7 @@ public class RollbackUtil extends Lookup { * The row ID for the skull data */ public static void queueSkullUpdate(String user, BlockState block, int rowId) { - if (Queue.class.getDeclaredMethods() != null) { - try { - java.lang.reflect.Method method = Queue.class.getDeclaredMethod("queueSkullUpdate", String.class, BlockState.class, int.class); - method.setAccessible(true); - method.invoke(null, user, block, rowId); - } - catch (Exception e) { - e.printStackTrace(); - } - } + Queue.queueSkullUpdate(user, block, rowId); } /** @@ -581,15 +563,6 @@ public class RollbackUtil extends Lookup { * The time of the update */ public static void queueSignUpdate(String user, BlockState block, int action, int time) { - if (Queue.class.getDeclaredMethods() != null) { - try { - java.lang.reflect.Method method = Queue.class.getDeclaredMethod("queueSignUpdate", String.class, BlockState.class, int.class, int.class); - method.setAccessible(true); - method.invoke(null, user, block, action, time); - } - catch (Exception e) { - e.printStackTrace(); - } - } + Queue.queueSignUpdate(user, block, action, time); } } diff --git a/src/main/java/net/coreprotect/utility/EntityUtils.java b/src/main/java/net/coreprotect/utility/EntityUtils.java index 40f0dc0..a3c922f 100644 --- a/src/main/java/net/coreprotect/utility/EntityUtils.java +++ b/src/main/java/net/coreprotect/utility/EntityUtils.java @@ -131,4 +131,4 @@ public class EntityUtils extends Queue { return result; } -} \ No newline at end of file +}