use of org.bukkit.event.server.RemoteServerCommandEvent in project Glowstone by GlowstoneMC.
the class RconHandler method handleCommand.
private void handleCommand(ChannelHandlerContext ctx, String payload, int requestId) {
if (!loggedIn) {
sendResponse(ctx, FAILURE, TYPE_COMMAND, "");
return;
}
try {
RemoteServerCommandEvent event = EventFactory.getInstance().callEvent(new RemoteServerCommandEvent(commandSender, payload));
if (event.isCancelled()) {
return;
}
rconServer.getServer().dispatchCommand(commandSender, event.getCommand());
String message = commandSender.flush();
if (!rconServer.getServer().useRconColors()) {
message = ChatColor.stripColor(message);
}
sendLargeResponse(ctx, requestId, message);
} catch (CommandException e) {
sendLargeResponse(ctx, requestId, String.format("Error executing: %s (%s)", payload, e.getMessage()));
}
}
Aggregations