@Override public void onFailure(Throwable throwable) { LOGGER.log(Level.WARNING, "Failed to submit pastebin", throwable); sender.printError("Failed to submit to a pastebin. Please see console for the error."); } });
@Override public void onFailure(@Nullable Throwable throwable) { try { exceptionConverter.convert(throwable); } catch (CommandException e) { String failure = this.failure != null ? this.failure : "An error occurred"; String message = e.getMessage() != null ? e.getMessage() : "An unknown error occurred. Please see the console!"; sender.printError(failure + ": " + message); } }
/** * Flush a block bag's changes to a player. * * @param actor the actor * @param editSession the edit session */ public void flushBlockBag(Actor actor, EditSession editSession) { BlockBag blockBag = editSession.getBlockBag(); if (blockBag != null) { blockBag.flushChanges(); } Map<BlockType, Integer> missingBlocks = editSession.popMissingBlocks(); if (!missingBlocks.isEmpty()) { StringBuilder str = new StringBuilder(); str.append("Missing these blocks: "); int size = missingBlocks.size(); int i = 0; for (Map.Entry<BlockType, Integer> blockTypeIntegerEntry : missingBlocks.entrySet()) { str.append((blockTypeIntegerEntry.getKey()).getName()); str.append(" [Amt: ").append(blockTypeIntegerEntry.getValue()).append("]"); ++i; if (i != size) { str.append(", "); } } actor.printError(str.toString()); } }
@Command( aliases = { "/calc", "/calculate", "/eval", "/evaluate", "/solve" }, usage = "<expression>", desc = "Evaluate a mathematical expression" ) @CommandPermissions("worldedit.calc") public void calc(Actor actor, @Text String input) throws CommandException { try { Expression expression = Expression.compile(input); actor.print("= " + expression.evaluate()); } catch (EvaluationException e) { actor.printError(String.format( "'%s' could not be parsed as a valid expression", input)); } catch (ExpressionException e) { actor.printError(String.format( "'%s' could not be evaluated (error: %s)", input, e.getMessage())); } }
actor.printError("No schematics found."); return; actor.printError("Page must be at least 1"); return; actor.printError("Page must be less than " + (pageCount + 1)); return;
@Override public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) { Vector3 center = region.getCenter(); if (!center.equals(Vector3.ZERO)) { player.print("Radius set to " + NUMBER_FORMAT.format(region.getRadius().getX()) + "/" + NUMBER_FORMAT.format(region.getRadius().getZ()) + " blocks. (" + region.getArea() + ")."); } else { player.printError("You must select the center point before setting the radius."); return; } session.describeCUI(player); }
} else { if (isRootLevel) { actor.printError(String.format("The command '%s' could not be found.", args.getString(i))); return; } else { actor.printError(String.format("The sub-command '%s' under '%s' could not be found.", command, Joiner.on(" ").join(visited))); return; isRootLevel = false; } else { actor.printError(String.format("'%s' has no sub-commands. (Maybe '%s' is for a parameter?)", Joiner.on(" ").join(visited), command)); return;
actor.printError("You are not permitted to do that. Are you in the right mode?"); } catch (InvalidUsageException e) { if (e.isFullHelpSuggested()) { String message = e.getMessage(); if (message != null) { actor.printError(message); actor.printError(message != null ? message : "The command was not used properly (no more help available)."); actor.printError("Usage: " + e.getSimpleUsageString("/")); actor.printError("Please report this error: [See console]"); actor.printRaw(t.getClass().getName() + ": " + t.getMessage()); log.log(Level.SEVERE, "An unexpected error while handling a WorldEdit command", t); String message = e.getMessage(); if (message != null) { actor.printError(e.getMessage()); } else { actor.printError("An unknown error has occurred! Please see console."); log.log(Level.SEVERE, "An unknown error occurred", e);
} else { if (query.length() <= 2) { actor.printError("Enter a longer search string (len > 2)."); return; actor.print("Searching for: " + query); } else if (blocksOnly && itemsOnly) { actor.printError("You cannot use both the 'b' and 'i' flags simultaneously."); return; } else if (blocksOnly) { actor.printError("No items found.");
@Command(aliases = {"report"}, desc = "Writes a report on WorldEdit", flags = "p", max = 0) @CommandPermissions({"worldedit.report"}) public void report(Actor actor, CommandContext args) throws WorldEditException { ReportList report = new ReportList("Report"); report.add(new SystemInfoReport()); report.add(new ConfigReport()); String result = report.toString(); try { File dest = new File(we.getWorkingDirectoryFile(we.getConfiguration().saveDir), "report.txt"); Files.write(result, dest, Charset.forName("UTF-8")); actor.print("WorldEdit report written to " + dest.getAbsolutePath()); } catch (IOException e) { actor.printError("Failed to write report: " + e.getMessage()); } if (args.hasFlag('p')) { actor.checkPermission("worldedit.report.pastebin"); ActorCallbackPaste.pastebin( we.getSupervisor(), actor, result, "WorldEdit report: %s.report", WorldEdit.getInstance().getPlatformManager().getCommandManager().getExceptionConverter() ); } }
@Subscribe public void handleCommandSuggestion(CommandSuggestionEvent event) { try { CommandLocals locals = new CommandLocals(); locals.put(Actor.class, event.getActor()); locals.put("arguments", event.getArguments()); event.setSuggestions(dispatcher.getSuggestions(event.getArguments(), locals)); } catch (CommandException e) { event.getActor().printError(e.getMessage()); } }
actor.printError("Use -1 to remove all entities in loaded chunks"); return;
radius = args.getInteger(0); if (radius < -1) { actor.printError("Use -1 to remove all mobs in loaded chunks"); return;
@Override public void onSuccess(Sampler result) { String output = result.toString(); try { File dest = new File(worldGuard.getPlatform().getConfigDir().toFile(), "profile.txt"); Files.write(output, dest, Charset.forName("UTF-8")); sender.print("CPU profiling data written to " + dest.getAbsolutePath()); } catch (IOException e) { sender.printError("Failed to write CPU profiling data: " + e.getMessage()); } if (pastebin) { ActorCallbackPaste.pastebin(worldGuard.getSupervisor(), sender, output, "Profile result: %s.profile", worldGuard.getExceptionConverter()); } }
final int pages = (int) Math.ceil(totalSize / (float) pageSize); sender.printError( (ownerMatcher == null ? "Regions (page " : "Regions for " + ownerMatcher.getName() + " (page ") + (page + 1) + " of " + pages + "):");
sender.printError("Error while reloading: " + t.getMessage()); } finally { if (minecraftLogger != null) {
sender.printError("Unknown flag specified: " + flagName); sender.printError("Available flags: " + list);