From 3194c35bb9b1818b900692c7a95c4123cf58e95f Mon Sep 17 00:00:00 2001 From: Intelli Date: Tue, 13 Aug 2024 20:11:16 -0600 Subject: [PATCH] Fixed purge include parameter not functioning correctly for SQLite databases --- .../java/net/coreprotect/command/PurgeCommand.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/coreprotect/command/PurgeCommand.java b/src/main/java/net/coreprotect/command/PurgeCommand.java index 230b92e4..e6f2dd2d 100755 --- a/src/main/java/net/coreprotect/command/PurgeCommand.java +++ b/src/main/java/net/coreprotect/command/PurgeCommand.java @@ -285,18 +285,22 @@ public void run() { boolean error = false; if (!excludeTables.contains(table)) { try { + boolean purge = true; String timeLimit = ""; if (purgeTables.contains(table)) { - String blockRestriction = ""; + String blockRestriction = "("; if (hasBlockRestriction && restrictTables.contains(table)) { - blockRestriction = "type IN(" + includeBlockFinal + ") AND "; + blockRestriction = "type NOT IN(" + includeBlockFinal + ") OR (type IN(" + includeBlockFinal + ") AND "; + } + else if (hasBlockRestriction) { + purge = false; } if (argWid > 0 && worldTables.contains(table)) { - timeLimit = " WHERE (" + blockRestriction + "wid = '" + argWid + "' AND (time >= '" + timeEnd + "' OR time < '" + timeStart + "')) OR (" + blockRestriction + "wid != '" + argWid + "')"; + timeLimit = " WHERE (" + blockRestriction + "wid = '" + argWid + "' AND (time >= '" + timeEnd + "' OR time < '" + timeStart + "'))) OR (wid != '" + argWid + "')"; } - else if (argWid == 0) { - timeLimit = " WHERE " + blockRestriction + "(time >= '" + timeEnd + "' OR time < '" + timeStart + "')"; + else if (argWid == 0 && purge) { + timeLimit = " WHERE " + blockRestriction + "(time >= '" + timeEnd + "' OR time < '" + timeStart + "'))"; } } query = "INSERT INTO " + purgePrefix + table + " SELECT " + columns + " FROM " + ConfigHandler.prefix + table + timeLimit;