mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-24 12:16:36 +01:00
Added support for time ranges in the time parameter
This commit is contained in:
parent
a596dd66a9
commit
0bbeee65e8
@ -168,7 +168,6 @@ public class CoreProtectAPI extends Queue {
|
||||
}
|
||||
|
||||
public int APIVersion() {
|
||||
return 8;
|
||||
try {
|
||||
// deny access to BlocksHub to prevent duplicate data from being logged
|
||||
if (!checkedBlocksHub && Bukkit.getPluginManager().getPlugin("BlocksHub") != null) {
|
||||
@ -187,6 +186,7 @@ public class CoreProtectAPI extends Queue {
|
||||
// proceed with returning API version
|
||||
}
|
||||
|
||||
return 8;
|
||||
}
|
||||
|
||||
public List<String[]> blockLookup(Block block, int time) {
|
||||
@ -483,7 +483,8 @@ public class CoreProtectAPI extends Queue {
|
||||
}
|
||||
|
||||
long timestamp = System.currentTimeMillis() / 1000L;
|
||||
long timePeriod = timestamp - time;
|
||||
long startTime = timestamp - time;
|
||||
long endTime = 0;
|
||||
|
||||
if (radius < 1) {
|
||||
radius = -1;
|
||||
@ -525,16 +526,16 @@ public class CoreProtectAPI extends Queue {
|
||||
}
|
||||
|
||||
if (useLimit) {
|
||||
result = Lookup.performPartialLookup(statement, null, uuids, restrictUsers, restrictBlocks, excludeBlocks, excludeUsers, actionList, location, argRadius, null, timePeriod, offset, rowCount, restrictWorld, true);
|
||||
result = Lookup.performPartialLookup(statement, null, uuids, restrictUsers, restrictBlocks, excludeBlocks, excludeUsers, actionList, location, argRadius, null, startTime, endTime, offset, rowCount, restrictWorld, true);
|
||||
}
|
||||
else {
|
||||
result = Lookup.performLookup(statement, null, uuids, restrictUsers, restrictBlocks, excludeBlocks, excludeUsers, actionList, location, argRadius, timePeriod, restrictWorld, true);
|
||||
result = Lookup.performLookup(statement, null, uuids, restrictUsers, restrictBlocks, excludeBlocks, excludeUsers, actionList, location, argRadius, startTime, endTime, restrictWorld, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
boolean verbose = false;
|
||||
result = Rollback.performRollbackRestore(statement, null, uuids, restrictUsers, null, restrictBlocks, excludeBlocks, excludeUsers, actionList, location, argRadius, timePeriod, restrictWorld, false, verbose, action, 0);
|
||||
result = Rollback.performRollbackRestore(statement, null, uuids, restrictUsers, null, restrictBlocks, excludeBlocks, excludeUsers, actionList, location, argRadius, startTime, endTime, restrictWorld, false, verbose, action, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,10 @@ public class ApplyCommand {
|
||||
try {
|
||||
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
||||
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
||||
long time = (Long) list.get(0);
|
||||
args = (String[]) list.get(1);
|
||||
Location location = (Location) list.get(2);
|
||||
long startTime = (Long) list.get(0);
|
||||
long endTime = (Long) list.get(1);
|
||||
args = (String[]) list.get(2);
|
||||
Location location = (Location) list.get(3);
|
||||
boolean valid = false;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].equals("#preview")) {
|
||||
@ -32,7 +33,7 @@ public class ApplyCommand {
|
||||
}
|
||||
else {
|
||||
ConfigHandler.lastRollback.remove(user.getName());
|
||||
RollbackRestoreCommand.runCommand(user, command, permission, args, location, time);
|
||||
RollbackRestoreCommand.runCommand(user, command, permission, args, location, startTime, endTime);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -17,9 +17,10 @@ public class CancelCommand {
|
||||
try {
|
||||
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
||||
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
||||
long time = (Long) list.get(0);
|
||||
args = (String[]) list.get(1);
|
||||
Location location = (Location) list.get(2);
|
||||
long startTime = (Long) list.get(0);
|
||||
long endTime = (Long) list.get(1);
|
||||
args = (String[]) list.get(2);
|
||||
Location location = (Location) list.get(3);
|
||||
boolean valid = false;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].equals("#preview")) {
|
||||
@ -32,7 +33,7 @@ public class CancelCommand {
|
||||
}
|
||||
else {
|
||||
ConfigHandler.lastRollback.remove(user.getName());
|
||||
RollbackRestoreCommand.runCommand(user, command, permission, args, location, time);
|
||||
RollbackRestoreCommand.runCommand(user, command, permission, args, location, startTime, endTime);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -691,11 +691,13 @@ public class CommandHandler implements CommandExecutor {
|
||||
return restricted;
|
||||
}
|
||||
|
||||
protected static long parseTime(String[] inputArguments) {
|
||||
protected static long[] parseTime(String[] inputArguments) {
|
||||
String[] argumentArray = inputArguments.clone();
|
||||
long time = 0;
|
||||
long timeStart = 0;
|
||||
long timeEnd = 0;
|
||||
int count = 0;
|
||||
int next = 0;
|
||||
boolean range = false;
|
||||
double w = 0;
|
||||
double d = 0;
|
||||
double h = 0;
|
||||
@ -720,41 +722,59 @@ public class CommandHandler implements CommandExecutor {
|
||||
argument = argument.replaceAll("d", "d:");
|
||||
argument = argument.replaceAll("h", "h:");
|
||||
argument = argument.replaceAll("s", "s:");
|
||||
range = argument.contains("-");
|
||||
|
||||
int argCount = 0;
|
||||
String[] i2 = argument.split(":");
|
||||
for (String i3 : i2) {
|
||||
if (i3.endsWith("w")) {
|
||||
if (range && argCount > 0 && timeStart == 0 && i3.startsWith("-")) {
|
||||
timeStart = (long) (((w * 7 * 24 * 60 * 60) + (d * 24 * 60 * 60) + (h * 60 * 60) + (m * 60) + s));
|
||||
w = 0;
|
||||
d = 0;
|
||||
h = 0;
|
||||
m = 0;
|
||||
s = 0;
|
||||
}
|
||||
|
||||
if (i3.endsWith("w") && w == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
w = Double.parseDouble(i4);
|
||||
}
|
||||
}
|
||||
else if (i3.endsWith("d")) {
|
||||
else if (i3.endsWith("d") && d == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
d = Double.parseDouble(i4);
|
||||
}
|
||||
}
|
||||
else if (i3.endsWith("h")) {
|
||||
else if (i3.endsWith("h") && h == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
h = Double.parseDouble(i4);
|
||||
}
|
||||
}
|
||||
else if (i3.endsWith("m")) {
|
||||
else if (i3.endsWith("m") && m == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
m = Double.parseDouble(i4);
|
||||
}
|
||||
}
|
||||
else if (i3.endsWith("s")) {
|
||||
else if (i3.endsWith("s") && s == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
s = Double.parseDouble(i4);
|
||||
}
|
||||
}
|
||||
|
||||
argCount++;
|
||||
}
|
||||
if (timeStart > 0) {
|
||||
timeEnd = (long) (((w * 7 * 24 * 60 * 60) + (d * 24 * 60 * 60) + (h * 60 * 60) + (m * 60) + s));
|
||||
}
|
||||
else {
|
||||
timeStart = (long) (((w * 7 * 24 * 60 * 60) + (d * 24 * 60 * 60) + (h * 60 * 60) + (m * 60) + s));
|
||||
}
|
||||
double rs = ((w * 7 * 24 * 60 * 60) + (d * 24 * 60 * 60) + (h * 60 * 60) + (m * 60) + s);
|
||||
time = (long) rs;
|
||||
next = 0;
|
||||
}
|
||||
else {
|
||||
@ -764,7 +784,12 @@ public class CommandHandler implements CommandExecutor {
|
||||
count++;
|
||||
}
|
||||
|
||||
return time;
|
||||
if (timeEnd >= timeStart) {
|
||||
return new long[] { timeEnd, timeStart };
|
||||
}
|
||||
else {
|
||||
return new long[] { timeStart, timeEnd };
|
||||
}
|
||||
}
|
||||
|
||||
private static String timeString(BigDecimal input) {
|
||||
@ -776,6 +801,7 @@ public class CommandHandler implements CommandExecutor {
|
||||
String time = "";
|
||||
int count = 0;
|
||||
int next = 0;
|
||||
boolean range = false;
|
||||
BigDecimal w = new BigDecimal(0);
|
||||
BigDecimal d = new BigDecimal(0);
|
||||
BigDecimal h = new BigDecimal(0);
|
||||
@ -800,43 +826,82 @@ public class CommandHandler implements CommandExecutor {
|
||||
argument = argument.replaceAll("d", "d:");
|
||||
argument = argument.replaceAll("h", "h:");
|
||||
argument = argument.replaceAll("s", "s:");
|
||||
range = argument.contains("-");
|
||||
|
||||
int argCount = 0;
|
||||
String[] i2 = argument.split(":");
|
||||
for (String i3 : i2) {
|
||||
if (i3.endsWith("w")) {
|
||||
if (range && argCount > 0 && !time.contains("-") && i3.startsWith("-")) {
|
||||
w = new BigDecimal(0);
|
||||
d = new BigDecimal(0);
|
||||
h = new BigDecimal(0);
|
||||
m = new BigDecimal(0);
|
||||
s = new BigDecimal(0);
|
||||
time = time + " -";
|
||||
}
|
||||
|
||||
if (i3.endsWith("w") && w.intValue() == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
w = new BigDecimal(i4);
|
||||
time = time + " " + Phrase.build(Phrase.TIME_WEEKS, timeString(w), (w.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
if (range) {
|
||||
time = time + " " + timeString(w) + "w";
|
||||
}
|
||||
else {
|
||||
time = time + " " + Phrase.build(Phrase.TIME_WEEKS, timeString(w), (w.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i3.endsWith("d")) {
|
||||
else if (i3.endsWith("d") && d.intValue() == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
d = new BigDecimal(i4);
|
||||
time = time + " " + Phrase.build(Phrase.TIME_DAYS, timeString(d), (d.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
if (range) {
|
||||
time = time + " " + timeString(d) + "d";
|
||||
}
|
||||
else {
|
||||
time = time + " " + Phrase.build(Phrase.TIME_DAYS, timeString(d), (d.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i3.endsWith("h")) {
|
||||
else if (i3.endsWith("h") && h.intValue() == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
h = new BigDecimal(i4);
|
||||
time = time + " " + Phrase.build(Phrase.TIME_HOURS, timeString(h), (h.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
if (range) {
|
||||
time = time + " " + timeString(h) + "h";
|
||||
}
|
||||
else {
|
||||
time = time + " " + Phrase.build(Phrase.TIME_HOURS, timeString(h), (h.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i3.endsWith("m")) {
|
||||
else if (i3.endsWith("m") && m.intValue() == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
m = new BigDecimal(i4);
|
||||
time = time + " " + Phrase.build(Phrase.TIME_MINUTES, timeString(m), (m.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
if (range) {
|
||||
time = time + " " + timeString(m) + "m";
|
||||
}
|
||||
else {
|
||||
time = time + " " + Phrase.build(Phrase.TIME_MINUTES, timeString(m), (m.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i3.endsWith("s")) {
|
||||
else if (i3.endsWith("s") && s.intValue() == 0) {
|
||||
String i4 = i3.replaceAll("[^0-9.]", "");
|
||||
if (i4.length() > 0 && i4.replaceAll("[^0-9]", "").length() > 0 && i4.indexOf('.') == i4.lastIndexOf('.')) {
|
||||
s = new BigDecimal(i4);
|
||||
time = time + " " + Phrase.build(Phrase.TIME_SECONDS, timeString(s), (s.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
if (range) {
|
||||
time = time + " " + timeString(s) + "s";
|
||||
}
|
||||
else {
|
||||
time = time + " " + Phrase.build(Phrase.TIME_SECONDS, timeString(s), (s.doubleValue() == 1 ? Selector.FIRST : Selector.SECOND));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
argCount++;
|
||||
}
|
||||
next = 0;
|
||||
}
|
||||
@ -1128,7 +1193,7 @@ public class CommandHandler implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (corecommand.equals("rollback") || corecommand.equals("restore") || corecommand.equals("rb") || corecommand.equals("rs") || corecommand.equals("ro") || corecommand.equals("re")) {
|
||||
RollbackRestoreCommand.runCommand(user, command, permission, argumentArray, null, 0);
|
||||
RollbackRestoreCommand.runCommand(user, command, permission, argumentArray, null, 0, 0);
|
||||
}
|
||||
else if (corecommand.equals("apply")) {
|
||||
ApplyCommand.runCommand(user, command, permission, argumentArray);
|
||||
|
@ -52,7 +52,9 @@ public class LookupCommand {
|
||||
List<Object> argExclude = CommandHandler.parseExcluded(player, args, argAction);
|
||||
List<String> argExcludeUsers = CommandHandler.parseExcludedUsers(player, args);
|
||||
String ts = CommandHandler.parseTimeString(args);
|
||||
long rbseconds = CommandHandler.parseTime(args);
|
||||
long[] argTime = CommandHandler.parseTime(args);
|
||||
long startTime = argTime[0];
|
||||
long endTime = argTime[1];
|
||||
int argWid = CommandHandler.parseWorld(args, true, true);
|
||||
int parseRows = CommandHandler.parseRows(args);
|
||||
boolean count = CommandHandler.parseCount(args);
|
||||
@ -258,7 +260,7 @@ public class LookupCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (rbseconds <= 0 && !pageLookup && type == 4 && (argBlocks.size() > 0 || argUsers.size() > 0)) {
|
||||
if (startTime <= 0 && !pageLookup && type == 4 && (argBlocks.size() > 0 || argUsers.size() > 0)) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.MISSING_LOOKUP_TIME, Selector.FIRST));
|
||||
return;
|
||||
}
|
||||
@ -571,7 +573,8 @@ public class LookupCommand {
|
||||
c++;
|
||||
}
|
||||
|
||||
long cs = -1;
|
||||
long timeStart = -1;
|
||||
long timeEnd = 0;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
@ -584,14 +587,14 @@ public class LookupCommand {
|
||||
y = Integer.parseInt(data[1]);
|
||||
z = Integer.parseInt(data[2]);
|
||||
wid = Integer.parseInt(data[3]);
|
||||
cs = Long.parseLong(data[4]);
|
||||
// arg_radius = Integer.parseInt(data[5]);
|
||||
argNoisy = Integer.parseInt(data[5]);
|
||||
argExcluded = Integer.parseInt(data[6]);
|
||||
argRestricted = Integer.parseInt(data[7]);
|
||||
argWid = Integer.parseInt(data[8]);
|
||||
timeStart = Long.parseLong(data[4]);
|
||||
timeEnd = Long.parseLong(data[5]);
|
||||
argNoisy = Integer.parseInt(data[6]);
|
||||
argExcluded = Integer.parseInt(data[7]);
|
||||
argRestricted = Integer.parseInt(data[8]);
|
||||
argWid = Integer.parseInt(data[9]);
|
||||
if (defaultRe) {
|
||||
re = Integer.parseInt(data[9]);
|
||||
re = Integer.parseInt(data[10]);
|
||||
}
|
||||
|
||||
rollbackusers = ConfigHandler.lookupUlist.get(player.getName());
|
||||
@ -601,7 +604,8 @@ public class LookupCommand {
|
||||
argAction = ConfigHandler.lookupAlist.get(player.getName());
|
||||
argRadius = ConfigHandler.lookupRadius.get(player.getName());
|
||||
ts = ConfigHandler.lookupTime.get(player.getName());
|
||||
rbseconds = 1;
|
||||
startTime = 1;
|
||||
endTime = 0;
|
||||
}
|
||||
else {
|
||||
if (lo != null) {
|
||||
@ -658,15 +662,23 @@ public class LookupCommand {
|
||||
|
||||
final List<String> rollbackusers2 = rollbackusers;
|
||||
long unixtimestamp = (System.currentTimeMillis() / 1000L);
|
||||
if (cs == -1) {
|
||||
if (rbseconds <= 0) {
|
||||
cs = 0;
|
||||
if (timeStart == -1) {
|
||||
if (startTime <= 0) {
|
||||
timeStart = 0;
|
||||
}
|
||||
else {
|
||||
cs = unixtimestamp - rbseconds;
|
||||
timeStart = unixtimestamp - startTime;
|
||||
}
|
||||
if (endTime <= 0) {
|
||||
timeEnd = 0;
|
||||
}
|
||||
else {
|
||||
timeEnd = unixtimestamp - endTime;
|
||||
}
|
||||
}
|
||||
final long stime = cs;
|
||||
|
||||
final long finalTimeStart = timeStart;
|
||||
final long finalTimeEnd = timeEnd;
|
||||
final Integer[] radius = argRadius;
|
||||
|
||||
try {
|
||||
@ -701,7 +713,7 @@ public class LookupCommand {
|
||||
List<String> uuidList = new ArrayList<>();
|
||||
Location location = finalLocation;
|
||||
boolean exists = false;
|
||||
String bc = finalX + "." + finalY + "." + finalZ + "." + finalWid + "." + stime + "." + noisy + "." + excluded + "." + restricted + "." + finalArgWid + "." + displayResults;
|
||||
String bc = finalX + "." + finalY + "." + finalZ + "." + finalWid + "." + finalTimeStart + "." + finalTimeEnd + "." + noisy + "." + excluded + "." + restricted + "." + finalArgWid + "." + displayResults;
|
||||
ConfigHandler.lookupCommand.put(player2.getName(), bc);
|
||||
ConfigHandler.lookupPage.put(player2.getName(), page);
|
||||
ConfigHandler.lookupTime.put(player2.getName(), rtime);
|
||||
@ -788,7 +800,7 @@ public class LookupCommand {
|
||||
}
|
||||
|
||||
if (checkRows) {
|
||||
rows = Lookup.countLookupRows(statement, player2, uuidList, userList, blist, elist, euserlist, finalArgAction, location, radius, rowData, stime, restrict_world, true);
|
||||
rows = Lookup.countLookupRows(statement, player2, uuidList, userList, blist, elist, euserlist, finalArgAction, location, radius, rowData, finalTimeStart, finalTimeEnd, restrict_world, true);
|
||||
rowData[3] = rows;
|
||||
ConfigHandler.lookupRows.put(player2.getName(), rowData);
|
||||
}
|
||||
@ -797,7 +809,7 @@ public class LookupCommand {
|
||||
Chat.sendMessage(player2, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.LOOKUP_ROWS_FOUND, row_format, (rows == 1 ? Selector.FIRST : Selector.SECOND)));
|
||||
}
|
||||
else if (pageStart < rows) {
|
||||
List<String[]> lookupList = Lookup.performPartialLookup(statement, player2, uuidList, userList, blist, elist, euserlist, finalArgAction, location, radius, rowData, stime, (int) pageStart, displayResults, restrict_world, true);
|
||||
List<String[]> lookupList = Lookup.performPartialLookup(statement, player2, uuidList, userList, blist, elist, euserlist, finalArgAction, location, radius, rowData, finalTimeStart, finalTimeEnd, (int) pageStart, displayResults, restrict_world, true);
|
||||
|
||||
Chat.sendMessage(player2, Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.LOOKUP_HEADER, "CoreProtect" + Color.WHITE + " | " + Color.DARK_AQUA) + Color.WHITE + " -----");
|
||||
if (finalArgAction.contains(6) || finalArgAction.contains(7)) { // Chat/command
|
||||
|
@ -31,10 +31,12 @@ public class PurgeCommand extends Consumer {
|
||||
int resultc = args.length;
|
||||
Location location = CommandHandler.parseLocation(player, args);
|
||||
final Integer[] argRadius = CommandHandler.parseRadius(args, player, location);
|
||||
final long seconds = CommandHandler.parseTime(args);
|
||||
final long[] argTime = CommandHandler.parseTime(args);
|
||||
final int argWid = CommandHandler.parseWorld(args, false, false);
|
||||
final List<Integer> argAction = CommandHandler.parseAction(args);
|
||||
final List<Integer> supportedActions = Arrays.asList();
|
||||
long startTime = argTime[1] > 0 ? argTime[0] : 0;
|
||||
long endTime = argTime[1] > 0 ? argTime[1] : argTime[0];
|
||||
|
||||
if (ConfigHandler.converterRunning) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||
@ -52,7 +54,7 @@ public class PurgeCommand extends Consumer {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.MISSING_PARAMETERS, "/co purge t:<time>"));
|
||||
return;
|
||||
}
|
||||
if (seconds <= 0) {
|
||||
if (endTime <= 0) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.MISSING_PARAMETERS, "/co purge t:<time>"));
|
||||
return;
|
||||
}
|
||||
@ -72,11 +74,11 @@ public class PurgeCommand extends Consumer {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (player instanceof Player && seconds < 2592000) {
|
||||
if (player instanceof Player && endTime < 2592000) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_MINIMUM_TIME, "30", Selector.FIRST)); // 30 days
|
||||
return;
|
||||
}
|
||||
else if (seconds < 86400) {
|
||||
else if (endTime < 86400) {
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.PURGE_MINIMUM_TIME, "24", Selector.SECOND)); // 24 hours
|
||||
return;
|
||||
}
|
||||
@ -96,7 +98,8 @@ public class PurgeCommand extends Consumer {
|
||||
public void run() {
|
||||
try {
|
||||
long timestamp = (System.currentTimeMillis() / 1000L);
|
||||
long ptime = timestamp - seconds;
|
||||
long timeStart = startTime > 0 ? (timestamp - startTime) : 0;
|
||||
long timeEnd = timestamp - endTime;
|
||||
long removed = 0;
|
||||
|
||||
Connection connection = null;
|
||||
@ -196,10 +199,10 @@ public class PurgeCommand extends Consumer {
|
||||
String timeLimit = "";
|
||||
if (purgeTables.contains(table)) {
|
||||
if (argWid > 0 && worldTables.contains(table)) {
|
||||
timeLimit = " WHERE (wid = '" + argWid + "' AND time >= '" + ptime + "') OR wid != '" + argWid + "'";
|
||||
timeLimit = " WHERE (wid = '" + argWid + "' AND (time >= '" + timeEnd + "' OR time < '" + timeStart + "')) OR wid != '" + argWid + "'";
|
||||
}
|
||||
else if (argWid == 0) {
|
||||
timeLimit = " WHERE time >= '" + ptime + "'";
|
||||
timeLimit = " WHERE (time >= '" + timeEnd + "' OR time < '" + timeStart + "')";
|
||||
}
|
||||
}
|
||||
query = "INSERT INTO " + purgePrefix + table + " SELECT " + columns + " FROM " + ConfigHandler.prefix + table + timeLimit;
|
||||
@ -262,7 +265,7 @@ public class PurgeCommand extends Consumer {
|
||||
}
|
||||
|
||||
if (purge) {
|
||||
query = "DELETE FROM " + purgePrefix + table + " WHERE time < '" + ptime + "'" + worldRestriction;
|
||||
query = "DELETE FROM " + purgePrefix + table + " WHERE time < '" + timeEnd + "' AND time >= '" + timeStart + "'" + worldRestriction;
|
||||
preparedStmt = connection.prepareStatement(query);
|
||||
preparedStmt.execute();
|
||||
preparedStmt.close();
|
||||
@ -321,7 +324,7 @@ public class PurgeCommand extends Consumer {
|
||||
}
|
||||
|
||||
if (purge) {
|
||||
query = "DELETE FROM " + ConfigHandler.prefix + table + " WHERE time < '" + ptime + "'" + worldRestriction;
|
||||
query = "DELETE FROM " + ConfigHandler.prefix + table + " WHERE time < '" + timeEnd + "' AND time >= '" + timeStart + "'" + worldRestriction;
|
||||
preparedStmt = connection.prepareStatement(query);
|
||||
preparedStmt.execute();
|
||||
removed = removed + preparedStmt.getUpdateCount();
|
||||
|
@ -31,7 +31,7 @@ import net.coreprotect.utility.Color;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class RollbackRestoreCommand {
|
||||
protected static void runCommand(CommandSender player, Command command, boolean permission, String[] args, Location argLocation, long forceSeconds) {
|
||||
protected static void runCommand(CommandSender player, Command command, boolean permission, String[] args, Location argLocation, long forceStart, long forceEnd) {
|
||||
Location lo = (argLocation != null ? argLocation : CommandHandler.parseLocation(player, args));
|
||||
List<String> argUuids = new ArrayList<>();
|
||||
List<String> argUsers = CommandHandler.parseUsers(args);
|
||||
@ -42,7 +42,9 @@ public class RollbackRestoreCommand {
|
||||
List<Object> argExclude = CommandHandler.parseExcluded(player, args, argAction);
|
||||
List<String> argExcludeUsers = CommandHandler.parseExcludedUsers(player, args);
|
||||
String ts = CommandHandler.parseTimeString(args);
|
||||
long rbSeconds = CommandHandler.parseTime(args);
|
||||
long[] argTime = CommandHandler.parseTime(args);
|
||||
long startTime = argTime[0];
|
||||
long endTime = argTime[1];
|
||||
int argWid = CommandHandler.parseWorld(args, true, true);
|
||||
boolean count = CommandHandler.parseCount(args);
|
||||
boolean worldedit = CommandHandler.parseWorldEdit(args);
|
||||
@ -139,7 +141,7 @@ public class RollbackRestoreCommand {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (preview > 1 && forceSeconds <= 0) {
|
||||
if (preview > 1 && forceStart <= 0) {
|
||||
preview = 1;
|
||||
}
|
||||
|
||||
@ -310,13 +312,16 @@ public class RollbackRestoreCommand {
|
||||
}
|
||||
|
||||
final List<String> rollbackusers2 = rollbackusers;
|
||||
if (rbSeconds > 0) {
|
||||
if (startTime > 0) {
|
||||
long unixtimestamp = (System.currentTimeMillis() / 1000L);
|
||||
long seconds = unixtimestamp - rbSeconds;
|
||||
if (forceSeconds > 0) {
|
||||
seconds = forceSeconds;
|
||||
long timeStart = unixtimestamp - startTime;
|
||||
long timeEnd = endTime > 0 ? (unixtimestamp - endTime) : 0;
|
||||
if (forceStart > 0) {
|
||||
timeStart = forceStart;
|
||||
timeEnd = forceEnd;
|
||||
}
|
||||
final long stime = seconds;
|
||||
final long finalTimeStart = timeStart;
|
||||
final long finalTimeEnd = timeEnd;
|
||||
final Integer[] radius = argRadius;
|
||||
try {
|
||||
final CommandSender player2 = player;
|
||||
@ -416,14 +421,15 @@ public class RollbackRestoreCommand {
|
||||
}
|
||||
|
||||
if (finalArgAction.contains(5)) {
|
||||
ContainerRollback.performContainerRollbackRestore(statement, player2, uuidList, rollbackusers2, rtime, blist, elist, euserlist, finalArgAction, location, radius, stime, restrictWorld, false, verbose, action);
|
||||
ContainerRollback.performContainerRollbackRestore(statement, player2, uuidList, rollbackusers2, rtime, blist, elist, euserlist, finalArgAction, location, radius, finalTimeStart, finalTimeEnd, restrictWorld, false, verbose, action);
|
||||
}
|
||||
else {
|
||||
Rollback.performRollbackRestore(statement, player2, uuidList, rollbackusers2, rtime, blist, elist, euserlist, finalArgAction, location, radius, stime, restrictWorld, false, verbose, action, finalPreview);
|
||||
Rollback.performRollbackRestore(statement, player2, uuidList, rollbackusers2, rtime, blist, elist, euserlist, finalArgAction, location, radius, finalTimeStart, finalTimeEnd, restrictWorld, false, verbose, action, finalPreview);
|
||||
}
|
||||
if (finalPreview < 2) {
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(stime);
|
||||
list.add(finalTimeStart);
|
||||
list.add(finalTimeEnd);
|
||||
list.add(finalArgs);
|
||||
list.add(locationFinal);
|
||||
ConfigHandler.lastRollback.put(player2.getName(), list);
|
||||
|
@ -17,9 +17,10 @@ public class UndoCommand {
|
||||
try {
|
||||
if (ConfigHandler.lastRollback.get(user.getName()) != null) {
|
||||
List<Object> list = ConfigHandler.lastRollback.get(user.getName());
|
||||
long time = (Long) list.get(0);
|
||||
args = (String[]) list.get(1);
|
||||
Location location = (Location) list.get(2);
|
||||
long startTime = (Long) list.get(0);
|
||||
long endTime = (Long) list.get(1);
|
||||
args = (String[]) list.get(2);
|
||||
Location location = (Location) list.get(3);
|
||||
for (String arg : args) {
|
||||
if (arg.equals("#preview")) {
|
||||
CancelCommand.runCommand(user, command, permission, args);
|
||||
@ -38,7 +39,7 @@ public class UndoCommand {
|
||||
}
|
||||
if (valid) {
|
||||
ConfigHandler.lastRollback.remove(user.getName());
|
||||
RollbackRestoreCommand.runCommand(user, command, permission, args, location, time);
|
||||
RollbackRestoreCommand.runCommand(user, command, permission, args, location, startTime, endTime);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -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…
Reference in New Issue
Block a user