Search in sources :

Example 1 with RemoteServerCommandEvent

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()));
    }
}
Also used : RemoteServerCommandEvent(org.bukkit.event.server.RemoteServerCommandEvent) CommandException(org.bukkit.command.CommandException)

Aggregations

CommandException (org.bukkit.command.CommandException)1 RemoteServerCommandEvent (org.bukkit.event.server.RemoteServerCommandEvent)1