Overriding /plugins

Discussion in 'Plugin Development' started by HotelManager24, Nov 25, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    HotelManager24

    Anybody know how to override the command /plugins?

    I tried doing this:
    Code:
    this.getCommand("plugins").setExecutor(new CommandExecutor() {
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (cmd.getName().toLowerCase().equals("plugins")) {
    sender.sendMessage(ChatColor.RED + "You may not look at our plugins.");
    return true;
    }
    return false;
    }
    });
    But Bukkit just denies it and gives me the list of plugins.
     
  2. Offline

    Pandemoneus

    You will rather need a player listener with onCommandPreprocess to catch that.
     
  3. Offline

    HotelManager24

    Would you mind showing me an example? I'm a bit new to Java.
     
  4. Offline

    Pandemoneus

  5. Offline

    HotelManager24

    Ok, so it would be like this?
    Code:
    public void onCommandPreprocess(PlayerChatEvent event) {
    String player1 = event.getPlayer().getDisplayName();
    String msg = event.getMessage();
    if (msg.equalsIgnoreCase("plugins")){
    event.setCancelled(true);
    Player thePlayer = Bukkit.getServer().getPlayer(player1);
    thePlayer.sendMessage(ChatColor.RED + "You may not look at our plugins.");
    }
    };
    I'm getting an eclipse error on:
    Code:
    public void onCommandPreprocess(PlayerChatEvent event) {
    The error being:
    "Void is an invalid type for the variable onCommandPreprocess." So what should I be doing?
     
  6. Offline

    Darkman2412

    Change it to: onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
     
  7. Offline

    Daniel Heppner

    A few things: you don't need this. there. Just do getCommand().
    Also, what everyone else said.
     
  8. Offline

    Darkman2412

    You can't use onCommand(), plugins is a builtin command.
     
  9. Offline

    Daniel Heppner

    I know, I'm just letting him know he doesn't need to use this. everywhere.
     
    Darkman2412 likes this.
Thread Status:
Not open for further replies.

Share This Page