This now uses an annoymous class implementing IExecutor that facilitates direct event method handler calling Changed commands from being executed exclusively by a player to by a CommandSender to facilitate external command callers such as rcon Fixed CustomEventListener Merged in additional events Added getFullName to PluginDescriptionFile which returns the combination of Name and Version There's also a few bits of reformatting as it seems someones been editing with either tabs or dos eol :(
31 lines
1.1 KiB
Java
31 lines
1.1 KiB
Java
package org.bukkit.command;
|
|
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
public final class PluginCommand extends Command {
|
|
private final Plugin owningPlugin;
|
|
|
|
public PluginCommand(String name, Plugin owner) {
|
|
super(name);
|
|
this.owningPlugin = owner;
|
|
this.usageMessage = "";
|
|
}
|
|
|
|
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
|
boolean cmdSuccess = owningPlugin.onCommand(sender, this, commandLabel, args);
|
|
if (!cmdSuccess && !usageMessage.isEmpty()) {
|
|
String tmpMsg = usageMessage.replace("<command>", commandLabel);
|
|
String[] usageLines = tmpMsg.split("\\n");
|
|
for(String line: usageLines) {
|
|
while (line.length() > 0) {
|
|
int stripChars = (line.length() > 53 ? 53:line.length());
|
|
sender.sendMessage(ChatColor.RED + line.substring(0, stripChars));
|
|
line = line.substring(stripChars);
|
|
}
|
|
}
|
|
}
|
|
return cmdSuccess;
|
|
}
|
|
} |