类org.bukkit.command.CommandExecutor源码实例Demo

下面列出了怎么用org.bukkit.command.CommandExecutor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: BukkitDevelopmentNote   文件: StupidLogin.java
public void onEnable() {
	instance = this;
	
	//Configuration
	this.saveDefaultConfig();  //���Ĭ������
	//Listener
	Bukkit.getPluginManager().registerEvents(new PlayerLimitListener(), this);  //ע�������
	Bukkit.getPluginManager().registerEvents(new PlayerLoginCommand(), this);
	Bukkit.getPluginManager().registerEvents(new PlayerTipListener(), this);
	//Commands
	CommandExecutor ce = new PlayerLoginCommand();  //ע��ָ���������ָ���ͬһ��Executor
	Bukkit.getPluginCommand("login").setExecutor(ce);
	Bukkit.getPluginCommand("register").setExecutor(ce);
	
	getLogger().info("StupidLogin���������");
}
 
源代码2 项目: helper   文件: CommandMapUtil.java
/**
 * 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;
}
 
源代码3 项目: CombatLogX   文件: CombatLogX.java
@Override
public void registerCommand(String commandName, CommandExecutor executor, String description, String usage, String... aliases) {
    PluginCommand command = getCommand(commandName);
    if(command == null) {
        forceRegisterCommand(commandName, executor, description, usage, aliases);
        return;
    }
    command.setExecutor(executor);

    if(executor instanceof TabCompleter) {
        TabCompleter completer = (TabCompleter) executor;
        command.setTabCompleter(completer);
    }

    if(executor instanceof Listener) {
        Listener listener = (Listener) executor;
        PluginManager manager = Bukkit.getPluginManager();
        manager.registerEvents(listener, this);
    }
}
 
源代码4 项目: Holograms   文件: HologramCommands.java
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length == 0) {
        sendMenu(sender);
    } else {
        String subCommand = args[0].toLowerCase();
        CommandExecutor subCommandExec = commands.get(subCommand);

        if (subCommandExec == null) {
            sendMenu(sender);
        } else if (!sender.hasPermission("holograms." + subCommand)) {
            sender.sendMessage(ChatColor.RED + command.getPermissionMessage());
        } else {
            return subCommandExec.onCommand(sender, command, label, args);
        }
    }

    return false;
}
 
源代码5 项目: intake   文件: BukkitCommand.java
public BukkitCommand(
    Plugin plugin, CommandExecutor executor, TabCompleter completer, CommandMapping command) {
  super(
      command.getPrimaryAlias(),
      command.getDescription().getShortDescription(),
      "/" + command.getPrimaryAlias() + " " + command.getDescription().getUsage(),
      Lists.newArrayList(command.getAllAliases()));
  this.plugin = plugin;
  this.executor = executor;
  this.completer = completer;
  this.permissions = command.getDescription().getPermissions();
  super.setPermission(Joiner.on(';').join(permissions));
}
 
源代码6 项目: helper   文件: CommandMapUtil.java
/**
 * Registers a CommandExecutor with the server
 *
 * @param plugin the plugin instance
 * @param command the command instance
 * @param permission the command permission
 * @param permissionMessage the message sent when the sender doesn't the required permission
 * @param description the command description
 * @param aliases the command aliases
 * @param <T> the command executor class type
 * @return the command executor
 */
