diff --git a/src/de/diddiz/LogBlock/CommandsHandler.java b/src/de/diddiz/LogBlock/CommandsHandler.java index b30a303..cd4e57e 100644 --- a/src/de/diddiz/LogBlock/CommandsHandler.java +++ b/src/de/diddiz/LogBlock/CommandsHandler.java @@ -462,25 +462,27 @@ public class CommandsHandler implements CommandExecutor @Override public void run() { try { - final int queue = logblock.getConsumer().getQueueSize(); - if (queue > 50 && (!config.askSavequeueBeforeRollback || questioner != null && sender instanceof Player && questioner.ask((Player)sender, "There are " + queue + " block in queue. Do yu want to process the queue before rollback?", "yes", "no").equals("yes"))) + if (logblock.getConsumer().getQueueSize() > 50) try { new CommandSaveQueue(sender, null); } catch (final Exception ex) { sender.sendMessage(ChatColor.RED + ex.getMessage()); } - sender.sendMessage(ChatColor.DARK_AQUA + "Searching " + params.getTitle() + ":"); + if (!params.silent) + sender.sendMessage(ChatColor.DARK_AQUA + "Searching " + params.getTitle() + ":"); rs = state.executeQuery(params.getRollbackQuery()); final WorldEditor editor = new WorldEditor(logblock, params.world); while (rs.next()) editor.queueBlockChange(rs.getInt("type"), rs.getInt("replaced"), rs.getByte("data"), rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getString("signtext"), rs.getShort("itemtype"), rs.getShort("itemamount"), rs.getByte("itemdata")); final int changes = editor.getSize(); - sender.sendMessage(ChatColor.GREEN.toString() + changes + " blocks found."); + if (!params.silent) + sender.sendMessage(ChatColor.GREEN.toString() + changes + " blocks found."); if (changes == 0) { - sender.sendMessage(ChatColor.RED + "Rollback aborted"); + if (!params.silent) + sender.sendMessage(ChatColor.RED + "Rollback aborted"); return; } - if (config.askRollbacks && questioner != null && sender instanceof Player && !questioner.ask((Player)sender, "Are you sure you want to continue?", "yes", "no").equals("yes")) { + if (!params.silent && config.askRollbacks && questioner != null && sender instanceof Player && !questioner.ask((Player)sender, "Are you sure you want to continue?", "yes", "no").equals("yes")) { sender.sendMessage(ChatColor.RED + "Rollback aborted"); return; } @@ -505,17 +507,20 @@ public class CommandsHandler implements CommandExecutor public void run() { try { rs = state.executeQuery(params.getRollbackQuery()); - sender.sendMessage(ChatColor.DARK_AQUA + "Searching " + params.getTitle() + ":"); + if (!params.silent) + sender.sendMessage(ChatColor.DARK_AQUA + "Searching " + params.getTitle() + ":"); final WorldEditor editor = new WorldEditor(logblock, params.world); while (rs.next()) editor.queueBlockChange(rs.getInt("replaced"), rs.getInt("type"), rs.getByte("data"), rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getString("signtext"), rs.getShort("itemtype"), (short)(rs.getShort("itemamount") * 1), rs.getByte("itemdata")); final int changes = editor.getSize(); - sender.sendMessage(ChatColor.GREEN.toString() + changes + " blocks found."); + if (!params.silent) + sender.sendMessage(ChatColor.GREEN.toString() + changes + " blocks found."); if (changes == 0) { - sender.sendMessage(ChatColor.RED + "Redo aborted"); + if (!params.silent) + sender.sendMessage(ChatColor.RED + "Redo aborted"); return; } - if (config.askRedos && questioner != null && sender instanceof Player && !questioner.ask((Player)sender, "Are you sure you want to continue?", "yes", "no").equals("yes")) { + if (!params.silent && config.askRedos && questioner != null && sender instanceof Player && !questioner.ask((Player)sender, "Are you sure you want to continue?", "yes", "no").equals("yes")) { sender.sendMessage(ChatColor.RED + "Redo aborted"); return; } @@ -551,7 +556,7 @@ public class CommandsHandler implements CommandExecutor rs = state.executeQuery("SELECT count(*) FROM `" + table + "` " + join + params.getWhere()); rs.next(); if ((deleted = rs.getInt(1)) > 0) { - if (config.askClearLogs && sender instanceof Player && questioner != null) { + if (!params.silent && config.askClearLogs && sender instanceof Player && questioner != null) { sender.sendMessage(ChatColor.DARK_AQUA + "Searching " + params.getTitle() + ":"); sender.sendMessage(ChatColor.GREEN.toString() + deleted + " blocks found."); if (!questioner.ask((Player)sender, "Are you sure you want to continue?", "yes", "no").equals("yes")) { diff --git a/src/de/diddiz/LogBlock/Config.java b/src/de/diddiz/LogBlock/Config.java index 9727de5..eb4ac78 100644 --- a/src/de/diddiz/LogBlock/Config.java +++ b/src/de/diddiz/LogBlock/Config.java @@ -124,9 +124,9 @@ public class Config if (!subkeys.contains("toolblockID")) config.setProperty("lookup.toolblockID", 7); if (!subkeys.contains("toolQuery")) - config.setProperty("lookup.toolQuery", "area 0 all sum none limit 15 desc"); + config.setProperty("lookup.toolQuery", "area 0 all sum none limit 15 desc silent"); if (!subkeys.contains("toolBlockQuery")) - config.setProperty("lookup.toolBlockQuery", "area 0 all sum none limit 15 desc"); + config.setProperty("lookup.toolBlockQuery", "area 0 all sum none limit 15 desc silent"); subkeys = config.getKeys("questioner"); if (subkeys == null) subkeys = new ArrayList(); diff --git a/src/de/diddiz/LogBlock/QueryParams.java b/src/de/diddiz/LogBlock/QueryParams.java index 2cce1a6..ac92059 100644 --- a/src/de/diddiz/LogBlock/QueryParams.java +++ b/src/de/diddiz/LogBlock/QueryParams.java @@ -23,13 +23,13 @@ import com.sk89q.worldedit.bukkit.selections.Selection; public class QueryParams implements Cloneable { - private static final HashSet keywords = new HashSet(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())); + private static final HashSet keywords = new HashSet(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())); public BlockChangeType bct = BlockChangeType.BOTH; public int limit = 15, minutes = 0, radius = -1; public Location loc = null; public Order order = Order.DESC; public List players = new ArrayList(); - public boolean prepareToolQuery = false, coords = false; + public boolean prepareToolQuery = false, coords = false, silent = false; public Selection sel = null; public SummarizationMode sum = SummarizationMode.NONE; public List types = new ArrayList(); @@ -304,6 +304,8 @@ public class QueryParams implements Cloneable order = Order.DESC; else if (param.equals("coords")) coords = true; + else if (param.equals("silent")) + silent = true; else throw new IllegalArgumentException("Not a valid argument: '" + param + "'"); if (values != null)