Added silent parameter

This commit is contained in:
Robin Kupper
2011-06-12 23:50:52 +02:00
parent 3c978b5e76
commit d0c60e47c4
3 changed files with 22 additions and 15 deletions

View File

@@ -462,25 +462,27 @@ public class CommandsHandler implements CommandExecutor
@Override @Override
public void run() { public void run() {
try { try {
final int queue = logblock.getConsumer().getQueueSize(); if (logblock.getConsumer().getQueueSize() > 50)
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")))
try { try {
new CommandSaveQueue(sender, null); new CommandSaveQueue(sender, null);
} catch (final Exception ex) { } catch (final Exception ex) {
sender.sendMessage(ChatColor.RED + ex.getMessage()); 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()); rs = state.executeQuery(params.getRollbackQuery());
final WorldEditor editor = new WorldEditor(logblock, params.world); final WorldEditor editor = new WorldEditor(logblock, params.world);
while (rs.next()) 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")); 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(); 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) { if (changes == 0) {
sender.sendMessage(ChatColor.RED + "Rollback aborted"); if (!params.silent)
sender.sendMessage(ChatColor.RED + "Rollback aborted");
return; 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"); sender.sendMessage(ChatColor.RED + "Rollback aborted");
return; return;
} }
@@ -505,17 +507,20 @@ public class CommandsHandler implements CommandExecutor
public void run() { public void run() {
try { try {
rs = state.executeQuery(params.getRollbackQuery()); 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); final WorldEditor editor = new WorldEditor(logblock, params.world);
while (rs.next()) 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")); 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(); 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) { if (changes == 0) {
sender.sendMessage(ChatColor.RED + "Redo aborted"); if (!params.silent)
sender.sendMessage(ChatColor.RED + "Redo aborted");
return; 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"); sender.sendMessage(ChatColor.RED + "Redo aborted");
return; return;
} }
@@ -551,7 +556,7 @@ public class CommandsHandler implements CommandExecutor
rs = state.executeQuery("SELECT count(*) FROM `" + table + "` " + join + params.getWhere()); rs = state.executeQuery("SELECT count(*) FROM `" + table + "` " + join + params.getWhere());
rs.next(); rs.next();
if ((deleted = rs.getInt(1)) > 0) { 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.DARK_AQUA + "Searching " + params.getTitle() + ":");
sender.sendMessage(ChatColor.GREEN.toString() + deleted + " blocks found."); sender.sendMessage(ChatColor.GREEN.toString() + deleted + " blocks found.");
if (!questioner.ask((Player)sender, "Are you sure you want to continue?", "yes", "no").equals("yes")) { if (!questioner.ask((Player)sender, "Are you sure you want to continue?", "yes", "no").equals("yes")) {

View File

@@ -124,9 +124,9 @@ public class Config
if (!subkeys.contains("toolblockID")) if (!subkeys.contains("toolblockID"))
config.setProperty("lookup.toolblockID", 7); config.setProperty("lookup.toolblockID", 7);
if (!subkeys.contains("toolQuery")) 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")) 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"); subkeys = config.getKeys("questioner");
if (subkeys == null) if (subkeys == null)
subkeys = new ArrayList<String>(); subkeys = new ArrayList<String>();

View File

@@ -23,13 +23,13 @@ import com.sk89q.worldedit.bukkit.selections.Selection;
public class QueryParams implements Cloneable public class QueryParams implements Cloneable
{ {
private static final HashSet<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())); private static final HashSet<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()));
public BlockChangeType bct = BlockChangeType.BOTH; public BlockChangeType bct = BlockChangeType.BOTH;
public int limit = 15, minutes = 0, radius = -1; public int limit = 15, minutes = 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>();
public boolean prepareToolQuery = false, coords = false; public boolean prepareToolQuery = false, coords = false, silent = false;
public Selection sel = null; public Selection sel = null;
public SummarizationMode sum = SummarizationMode.NONE; public SummarizationMode sum = SummarizationMode.NONE;
public List<Integer> types = new ArrayList<Integer>(); public List<Integer> types = new ArrayList<Integer>();
@@ -304,6 +304,8 @@ public class QueryParams implements Cloneable
order = Order.DESC; order = Order.DESC;
else if (param.equals("coords")) else if (param.equals("coords"))
coords = true; coords = true;
else if (param.equals("silent"))
silent = true;
else else
throw new IllegalArgumentException("Not a valid argument: '" + param + "'"); throw new IllegalArgumentException("Not a valid argument: '" + param + "'");
if (values != null) if (values != null)