use of me.botsko.prism.actionlibs.QueryParameters in project Prism-Bukkit by prism.
the class QueryWandBase method setParameters.
/**
* Set the field {@link #parameters} with the parameters here. This will be
* using the stuff in <code>/prism params</code>
*
* @param sender
* The sender of the command.
* @param args
* The arguments from <code>/prism params</code>.
* @param argStart
* What argument to start on.
*/
public boolean setParameters(Player sender, String[] args, int argStart) {
final PrismProcessType processType = this instanceof RollbackWand ? PrismProcessType.ROLLBACK : this instanceof RestoreWand ? PrismProcessType.RESTORE : this instanceof InspectorWand ? PrismProcessType.LOOKUP : PrismProcessType.LOOKUP;
final QueryParameters params = PreprocessArgs.process(plugin, sender, args, processType, argStart, false, true);
if (params == null) {
return false;
} else {
params.resetMinMaxVectors();
this.parameters = params;
return true;
}
}
use of me.botsko.prism.actionlibs.QueryParameters in project Prism-Bukkit by prism.
the class RestoreWand method restore.
/**
*
* @param player
* @param block
*/
protected void restore(Player player, Location loc) {
final Block block = loc.getBlock();
plugin.eventTimer.recordTimedEvent("rollback wand used");
// Build params
QueryParameters params;
try {
params = parameters.clone();
} catch (final CloneNotSupportedException ex) {
params = new QueryParameters();
player.sendMessage(Prism.messenger.playerError("Error retrieving parameters. Checking with default parameters."));
}
params.setWorld(player.getWorld().getName());
params.setSpecificBlockLocation(block.getLocation());
params.setLimit(1);
params.setProcessType(PrismProcessType.RESTORE);
boolean timeDefault = false;
for (final String _default : params.getDefaultsUsed()) {
if (_default.startsWith("t:")) {
timeDefault = true;
}
}
if (timeDefault) {
params.setIgnoreTime(true);
}
final ActionsQuery aq = new ActionsQuery(plugin);
final QueryResult results = aq.lookup(params, player);
if (!results.getActionResults().isEmpty()) {
final Restore rb = new Restore(plugin, player, results.getActionResults(), params, new PrismApplierCallback());
rb.apply();
} else {
final String space_name = (block.getType().equals(Material.AIR) ? "space" : block.getType().toString().replaceAll("_", " ").toLowerCase() + (block.getType().toString().endsWith("BLOCK") ? "" : " block"));
player.sendMessage(Prism.messenger.playerError("Nothing to restore for this " + space_name + " found."));
}
}
use of me.botsko.prism.actionlibs.QueryParameters in project Prism-Bukkit by prism.
the class PurgeManager method run.
/**
*
*/
@Override
public void run() {
Prism.log("Scheduled purge executor beginning new run...");
if (!purgeRules.isEmpty()) {
final CopyOnWriteArrayList<QueryParameters> paramList = new CopyOnWriteArrayList<QueryParameters>();
for (final String purgeArgs : purgeRules) {
// Process and validate all of the arguments
final QueryParameters parameters = PreprocessArgs.process(plugin, null, purgeArgs.split(" "), PrismProcessType.DELETE, 0, false);
if (parameters == null) {
Prism.log("Invalid parameters for database purge: " + purgeArgs);
continue;
}
if (parameters.getFoundArgs().size() > 0) {
parameters.setStringFromRawArgs(purgeArgs.split(" "), 0);
paramList.add(parameters);
}
}
if (paramList.size() > 0) {
// Identify the minimum for chunking
final int minId = PurgeChunkingUtil.getMinimumPrimaryKey();
if (minId == 0) {
Prism.log("No minimum primary key could be found for purge chunking.");
return;
}
// Identify the max id for chunking
final int maxId = PurgeChunkingUtil.getMaximumPrimaryKey();
if (maxId == 0) {
Prism.log("No maximum primary key could be found for purge chunking.");
return;
}
int purge_tick_delay = plugin.getConfig().getInt("prism.purge.batch-tick-delay");
if (purge_tick_delay < 1) {
purge_tick_delay = 20;
}
/**
* We're going to cycle through the param rules, one rule at a
* time in a single async task. This task will reschedule itself
* when each purge cycle has completed and records remain
*/
Prism.log("Beginning prism database purge cycle. Will be performed in batches so we don't tie up the db...");
deleteTask = Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new PurgeTask(plugin, paramList, purge_tick_delay, minId, maxId, new LogPurgeCallback()), purge_tick_delay);
}
} else {
Prism.log("Purge rules are empty, not purging anything.");
}
}
Aggregations