Added support for time ranges in the time parameter
This commit is contained in:
parent
a596dd66a9
commit
0bbeee65e8
11 changed files with 193 additions and 99 deletions
|
|
@ -28,11 +28,11 @@ import net.coreprotect.utility.Util;
|
|||
|
||||
public class ContainerRollback extends Queue {
|
||||
|
||||
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius, long checkTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType) {
|
||||
public static void performContainerRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, final Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType) {
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
long timeStart = System.currentTimeMillis();
|
||||
|
||||
final List<Object[]> lookupList = Lookup.performLookupRaw(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, null, checkTime, -1, -1, restrictWorld, lookup);
|
||||
final List<Object[]> lookupList = Lookup.performLookupRaw(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, null, startTime, endTime, -1, -1, restrictWorld, lookup);
|
||||
if (rollbackType == 1) {
|
||||
Collections.reverse(lookupList);
|
||||
}
|
||||
|
|
@ -164,8 +164,8 @@ public class ContainerRollback extends Queue {
|
|||
|
||||
rollbackHashData = ConfigHandler.rollbackHash.get(finalUserString);
|
||||
int blockCount = rollbackHashData[1];
|
||||
long endTime = System.currentTimeMillis();
|
||||
double totalSeconds = (endTime - startTime) / 1000.0;
|
||||
long timeFinish = System.currentTimeMillis();
|
||||
double totalSeconds = (timeFinish - timeStart) / 1000.0;
|
||||
|
||||
if (user != null) {
|
||||
int file = -1;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class Lookup extends Queue {
|
|||
return newList;
|
||||
}
|
||||
|
||||
public static long countLookupRows(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long checkTime, boolean restrictWorld, boolean lookup) {
|
||||
public static long countLookupRows(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, boolean restrictWorld, boolean lookup) {
|
||||
Long rows = 0L;
|
||||
|
||||
try {
|
||||
|
|
@ -84,7 +84,7 @@ public class Lookup extends Queue {
|
|||
}
|
||||
Consumer.isPaused = true;
|
||||
|
||||
ResultSet results = rawLookupResultSet(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, null, checkTime, -1, -1, restrictWorld, lookup, true);
|
||||
ResultSet results = rawLookupResultSet(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, null, startTime, endTime, -1, -1, restrictWorld, lookup, true);
|
||||
while (results.next()) {
|
||||
int resultTable = results.getInt("tbl");
|
||||
long count = results.getLong("count");
|
||||
|
|
@ -102,11 +102,11 @@ public class Lookup extends Queue {
|
|||
return rows;
|
||||
}
|
||||
|
||||
public static List<String[]> performLookup(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long checkTime, boolean restrictWorld, boolean lookup) {
|
||||
public static List<String[]> performLookup(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup) {
|
||||
List<String[]> newList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
List<Object[]> lookupList = performLookupRaw(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, null, checkTime, -1, -1, restrictWorld, lookup);
|
||||
List<Object[]> lookupList = performLookupRaw(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, null, startTime, endTime, -1, -1, restrictWorld, lookup);
|
||||
newList = convertRawLookup(statement, lookupList);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
@ -116,7 +116,7 @@ public class Lookup extends Queue {
|
|||
return newList;
|
||||
}
|
||||
|
||||
static List<Object[]> performLookupRaw(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long checkTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
static List<Object[]> performLookupRaw(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
List<Object[]> list = new ArrayList<>();
|
||||
List<Integer> invalidRollbackActions = new ArrayList<>();
|
||||
invalidRollbackActions.add(2);
|
||||
|
|
@ -136,7 +136,7 @@ public class Lookup extends Queue {
|
|||
|
||||
Consumer.isPaused = true;
|
||||
|
||||
ResultSet results = rawLookupResultSet(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, rowData, checkTime, limitOffset, limitCount, restrictWorld, lookup, false);
|
||||
ResultSet results = rawLookupResultSet(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, rowData, startTime, endTime, limitOffset, limitCount, restrictWorld, lookup, false);
|
||||
|
||||
while (results.next()) {
|
||||
if (actionList.contains(6) || actionList.contains(7)) {
|
||||
|
|
@ -272,11 +272,11 @@ public class Lookup extends Queue {
|
|||
return list;
|
||||
}
|
||||
|
||||
public static List<String[]> performPartialLookup(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long checkTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
public static List<String[]> performPartialLookup(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup) {
|
||||
List<String[]> newList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
List<Object[]> lookupList = performLookupRaw(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, rowData, checkTime, limitOffset, limitCount, restrictWorld, lookup);
|
||||
List<Object[]> lookupList = performLookupRaw(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, rowData, startTime, endTime, limitOffset, limitCount, restrictWorld, lookup);
|
||||
newList = convertRawLookup(statement, lookupList);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
@ -286,7 +286,7 @@ public class Lookup extends Queue {
|
|||
return newList;
|
||||
}
|
||||
|
||||
private static ResultSet rawLookupResultSet(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long checkTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup, boolean count) {
|
||||
private static ResultSet rawLookupResultSet(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, Long[] rowData, long startTime, long endTime, int limitOffset, int limitCount, boolean restrictWorld, boolean lookup, boolean count) {
|
||||
ResultSet results = null;
|
||||
|
||||
try {
|
||||
|
|
@ -570,8 +570,12 @@ public class Lookup extends Queue {
|
|||
queryBlock = queryBlock + " user NOT IN(" + excludeUsers + ") AND";
|
||||
}
|
||||
|
||||
if (checkTime > 0) {
|
||||
queryBlock = queryBlock + " time > '" + checkTime + "' AND";
|
||||
if (startTime > 0) {
|
||||
queryBlock = queryBlock + " time > '" + startTime + "' AND";
|
||||
}
|
||||
|
||||
if (endTime > 0) {
|
||||
queryBlock = queryBlock + " time <= '" + endTime + "' AND";
|
||||
}
|
||||
|
||||
if (actionList.contains(10)) {
|
||||
|
|
|
|||
|
|
@ -95,15 +95,15 @@ import net.coreprotect.utility.entity.HangingUtil;
|
|||
|
||||
public class Rollback extends Queue {
|
||||
|
||||
public static List<String[]> performRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long checkTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType, final int preview) {
|
||||
public static List<String[]> performRollbackRestore(Statement statement, CommandSender user, List<String> checkUuids, List<String> checkUsers, String timeString, List<Object> restrictList, List<Object> excludeList, List<String> excludeUserList, List<Integer> actionList, Location location, Integer[] radius, long startTime, long endTime, boolean restrictWorld, boolean lookup, boolean verbose, final int rollbackType, final int preview) {
|
||||
List<String[]> list = new ArrayList<>();
|
||||
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
long timeStart = System.currentTimeMillis();
|
||||
List<Object[]> lookupList = new ArrayList<>();
|
||||
|
||||
if (!actionList.contains(4) && !actionList.contains(5) && !checkUsers.contains("#container")) {
|
||||
lookupList = Lookup.performLookupRaw(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, null, checkTime, -1, -1, restrictWorld, lookup);
|
||||
lookupList = Lookup.performLookupRaw(statement, user, checkUuids, checkUsers, restrictList, excludeList, excludeUserList, actionList, location, radius, null, startTime, endTime, -1, -1, restrictWorld, lookup);
|
||||
}
|
||||
|
||||
if (lookupList == null) {
|
||||
|
|
@ -137,7 +137,7 @@ public class Rollback extends Queue {
|
|||
itemActionList.add(4);
|
||||
}
|
||||
|
||||
itemList = Lookup.performLookupRaw(statement, user, checkUuids, checkUsers, itemRestrictList, itemExcludeList, excludeUserList, itemActionList, location, radius, null, checkTime, -1, -1, restrictWorld, lookup);
|
||||
itemList = Lookup.performLookupRaw(statement, user, checkUuids, checkUsers, itemRestrictList, itemExcludeList, excludeUserList, itemActionList, location, radius, null, startTime, endTime, -1, -1, restrictWorld, lookup);
|
||||
}
|
||||
|
||||
TreeMap<Long, Integer> chunkList = new TreeMap<>();
|
||||
|
|
@ -1255,8 +1255,8 @@ public class Rollback extends Queue {
|
|||
int itemCount = rollbackHashData[0];
|
||||
int blockCount = rollbackHashData[1];
|
||||
int entityCount = rollbackHashData[2];
|
||||
long endTime = System.currentTimeMillis();
|
||||
double totalSeconds = (endTime - startTime) / 1000.0;
|
||||
long timeFinish = System.currentTimeMillis();
|
||||
double totalSeconds = (timeFinish - timeStart) / 1000.0;
|
||||
|
||||
if (user != null) {
|
||||
finishRollbackRestore(user, location, checkUsers, restrictList, excludeList, excludeUserList, actionList, timeString, chunkCount, totalSeconds, itemCount, blockCount, entityCount, rollbackType, radius, verbose, restrictWorld, preview);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue