Java Code Examples for org.bukkit.event.server.ServerCommandEvent#getCommand()

The following examples show how to use org.bukkit.event.server.ServerCommandEvent#getCommand() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Commands.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("null")
@EventHandler(priority = EventPriority.HIGHEST)
public void onServerCommand(final ServerCommandEvent e) {
	if (e.getCommand() == null || e.getCommand().isEmpty())
		return;
	if (SkriptConfig.enableEffectCommands.value() && e.getCommand().startsWith(SkriptConfig.effectCommandToken.value())) {
		if (handleEffectCommand(e.getSender(), e.getCommand())) {
			e.setCancelled(true);
		}
		return;
	}
}
 
Example 2
Source File: BukkitCommandExecutor.java    From LuckPerms with MIT License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onConsoleCommand(ServerCommandEvent e) {
    if (!(e.getSender() instanceof ConsoleCommandSender)) {
        return;
    }

    String buffer = e.getCommand();
    if (buffer.isEmpty() || buffer.charAt(0) != '/') {
        return;
    }

    buffer = buffer.substring(1);

    String commandLabel;
    int firstSpace = buffer.indexOf(' ');
    if (firstSpace == -1) {
        commandLabel = buffer;
    } else {
        commandLabel = buffer.substring(0, firstSpace);
    }

    Command command = CommandMapUtil.getCommandMap(this.plugin.getBootstrap().getServer()).getCommand(commandLabel);
    if (command != this.command) {
        return;
    }

    e.setCommand(buffer);
}
 
Example 3
Source File: TpsPingCmdWarpper.java    From NyaaUtils with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onServerCommandPreProcess(ServerCommandEvent e) {
    String cmd = e.getCommand();
    if (plugin.cfg.tps_enable && plugin.cfg.tps_override && (cmd.startsWith("tps ") || cmd.equals("tps"))) {
        e.setCommand(cmd.replaceAll("^tps", "nu tps"));
    }

    if (plugin.cfg.ping_enable && plugin.cfg.ping_override && (cmd.startsWith("ping ") || cmd.equals("ping"))) {
        e.setCommand(cmd.replaceAll("^ping", "nu ping"));
    }

    if (plugin.cfg.ping_enable && plugin.cfg.ping_override && (cmd.startsWith("pingtop ") || cmd.equals("pingtop"))) {
        e.setCommand(cmd.replaceAll("^pingtop", "nu pingtop"));
    }
}
 
Example 4
Source File: ServerCommandPlaceholder.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onCmd(ServerCommandEvent e) {
    String cmd = e.getCommand();
    String replacement = PlaceholderHandler.replacePlaceholders(e.getSender() instanceof Player ? (Player) e.getSender() : null, cmd);
    if (replacement != null && !cmd.equals(replacement)) {
        e.setCommand(cmd);
    }
}