.isAssignableFrom(((PluginCommand) command).getExecutor().getClass())) { HelpTopic t = entry.getValue().createTopic(command); if (t != null) {
private Command registerCommand(String name) { PluginCommand command = plugin.getCommand(name); if (command.getExecutor() != this) { command.setExecutor(this); } return command; }
public static FreedomCommand getFrom(Command command) { try { return (FreedomCommand) ((FreedomCommandExecutor) (((PluginCommand) command).getExecutor())).getCommandBase(); } catch (Exception ex) { return null; } } }
@Override public MCPlugin getExecutor() { // TODO Not all plugins execute commands in their main class, so this cast won't always work if(!(cmd instanceof PluginCommand)) { return null; } return new BukkitMCPlugin((Plugin) ((PluginCommand) cmd).getExecutor()); }
/** * Unregisters a CommandExecutor with the server * * @param command the command instance * @param <T> the command executor class type * @return the command executor */ @Nonnull public static <T extends CommandExecutor> T unregisterCommand(@Nonnull T command) { CommandMap map = getCommandMap(); try { //noinspection unchecked Map<String, Command> knownCommands = (Map<String, Command>) KNOWN_COMMANDS_FIELD.get(map); Iterator<Command> iterator = knownCommands.values().iterator(); while (iterator.hasNext()) { Command cmd = iterator.next(); if (cmd instanceof PluginCommand) { CommandExecutor executor = ((PluginCommand) cmd).getExecutor(); if (command == executor) { cmd.unregister(map); iterator.remove(); } } } } catch (Exception e) { throw new RuntimeException("Could not unregister command", e); } return command; }
/** * Unregisters a CommandExecutor with the server * * @param command the command instance * @param <T> the command executor class type * @return the command executor */ @Nonnull public static <T extends CommandExecutor> T unregisterCommand(@Nonnull T command) { CommandMap map = getCommandMap(); try { //noinspection unchecked Map<String, Command> knownCommands = (Map<String, Command>) KNOWN_COMMANDS_FIELD.get(map); Iterator<Command> iterator = knownCommands.values().iterator(); while (iterator.hasNext()) { Command cmd = iterator.next(); if (cmd instanceof PluginCommand) { CommandExecutor executor = ((PluginCommand) cmd).getExecutor(); if (command == executor) { cmd.unregister(map); iterator.remove(); } } } } catch (Exception e) { throw new RuntimeException("Could not unregister command", e); } return command; }