String commandName = message.split(" ")[0].substring(1).toLowerCase();
String args = commandName.length() + 1 >= message.length() ? "" : message.substring(commandName.length() + 2);
CommandConfig config = server.config.commands.getTopConfig(commandName);
String originalName = config == null ? commandName : config.originalName;
PlayerCommand command = server.resolvePlayerCommand(originalName, groupObject);
if (config != null && !overridePermissions) {
Permission permission = server.config.getCommandPermission(config.name, args, position.coordinate());
if (!permission.contains(this)) {
addTMessage(Color.RED, "Insufficient permission.");
return null;
}
}
try {
if (server.options.getBoolean("enableEvents") && config.event != null) {
Event e = server.eventhost.findEvent(config.event);
if (e != null) {
ArrayList<String> arguments = new ArrayList<String>();
if (!args.equals("")) {
arguments = new ArrayList<String>(java.util.Arrays.asList(args.split("\\s+")));
}
server.eventhost.execute(e, this, true, arguments);
} else {
System.out.println("Error in player command " + originalName + ": Event " + config.event + " not found!");
}
}
} catch (NullPointerException e) {
System.out.println("Error evaluating player command: " + originalName);
}
if (!(command instanceof ExternalCommand) && (config == null || config.forwarding != Forwarding.ONLY)) {
command.execute(this, message);
}
if (command instanceof ExternalCommand) {
// commands with bound events have to be forwarded explicitly
// (to prevent unknown command error by server)