forked from LogBlock/LogBlock
Made since and before working at the same time
This commit is contained in:
@@ -215,7 +215,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
} else if (command.equals("rollback") || command.equals("undo") || command.equals("rb")) {
|
} else if (command.equals("rollback") || command.equals("undo") || command.equals("rb")) {
|
||||||
if (logblock.hasPermission(sender, "logblock.rollback")) {
|
if (logblock.hasPermission(sender, "logblock.rollback")) {
|
||||||
final QueryParams params = new QueryParams(logblock);
|
final QueryParams params = new QueryParams(logblock);
|
||||||
params.minutes = logblock.getConfig().defaultTime;
|
params.since = logblock.getConfig().defaultTime;
|
||||||
params.bct = BlockChangeType.ALL;
|
params.bct = BlockChangeType.ALL;
|
||||||
params.parseArgs(sender, argsToList(args, 1));
|
params.parseArgs(sender, argsToList(args, 1));
|
||||||
new CommandRollback(sender, params, true);
|
new CommandRollback(sender, params, true);
|
||||||
@@ -224,7 +224,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
} else if (command.equals("redo")) {
|
} else if (command.equals("redo")) {
|
||||||
if (logblock.hasPermission(sender, "logblock.rollback")) {
|
if (logblock.hasPermission(sender, "logblock.rollback")) {
|
||||||
final QueryParams params = new QueryParams(logblock);
|
final QueryParams params = new QueryParams(logblock);
|
||||||
params.minutes = logblock.getConfig().defaultTime;
|
params.since = logblock.getConfig().defaultTime;
|
||||||
params.bct = BlockChangeType.ALL;
|
params.bct = BlockChangeType.ALL;
|
||||||
params.parseArgs(sender, argsToList(args, 1));
|
params.parseArgs(sender, argsToList(args, 1));
|
||||||
new CommandRedo(sender, params, true);
|
new CommandRedo(sender, params, true);
|
||||||
@@ -326,7 +326,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
private boolean checkRestrictions(CommandSender sender, QueryParams params) {
|
private boolean checkRestrictions(CommandSender sender, QueryParams params) {
|
||||||
if (logblock.hasPermission(sender, "logblock.ignoreRestrictions"))
|
if (logblock.hasPermission(sender, "logblock.ignoreRestrictions"))
|
||||||
return true;
|
return true;
|
||||||
if (config.rollbackMaxTime > 0 && (params.minutes <= 0 || params.minutes > config.rollbackMaxTime)) {
|
if (config.rollbackMaxTime > 0 && (params.before <= 0 || params.since > config.rollbackMaxTime)) {
|
||||||
sender.sendMessage(ChatColor.RED + "You are not allowed to rollback more than " + config.rollbackMaxTime + " minutes");
|
sender.sendMessage(ChatColor.RED + "You are not allowed to rollback more than " + config.rollbackMaxTime + " minutes");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -78,7 +78,7 @@ class LBToolListener extends PlayerListener
|
|||||||
if (split.length > 1 && split[0].equalsIgnoreCase("/ban") && logblock.hasPermission(event.getPlayer(), logblock.getConfig().banPermission)) {
|
if (split.length > 1 && split[0].equalsIgnoreCase("/ban") && logblock.hasPermission(event.getPlayer(), logblock.getConfig().banPermission)) {
|
||||||
final QueryParams p = new QueryParams(logblock);
|
final QueryParams p = new QueryParams(logblock);
|
||||||
p.setPlayer(split[1].equalsIgnoreCase("g") ? split[2] : split[1]);
|
p.setPlayer(split[1].equalsIgnoreCase("g") ? split[2] : split[1]);
|
||||||
p.minutes = 0;
|
p.since = 0;
|
||||||
p.silent = false;
|
p.silent = false;
|
||||||
logblock.getServer().getScheduler().scheduleAsyncDelayedTask(logblock, new Runnable() {
|
logblock.getServer().getScheduler().scheduleAsyncDelayedTask(logblock, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@@ -157,7 +157,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
log.info("[LogBlock] Permissions plugin not found. Using Bukkit Permissions.");
|
log.info("[LogBlock] Permissions plugin not found. Using Bukkit Permissions.");
|
||||||
if (config.keepLogDays >= 0) {
|
if (config.keepLogDays >= 0) {
|
||||||
final QueryParams params = new QueryParams(this);
|
final QueryParams params = new QueryParams(this);
|
||||||
params.minutes = config.keepLogDays * -1440;
|
params.before = config.keepLogDays * 1440;
|
||||||
params.bct = BlockChangeType.ALL;
|
params.bct = BlockChangeType.ALL;
|
||||||
for (final World world : getServer().getWorlds())
|
for (final World world : getServer().getWorlds())
|
||||||
if (config.worlds.containsKey(world.getName().hashCode())) {
|
if (config.worlds.containsKey(world.getName().hashCode())) {
|
||||||
|
@@ -27,7 +27,7 @@ public class QueryParams implements Cloneable
|
|||||||
{
|
{
|
||||||
private static final Set<Integer> keywords = new HashSet<Integer>(Arrays.asList("player".hashCode(), "area".hashCode(), "selection".hashCode(), "sel".hashCode(), "block".hashCode(), "type".hashCode(), "sum".hashCode(), "destroyed".hashCode(), "created".hashCode(), "chestaccess".hashCode(), "all".hashCode(), "time".hashCode(), "since".hashCode(), "before".hashCode(), "limit".hashCode(), "world".hashCode(), "asc".hashCode(), "desc".hashCode(), "last".hashCode(), "coords".hashCode(), "silent".hashCode(), "chat".hashCode(), "search".hashCode(), "match".hashCode()));
|
private static final Set<Integer> keywords = new HashSet<Integer>(Arrays.asList("player".hashCode(), "area".hashCode(), "selection".hashCode(), "sel".hashCode(), "block".hashCode(), "type".hashCode(), "sum".hashCode(), "destroyed".hashCode(), "created".hashCode(), "chestaccess".hashCode(), "all".hashCode(), "time".hashCode(), "since".hashCode(), "before".hashCode(), "limit".hashCode(), "world".hashCode(), "asc".hashCode(), "desc".hashCode(), "last".hashCode(), "coords".hashCode(), "silent".hashCode(), "chat".hashCode(), "search".hashCode(), "match".hashCode()));
|
||||||
public BlockChangeType bct = BlockChangeType.BOTH;
|
public BlockChangeType bct = BlockChangeType.BOTH;
|
||||||
public int limit = -1, minutes = 0, radius = -1;
|
public int limit = -1, before = 0, since = 0, radius = -1;
|
||||||
public Location loc = null;
|
public Location loc = null;
|
||||||
public Order order = Order.DESC;
|
public Order order = Order.DESC;
|
||||||
public List<String> players = new ArrayList<String>();
|
public List<String> players = new ArrayList<String>();
|
||||||
@@ -136,10 +136,12 @@ public class QueryParams implements Cloneable
|
|||||||
title.append((excludePlayersMode ? "without" : "from") + " player" + (players.size() != 1 ? "s" : "") + " " + listing(players.toArray(new String[players.size()]), ", ", " and ") + " ");
|
title.append((excludePlayersMode ? "without" : "from") + " player" + (players.size() != 1 ? "s" : "") + " " + listing(players.toArray(new String[players.size()]), ", ", " and ") + " ");
|
||||||
if (match != null && match.length() > 0)
|
if (match != null && match.length() > 0)
|
||||||
title.append("matching '" + match + "' ");
|
title.append("matching '" + match + "' ");
|
||||||
if (minutes > 0)
|
if (before > 0 && since > 0)
|
||||||
title.append("in the last " + minutes + " minutes ");
|
title.append("between " + since + " and " + before + " minutes ago ");
|
||||||
if (minutes < 0)
|
else if (since > 0)
|
||||||
title.append("more than " + minutes * -1 + " minutes ago ");
|
title.append("in the last " + since + " minutes ");
|
||||||
|
else if (before > 0)
|
||||||
|
title.append("more than " + before * -1 + " minutes ago ");
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
if (radius > 0)
|
if (radius > 0)
|
||||||
title.append("within " + radius + " blocks of " + (prepareToolQuery ? "clicked block" : "you") + " ");
|
title.append("within " + radius + " blocks of " + (prepareToolQuery ? "clicked block" : "you") + " ");
|
||||||
@@ -247,10 +249,10 @@ public class QueryParams implements Cloneable
|
|||||||
} else
|
} else
|
||||||
for (final String playerName : players)
|
for (final String playerName : players)
|
||||||
where.append("playername != '" + playerName + "' AND ");
|
where.append("playername != '" + playerName + "' AND ");
|
||||||
if (minutes > 0)
|
if (since > 0)
|
||||||
where.append("date > date_sub(now(), INTERVAL " + minutes + " MINUTE) AND ");
|
where.append("date > date_sub(now(), INTERVAL " + since + " MINUTE) AND ");
|
||||||
if (minutes < 0)
|
if (before > 0)
|
||||||
where.append("date < date_sub(now(), INTERVAL " + minutes * -1 + " MINUTE) AND ");
|
where.append("date < date_sub(now(), INTERVAL " + before + " MINUTE) AND ");
|
||||||
if (where.length() > 6)
|
if (where.length() > 6)
|
||||||
where.delete(where.length() - 4, where.length());
|
where.delete(where.length() - 4, where.length());
|
||||||
else
|
else
|
||||||
@@ -324,18 +326,18 @@ public class QueryParams implements Cloneable
|
|||||||
throw new IllegalArgumentException("You have to define a cuboid selection");
|
throw new IllegalArgumentException("You have to define a cuboid selection");
|
||||||
setSelection(selection);
|
setSelection(selection);
|
||||||
} else if (param.equals("time") || param.equals("since")) {
|
} else if (param.equals("time") || param.equals("since")) {
|
||||||
if (values == null)
|
if (values.length == 0)
|
||||||
minutes = logblock.getConfig().defaultTime;
|
since = logblock.getConfig().defaultTime;
|
||||||
else
|
else
|
||||||
minutes = parseTimeSpec(values);
|
since = parseTimeSpec(values);
|
||||||
if (minutes == -1)
|
if (since == -1)
|
||||||
throw new IllegalArgumentException("Failed to parse time spec for '" + param + "'");
|
throw new IllegalArgumentException("Failed to parse time spec for '" + param + "'");
|
||||||
} else if (param.equals("before")) {
|
} else if (param.equals("before")) {
|
||||||
if (values == null)
|
if (values.length == 0)
|
||||||
minutes = -logblock.getConfig().defaultTime;
|
before = logblock.getConfig().defaultTime;
|
||||||
else
|
else
|
||||||
minutes = -parseTimeSpec(values);
|
before = parseTimeSpec(values);
|
||||||
if (minutes == 1)
|
if (before == -1)
|
||||||
throw new IllegalArgumentException("Faile to parse time spec for '" + param + "'");
|
throw new IllegalArgumentException("Faile to parse time spec for '" + param + "'");
|
||||||
} else if (param.equals("sum")) {
|
} else if (param.equals("sum")) {
|
||||||
if (values == null || values.length != 1)
|
if (values == null || values.length != 1)
|
||||||
@@ -457,8 +459,9 @@ public class QueryParams implements Cloneable
|
|||||||
loc = p.loc;
|
loc = p.loc;
|
||||||
radius = p.radius;
|
radius = p.radius;
|
||||||
sel = p.sel;
|
sel = p.sel;
|
||||||
if (p.minutes != 0 || minutes != logblock.getConfig().defaultTime)
|
if (p.since != 0 || since != logblock.getConfig().defaultTime)
|
||||||
minutes = p.minutes;
|
since = p.since;
|
||||||
|
before = p.before;
|
||||||
sum = p.sum;
|
sum = p.sum;
|
||||||
bct = p.bct;
|
bct = p.bct;
|
||||||
limit = p.limit;
|
limit = p.limit;
|
||||||
|
Reference in New Issue
Block a user