use of me.botsko.prism.appliers.Restore in project Prism-Bukkit by prism.
the class PreviewCommand method handleRestore.
private void handleRestore(CallInfo call, QueryParameters parameters, QueryResult results, Audience audience) {
parameters.setProcessType(PrismProcessType.RESTORE);
if (!results.getActionResults().isEmpty()) {
Prism.messenger.sendMessage(call.getPlayer(), Prism.messenger.playerHeaderMsg(Il8nHelper.getMessage("preview-apply-start")));
// Perform preview on the main thread
plugin.getServer().getScheduler().runTask(plugin, () -> {
final Previewable rs = new Restore(plugin, call.getPlayer(), results.getActionResults(), parameters, new PrismApplierCallback());
rs.preview();
});
} else {
Prism.messenger.sendMessage(call.getPlayer(), Prism.messenger.playerError(Il8nHelper.getMessage("preview-no-actions")));
}
}
use of me.botsko.prism.appliers.Restore in project Prism-Bukkit by prism.
the class RestoreWand method restore.
protected void restore(Player player, Location loc) {
final Block block = loc.getBlock();
QueryParameters params = checkQueryParams(block, parameters, player);
params.setProcessType(PrismProcessType.RESTORE);
final QueryResult results = getResult(params, player);
if (!results.getActionResults().isEmpty()) {
final Previewable 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"));
Prism.messenger.sendMessage(player, Prism.messenger.playerError("Nothing to restore for this " + space_name + " found."));
}
}
use of me.botsko.prism.appliers.Restore in project Prism-Bukkit by prism.
the class RestoreCommand method handle.
@Override
public void handle(final CallInfo call) {
final QueryParameters parameters = PreprocessArgs.process(plugin, call.getSender(), call.getArgs(), PrismProcessType.RESTORE, 1, !plugin.getConfig().getBoolean("prism.queries.never-use-defaults"));
if (parameters == null) {
return;
}
parameters.setProcessType(PrismProcessType.RESTORE);
parameters.setStringFromRawArgs(call.getArgs(), 1);
StringBuilder defaultsReminder = checkIfDefaultUsed(parameters);
Prism.messenger.sendMessage(call.getSender(), Prism.messenger.playerSubduedHeaderMsg(ReplaceableTextComponent.builder("restore-prepare").replace("<defaults>", defaultsReminder).build()));
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
final ActionsQuery aq = new ActionsQuery(plugin);
final QueryResult results = aq.lookup(parameters, call.getSender());
if (!results.getActionResults().isEmpty()) {
Prism.messenger.sendMessage(call.getSender(), Prism.messenger.playerHeaderMsg(Il8nHelper.getMessage("restore-start")));
// Inform nearby players
if (call.getSender() instanceof Player) {
final Player player = (Player) call.getSender();
plugin.notifyNearby(player, parameters.getRadius(), ReplaceableTextComponent.builder("block-changes-near").replace("<player>", player.getDisplayName()).build());
}
// Perform restore on the main thread
plugin.getServer().getScheduler().runTask(plugin, () -> {
final Previewable rs = new Restore(plugin, call.getSender(), results.getActionResults(), parameters, new PrismApplierCallback());
rs.apply();
});
} else {
Prism.messenger.sendMessage(call.getSender(), Prism.messenger.playerError(Il8nHelper.getMessage("restore-error")));
}
});
}
Aggregations