mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00:00
Added a //help command.
This commit is contained in:
@ -983,6 +983,13 @@ public class WorldEdit {
|
||||
return commands.getCommands();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the commands
|
||||
*/
|
||||
public CommandsManager<LocalPlayer> getCommandsManager() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
@ -20,9 +20,13 @@
|
||||
package com.sk89q.worldedit.commands;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||
import com.sk89q.minecraft.util.commands.Logging;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
||||
import com.sk89q.worldedit.*;
|
||||
@ -426,4 +430,48 @@ public class UtilityCommands {
|
||||
int removed = player.getWorld().removeEntities(type, origin, radius);
|
||||
player.print("Marked " + removed + " entit(ies) for removal.");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "/help" },
|
||||
usage = "[<command>]",
|
||||
desc = "Displays help for the given command or lists all commands.",
|
||||
min = 0,
|
||||
max = -1
|
||||
)
|
||||
public static void help(CommandContext args, WorldEdit we,
|
||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||
throws WorldEditException {
|
||||
|
||||
final CommandsManager<LocalPlayer> commandsManager = we.getCommandsManager();
|
||||
|
||||
if (args.argsLength() == 0) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean first = true;
|
||||
SortedSet<String> commands = new TreeSet<String>(commandsManager.getCommands().keySet());
|
||||
|
||||
for (String command : commands) {
|
||||
if (!first) {
|
||||
sb.append(", ");
|
||||
}
|
||||
|
||||
sb.append('/');
|
||||
sb.append(command);
|
||||
first = false;
|
||||
}
|
||||
|
||||
player.print(sb.toString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String command = args.getJoinedStrings(0).replaceAll("/", "");
|
||||
|
||||
String helpMessage = commandsManager.getHelpMessages().get(command);
|
||||
if (helpMessage == null) {
|
||||
player.printError("Unknown command '" + command + "'.");
|
||||
return;
|
||||
}
|
||||
|
||||
player.print(helpMessage);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user