1 package org.bukkit.command;
5 import org.apache.commons.lang.Validate;
6 import org.bukkit.plugin.Plugin;
12 private final Plugin owningPlugin;
18 this.executor = owner;
19 this.owningPlugin = owner;
33 boolean success =
false;
44 success = executor.
onCommand(sender,
this, commandLabel, args);
45 }
catch (Throwable ex) {
50 for (String line :
usageMessage.replace(
"<command>", commandLabel).split(
"\n")) {
64 this.executor = executor == null ? owningPlugin : executor;
84 this.completer = completer;
120 Validate.notNull(sender,
"Sender cannot be null");
121 Validate.notNull(args,
"Arguments cannot be null");
122 Validate.notNull(alias,
"Alias cannot be null");
124 List<String> completions = null;
126 if (completer != null) {
127 completions = completer.
onTabComplete(sender,
this, alias, args);
129 if (completions == null && executor instanceof
TabCompleter) {
130 completions = ((TabCompleter) executor).onTabComplete(sender,
this, alias, args);
132 }
catch (Throwable ex) {
133 StringBuilder message =
new StringBuilder();
134 message.append(
"Unhandled exception during tab completion for command '/").append(alias).append(
' ');
135 for (String arg : args) {
136 message.append(arg).append(
' ');
142 if (completions == null) {
143 return super.tabComplete(sender, alias, args);
150 StringBuilder stringBuilder =
new StringBuilder(super.toString());
151 stringBuilder.deleteCharAt(stringBuilder.length() - 1);
153 return stringBuilder.toString();