@Nonnull
public static <T extends CommandExecutor> T registerCommand(@Nonnull Plugin plugin, @Nonnull T command, String permission, String permissionMessage, String description, @Nonnull String... aliases) {
    Preconditions.checkArgument(aliases.length != 0, "No aliases");
    for (String alias : aliases) {
        try {
            PluginCommand cmd = COMMAND_CONSTRUCTOR.newInstance(alias, plugin);

            getCommandMap().register(plugin.getDescription().getName(), cmd);
            getKnownCommandMap().put(plugin.getDescription().getName().toLowerCase() + ":" + alias.toLowerCase(), cmd);
            getKnownCommandMap().put(alias.toLowerCase(), cmd);
            cmd.setLabel(alias.toLowerCase());
            if (permission != null) {
               cmd.setPermission(permission);
               if (permissionMessage != null) {
                   cmd.setPermissionMessage(permissionMessage);
               }
            }
            if (description != null) {
                cmd.setDescription(description);
            }

            cmd.setExecutor(command);
            if (command instanceof TabCompleter) {
                cmd.setTabCompleter((TabCompleter) command);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return command;
}
 
源代码7 项目: UhcCore   文件: GameManager.java
private void registerCommand(String commandName, CommandExecutor executor){
	PluginCommand command = UhcCore.getPlugin().getCommand(commandName);
	if (command == null){
		Bukkit.getLogger().warning("[UhcCore] Failed to register " + commandName + " command!");
		return;
	}

	command.setExecutor(executor);
}
 
源代码8 项目: CombatLogX   文件: CombatLogX.java
private void forceRegisterCommand(String commandName, CommandExecutor executor, String description, String usage, String... aliases) {
    if(commandName == null || executor == null || description == null || usage == null || aliases == null) return;

    PluginManager manager = Bukkit.getPluginManager();

    CustomCommand command = new CustomCommand(commandName, executor, description, usage, aliases);
    manager.registerEvents(command, this);

    if(executor instanceof Listener) {
        Listener listener = (Listener) executor;
        manager.registerEvents(listener, this);
    }
}
 
源代码9 项目: helper   文件: ExtendedJavaPlugin.java
@Nonnull
@Override
public <T extends CommandExecutor> T registerCommand(@Nonnull T command, String permission, String permissionMessage, String description, @Nonnull String... aliases) {
    return CommandMapUtil.registerCommand(this, command, permission, permissionMessage, description, aliases);
}
 
源代码10 项目: CombatLogX   文件: CombatLogX.java
private void registerCommand(String commandName, CommandExecutor executor) {
    registerCommand(commandName, executor, null, null);
}
 
源代码11 项目: CombatLogX   文件: CustomCommand.java
public CustomCommand(String command, CommandExecutor executor, String description, String usage, String... aliases) {
    super(command, description, usage, Util.newList(aliases));
    this.executor = executor;
}
 
源代码12 项目: UHC   文件: UHC.java
protected void setupCommand(CommandExecutor executor, String... commands) {
    for (final String command : commands) {
        getCommand(command).setExecutor(executor);
    }
}
 
源代码13 项目: ShopChest   文件: ShopSubCommand.java
public ShopSubCommand(String name, boolean playerCommand, CommandExecutor executor, TabCompleter tabCompleter) {
    this.name = name;
    this.playerCommand = playerCommand;
    this.executor = executor;
    this.tabCompleter = tabCompleter;
}
 
源代码14 项目: helper   文件: HelperPlugin.java
/**
 * Registers a CommandExecutor with the server
 *
 * @param command the command instance
 * @param aliases the command aliases
 * @param <T> the command executor class type
 * @return the command executor
 */
@Nonnull
default <T extends CommandExecutor> T registerCommand(@Nonnull T command, @Nonnull String... aliases) {
    return registerCommand(command, null, null, null, aliases);
}
 
源代码15 项目: helper   文件: HelperPlugin.java
/**
 * Registers a CommandExecutor with the server
 *
 * @param command the command instance
 * @param permission the command permission
 * @param permissionMessage the message sent when the sender doesn't the required permission
 * @param description the command description
 * @param aliases the command aliases
 * @param <T> the command executor class type
 * @return the command executor
 */
@Nonnull
<T extends CommandExecutor> T registerCommand(@Nonnull T command, String permission, String permissionMessage, String description, @Nonnull String... aliases);
 
源代码16 项目: helper   文件: CommandMapUtil.java
/**
 * Registers a CommandExecutor with the server
 *
 * @param plugin the plugin instance
 * @param command the command instance
 * @param aliases the command aliases
 * @param <T> the command executor class type
 * @return the command executor
 */
@Nonnull
public static <T extends CommandExecutor> T registerCommand(@Nonnull Plugin plugin, @Nonnull T command, @Nonnull String... aliases) {
    return registerCommand(plugin, command, null, null, null, aliases);
}
 
源代码17 项目: CombatLogX   文件: ICombatLogX.java
/**
 * Register a command to CombatLogX
 * @param commandName The name of the command
 * @param executor The executor class of the command
 * @param description The description of the command
 * @param usage The usage of the command
 * @param aliases The alias list of the command
 * @see CommandExecutor
 */
void registerCommand(String commandName, CommandExecutor executor, String description, String usage, String... aliases);
 
 类所在包
 同包方法