mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Update to latest Piston changes
This commit is contained in:
parent
7dcf8f5a45
commit
0960f70e6b
@ -39,6 +39,7 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
|||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.io.Closer;
|
import com.sk89q.worldedit.util.io.Closer;
|
||||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||||
import org.enginehub.piston.annotation.Command;
|
import org.enginehub.piston.annotation.Command;
|
||||||
@ -159,7 +160,7 @@ public class SchematicCommands {
|
|||||||
boolean overwrite = f.exists();
|
boolean overwrite = f.exists();
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
if (!player.hasPermission("worldedit.schematic.delete")) {
|
if (!player.hasPermission("worldedit.schematic.delete")) {
|
||||||
throw new StopExecutionException("That schematic already exists!");
|
throw new StopExecutionException(TextComponent.of("That schematic already exists!"));
|
||||||
}
|
}
|
||||||
if (!allowOverwrite) {
|
if (!allowOverwrite) {
|
||||||
player.printError("That schematic already exists. Use the -f flag to overwrite it.");
|
player.printError("That schematic already exists. Use the -f flag to overwrite it.");
|
||||||
@ -186,7 +187,8 @@ public class SchematicCommands {
|
|||||||
File parent = f.getParentFile();
|
File parent = f.getParentFile();
|
||||||
if (parent != null && !parent.exists()) {
|
if (parent != null && !parent.exists()) {
|
||||||
if (!parent.mkdirs()) {
|
if (!parent.mkdirs()) {
|
||||||
throw new StopExecutionException("Could not create folder for schematics!");
|
throw new StopExecutionException(TextComponent.of(
|
||||||
|
"Could not create folder for schematics!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +279,7 @@ public class SchematicCommands {
|
|||||||
@Switch(name = 'n', desc = "Sort by date, newest first")
|
@Switch(name = 'n', desc = "Sort by date, newest first")
|
||||||
boolean newFirst) {
|
boolean newFirst) {
|
||||||
if (oldFirst && newFirst) {
|
if (oldFirst && newFirst) {
|
||||||
throw new StopExecutionException("Cannot sort by oldest and newest.");
|
throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest."));
|
||||||
}
|
}
|
||||||
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir);
|
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir);
|
||||||
List<File> fileList = allFiles(dir);
|
List<File> fileList = allFiles(dir);
|
||||||
|
@ -83,13 +83,13 @@ public class PrintCommandHelp {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> visited = new ArrayList<>();
|
List<Command> visited = new ArrayList<>();
|
||||||
Command currentCommand = detectCommand(manager, commandPath.get(0));
|
Command currentCommand = detectCommand(manager, commandPath.get(0));
|
||||||
if (currentCommand == null) {
|
if (currentCommand == null) {
|
||||||
actor.printError(String.format("The command '%s' could not be found.", commandPath.get(0)));
|
actor.printError(String.format("The command '%s' could not be found.", commandPath.get(0)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
visited.add(commandPath.get(0));
|
visited.add(currentCommand);
|
||||||
|
|
||||||
// Drill down to the command
|
// Drill down to the command
|
||||||
for (int i = 1; i < commandPath.size(); i++) {
|
for (int i = 1; i < commandPath.size(); i++) {
|
||||||
@ -103,8 +103,8 @@ public class PrintCommandHelp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (subCommands.containsKey(subCommand)) {
|
if (subCommands.containsKey(subCommand)) {
|
||||||
visited.add(subCommand);
|
|
||||||
currentCommand = subCommands.get(subCommand);
|
currentCommand = subCommands.get(subCommand);
|
||||||
|
visited.add(currentCommand);
|
||||||
} else {
|
} else {
|
||||||
actor.printError(String.format("The sub-command '%s' under '%s' could not be found.",
|
actor.printError(String.format("The sub-command '%s' under '%s' could not be found.",
|
||||||
subCommand, Joiner.on(" ").join(visited)));
|
subCommand, Joiner.on(" ").join(visited)));
|
||||||
@ -116,7 +116,8 @@ public class PrintCommandHelp {
|
|||||||
|
|
||||||
if (subCommands.isEmpty()) {
|
if (subCommands.isEmpty()) {
|
||||||
// Create the message
|
// Create the message
|
||||||
CommandUsageBox box = new CommandUsageBox(currentCommand, String.join(" ", visited));
|
CommandUsageBox box = new CommandUsageBox(visited, visited.stream()
|
||||||
|
.map(Command::getName).collect(Collectors.joining(" ")));
|
||||||
actor.print(box.create());
|
actor.print(box.create());
|
||||||
} else {
|
} else {
|
||||||
printAllCommands(page, perPage, subCommands.values().stream(), actor, visited);
|
printAllCommands(page, perPage, subCommands.values().stream(), actor, visited);
|
||||||
@ -124,7 +125,7 @@ public class PrintCommandHelp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void printAllCommands(int page, int perPage, Stream<Command> commandStream, Actor actor,
|
private static void printAllCommands(int page, int perPage, Stream<Command> commandStream, Actor actor,
|
||||||
List<String> commandList) {
|
List<Command> commandList) {
|
||||||
// Get a list of aliases
|
// Get a list of aliases
|
||||||
List<Command> commands = commandStream
|
List<Command> commands = commandStream
|
||||||
.sorted(byCleanName())
|
.sorted(byCleanName())
|
||||||
@ -151,7 +152,8 @@ public class PrintCommandHelp {
|
|||||||
// Add each command
|
// Add each command
|
||||||
for (Command mapping : list) {
|
for (Command mapping : list) {
|
||||||
String alias = (commandList.isEmpty() ? "/" : "") + mapping.getName();
|
String alias = (commandList.isEmpty() ? "/" : "") + mapping.getName();
|
||||||
String command = Stream.concat(commandList.stream(), Stream.of(mapping.getName()))
|
String command = Stream.concat(commandList.stream(), Stream.of(mapping))
|
||||||
|
.map(Command::getName)
|
||||||
.collect(Collectors.joining(" ", "/", ""));
|
.collect(Collectors.joining(" ", "/", ""));
|
||||||
box.appendCommand(alias, mapping.getDescription(), command);
|
box.appendCommand(alias, mapping.getDescription(), command);
|
||||||
}
|
}
|
||||||
|
@ -94,9 +94,11 @@ import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
|
|||||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||||
import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
|
import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
|
||||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import org.enginehub.piston.ColorConfig;
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
import org.enginehub.piston.DefaultCommandManagerService;
|
import org.enginehub.piston.DefaultCommandManagerService;
|
||||||
@ -112,6 +114,7 @@ import org.enginehub.piston.inject.MapBackedValueStore;
|
|||||||
import org.enginehub.piston.inject.MemoizingValueAccess;
|
import org.enginehub.piston.inject.MemoizingValueAccess;
|
||||||
import org.enginehub.piston.inject.MergedValueAccess;
|
import org.enginehub.piston.inject.MergedValueAccess;
|
||||||
import org.enginehub.piston.part.SubCommandPart;
|
import org.enginehub.piston.part.SubCommandPart;
|
||||||
|
import org.enginehub.piston.util.HelpGenerator;
|
||||||
import org.enginehub.piston.util.ValueProvider;
|
import org.enginehub.piston.util.ValueProvider;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -499,21 +502,28 @@ public final class PlatformCommandManager {
|
|||||||
actor.printError("You are not permitted to do that. Are you in the right mode?");
|
actor.printError("You are not permitted to do that. Are you in the right mode?");
|
||||||
}
|
}
|
||||||
} catch (UsageException e) {
|
} catch (UsageException e) {
|
||||||
String message = e.getMessage();
|
actor.print(TextComponent.builder("")
|
||||||
actor.printError(message != null ? message : "The command was not used properly (no more help available).");
|
.color(TextColor.RED)
|
||||||
|
.append(e.getRichMessage())
|
||||||
|
.build());
|
||||||
|
ImmutableList<Command> cmd = e.getCommands();
|
||||||
|
if (cmd.size() > 0) {
|
||||||
|
actor.print(TextComponent.builder("Usage: ")
|
||||||
|
.color(TextColor.RED)
|
||||||
|
.append(TextComponent.of("/", ColorConfig.getMainText()))
|
||||||
|
.append(HelpGenerator.create(cmd).getUsage())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
} catch (CommandExecutionException e) {
|
} catch (CommandExecutionException e) {
|
||||||
Throwable t = e.getCause();
|
Throwable t = e.getCause();
|
||||||
actor.printError("Please report this error: [See console]");
|
actor.printError("Please report this error: [See console]");
|
||||||
actor.printRaw(t.getClass().getName() + ": " + t.getMessage());
|
actor.printRaw(t.getClass().getName() + ": " + t.getMessage());
|
||||||
log.error("An unexpected error while handling a WorldEdit command", t);
|
log.error("An unexpected error while handling a WorldEdit command", t);
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
String message = e.getMessage();
|
actor.print(TextComponent.builder("")
|
||||||
if (message != null) {
|
.color(TextColor.RED)
|
||||||
actor.printError(e.getMessage());
|
.append(e.getRichMessage())
|
||||||
} else {
|
.build());
|
||||||
actor.printError("An unknown error has occurred! Please see console.");
|
|
||||||
log.error("An unknown error occurred", e);
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
Optional<EditSession> editSessionOpt =
|
Optional<EditSession> editSessionOpt =
|
||||||
context.snapshotMemory().injectedValue(Key.of(EditSession.class));
|
context.snapshotMemory().injectedValue(Key.of(EditSession.class));
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.internal.command;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.worldedit.DisallowedItemException;
|
import com.sk89q.worldedit.DisallowedItemException;
|
||||||
import com.sk89q.worldedit.EmptyClipboardException;
|
import com.sk89q.worldedit.EmptyClipboardException;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
@ -39,6 +40,7 @@ import com.sk89q.worldedit.internal.expression.ExpressionException;
|
|||||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ExceptionConverterHelper;
|
import com.sk89q.worldedit.util.command.parametric.ExceptionConverterHelper;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ExceptionMatch;
|
import com.sk89q.worldedit.util.command.parametric.ExceptionMatch;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
|
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
|
||||||
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
|
import com.sk89q.worldedit.util.io.file.FilenameResolutionException;
|
||||||
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
|
import com.sk89q.worldedit.util.io.file.InvalidFilenameException;
|
||||||
@ -61,110 +63,114 @@ public class WorldEditExceptionConverter extends ExceptionConverterHelper {
|
|||||||
this.worldEdit = worldEdit;
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CommandException newCommandException(String message, Throwable cause) {
|
||||||
|
return new CommandException(TextComponent.of(message), cause, ImmutableList.of());
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(NumberFormatException e) throws CommandException {
|
public void convert(NumberFormatException e) throws CommandException {
|
||||||
final Matcher matcher = numberFormat.matcher(e.getMessage());
|
final Matcher matcher = numberFormat.matcher(e.getMessage());
|
||||||
|
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
throw new CommandException("Number expected; string \"" + matcher.group(1)
|
throw newCommandException("Number expected; string \"" + matcher.group(1)
|
||||||
+ "\" given.", e, null);
|
+ "\" given.", e);
|
||||||
} else {
|
} else {
|
||||||
throw new CommandException("Number expected; string given.", e, null);
|
throw newCommandException("Number expected; string given.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(IncompleteRegionException e) throws CommandException {
|
public void convert(IncompleteRegionException e) throws CommandException {
|
||||||
throw new CommandException("Make a region selection first.", e, null);
|
throw newCommandException("Make a region selection first.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(UnknownItemException e) throws CommandException {
|
public void convert(UnknownItemException e) throws CommandException {
|
||||||
throw new CommandException("Block name '" + e.getID() + "' was not recognized.", e, null);
|
throw newCommandException("Block name '" + e.getID() + "' was not recognized.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(InvalidItemException e) throws CommandException {
|
public void convert(InvalidItemException e) throws CommandException {
|
||||||
throw new CommandException(e.getMessage(), e, null);
|
throw newCommandException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(DisallowedItemException e) throws CommandException {
|
public void convert(DisallowedItemException e) throws CommandException {
|
||||||
throw new CommandException("Block '" + e.getID()
|
throw newCommandException("Block '" + e.getID()
|
||||||
+ "' not allowed (see WorldEdit configuration).", e, null);
|
+ "' not allowed (see WorldEdit configuration).", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(MaxChangedBlocksException e) throws CommandException {
|
public void convert(MaxChangedBlocksException e) throws CommandException {
|
||||||
throw new CommandException("Max blocks changed in an operation reached ("
|
throw newCommandException("Max blocks changed in an operation reached ("
|
||||||
+ e.getBlockLimit() + ").", e, null);
|
+ e.getBlockLimit() + ").", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(MaxBrushRadiusException e) throws CommandException {
|
public void convert(MaxBrushRadiusException e) throws CommandException {
|
||||||
throw new CommandException("Maximum brush radius (in configuration): " + worldEdit.getConfiguration().maxBrushRadius, e, null);
|
throw newCommandException("Maximum brush radius (in configuration): " + worldEdit.getConfiguration().maxBrushRadius, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(MaxRadiusException e) throws CommandException {
|
public void convert(MaxRadiusException e) throws CommandException {
|
||||||
throw new CommandException("Maximum radius (in configuration): " + worldEdit.getConfiguration().maxRadius, e, null);
|
throw newCommandException("Maximum radius (in configuration): " + worldEdit.getConfiguration().maxRadius, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(UnknownDirectionException e) throws CommandException {
|
public void convert(UnknownDirectionException e) throws CommandException {
|
||||||
throw new CommandException("Unknown direction: " + e.getDirection(), e, null);
|
throw newCommandException("Unknown direction: " + e.getDirection(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(InsufficientArgumentsException e) throws CommandException {
|
public void convert(InsufficientArgumentsException e) throws CommandException {
|
||||||
throw new CommandException(e.getMessage(), e, null);
|
throw newCommandException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(RegionOperationException e) throws CommandException {
|
public void convert(RegionOperationException e) throws CommandException {
|
||||||
throw new CommandException(e.getMessage(), e, null);
|
throw newCommandException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(ExpressionException e) throws CommandException {
|
public void convert(ExpressionException e) throws CommandException {
|
||||||
throw new CommandException(e.getMessage(), e, null);
|
throw newCommandException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(EmptyClipboardException e) throws CommandException {
|
public void convert(EmptyClipboardException e) throws CommandException {
|
||||||
throw new CommandException("Your clipboard is empty. Use //copy first.", e, null);
|
throw newCommandException("Your clipboard is empty. Use //copy first.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(InvalidFilenameException e) throws CommandException {
|
public void convert(InvalidFilenameException e) throws CommandException {
|
||||||
throw new CommandException("Filename '" + e.getFilename() + "' invalid: "
|
throw newCommandException("Filename '" + e.getFilename() + "' invalid: "
|
||||||
+ e.getMessage(), e, null);
|
+ e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(FilenameResolutionException e) throws CommandException {
|
public void convert(FilenameResolutionException e) throws CommandException {
|
||||||
throw new CommandException(
|
throw newCommandException(
|
||||||
"File '" + e.getFilename() + "' resolution error: " + e.getMessage(), e, null);
|
"File '" + e.getFilename() + "' resolution error: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(InvalidToolBindException e) throws CommandException {
|
public void convert(InvalidToolBindException e) throws CommandException {
|
||||||
throw new CommandException("Can't bind tool to " + e.getItemType().getName() + ": " + e.getMessage(), e, null);
|
throw newCommandException("Can't bind tool to " + e.getItemType().getName() + ": " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(FileSelectionAbortedException e) throws CommandException {
|
public void convert(FileSelectionAbortedException e) throws CommandException {
|
||||||
throw new CommandException("File selection aborted.", e, null);
|
throw newCommandException("File selection aborted.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(WorldEditException e) throws CommandException {
|
public void convert(WorldEditException e) throws CommandException {
|
||||||
throw new CommandException(e.getMessage(), e, null);
|
throw newCommandException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionMatch
|
@ExceptionMatch
|
||||||
public void convert(IllegalArgumentException e) throws CommandException {
|
public void convert(IllegalArgumentException e) throws CommandException {
|
||||||
throw new CommandException(e.getMessage(), e, null);
|
throw newCommandException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.util.formatting.component;
|
package com.sk89q.worldedit.util.formatting.component;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.CommandParameters;
|
import org.enginehub.piston.CommandParameters;
|
||||||
|
import org.enginehub.piston.util.HelpGenerator;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -39,26 +41,26 @@ public class CommandUsageBox extends TextComponentProducer {
|
|||||||
/**
|
/**
|
||||||
* Create a new usage box.
|
* Create a new usage box.
|
||||||
*
|
*
|
||||||
* @param command the command to describe
|
* @param commands the commands to describe
|
||||||
* @param commandString the command that was used, such as "/we" or "/brush sphere"
|
* @param commandString the commands that were used, such as "/we" or "/brush sphere"
|
||||||
*/
|
*/
|
||||||
public CommandUsageBox(Command command, String commandString) {
|
public CommandUsageBox(List<Command> commands, String commandString) {
|
||||||
this(command, commandString, null);
|
this(commands, commandString, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new usage box.
|
* Create a new usage box.
|
||||||
*
|
*
|
||||||
* @param command the command to describe
|
* @param commands the commands to describe
|
||||||
* @param commandString the command that was used, such as "/we" or "/brush sphere"
|
* @param commandString the commands that were used, such as "/we" or "/brush sphere"
|
||||||
* @param parameters list of parameters to use
|
* @param parameters list of parameters to use
|
||||||
*/
|
*/
|
||||||
public CommandUsageBox(Command command, String commandString, @Nullable CommandParameters parameters) {
|
public CommandUsageBox(List<Command> commands, String commandString, @Nullable CommandParameters parameters) {
|
||||||
checkNotNull(command);
|
checkNotNull(commands);
|
||||||
checkNotNull(commandString);
|
checkNotNull(commandString);
|
||||||
Map<String, Command> subCommands = getSubCommands(command);
|
Map<String, Command> subCommands = getSubCommands(Iterables.getLast(commands));
|
||||||
if (subCommands.isEmpty()) {
|
if (subCommands.isEmpty()) {
|
||||||
attachCommandUsage(command, commandString);
|
attachCommandUsage(commands, commandString);
|
||||||
} else {
|
} else {
|
||||||
attachSubcommandUsage(subCommands, commandString, parameters);
|
attachSubcommandUsage(subCommands, commandString, parameters);
|
||||||
}
|
}
|
||||||
@ -81,9 +83,9 @@ public class CommandUsageBox extends TextComponentProducer {
|
|||||||
append(box.create());
|
append(box.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attachCommandUsage(Command description, String commandString) {
|
private void attachCommandUsage(List<Command> commands, String commandString) {
|
||||||
MessageBox box = new MessageBox("Help for " + commandString,
|
MessageBox box = new MessageBox("Help for " + commandString,
|
||||||
new TextComponentProducer().append(description.getFullHelp()));
|
new TextComponentProducer().append(HelpGenerator.create(commands).getFullHelp()));
|
||||||
|
|
||||||
append(box.create());
|
append(box.create());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user