Intercepting a command from another plugin

Discussion in 'Plugin Development' started by thefiscster510, Jan 11, 2013.

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

    thefiscster510

    Hey, I was wondering if someone could tell me how i can intercept a command from another plugin. The command being sent, i want to only be allowed in a certain world.. My server that I'm working with doesn't like permissions plugins that do that.. So, I need to make a plugin that will do it..

    Solutions I'd rather not use
    • A permissions plugin like PermissionsEx or GroupManager (That includes default Bukkit permissions)
    • Any other plugin (I want this to be pure. I just want code to intercept a command, check if the sender is in a world, if not then cancel the command and send the user a message)
    Things you should know
    • The server I'm working with is a Beta 1.7.3 server and I'd prefer the code to be. I'm okay with newer API code, but I will have to convert it.. So, If possible, Please try to give me code that will work with older API's
    Thank you in advance for any help you can be, I'm very appreciative.
     
  2. Offline

    gomeow

    PlayerCommandPreprocessEvent

    command = event.getMessage()

    If you want, I have code to parse the label and the args
     
  3. Offline

    ZeusAllMighty11

    PlayerCommandPreprocessEvent ?


    Edit: Ninja'd by gomeow:p
     
  4. Offline

    thefiscster510

    That would be nice. And I can cancel the command from being sent correct..?
     
  5. Offline

    gomeow

  6. Offline

    thefiscster510

    See, I thought to use playerCommandPreprocessEvent originally.. But i thought that that wouldn't cancel the other plugin from processing the command..
     
  7. Offline

    gomeow

    Code:java
    1. String rawMessage = event.getMessage();
    2. String label = rawMessage.substring(1).split(" ", 1);
    3. String[] args = rawMessage().substring(label.size()+1).split(" ");
     
  8. Offline

    thefiscster510

    Okay, Now PlayerCommandPreprocess doesn't register right in mc 1.7.3...

    I have

    Code:
    import org.bukkit.ChatColor;
    import org.bukkit.event.player.PlayerCommandPreprocessEvent;
    import org.bukkit.event.player.PlayerListener;
     
    public class Filter extends PlayerListener{
        @Override
        public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e){
        system.out.println("test");
        e.setCancelled(true);
    }
     
    }
    and then

    in my onEnable() i have

    Code:
    getServer().getPluginManager().registerEvent(Type.PLAYER_COMMAND_PREPROCESS, new Filter(), Priority.High, this);
    And it does absolutely nothing..
     
  9. Offline

    gomeow

    To register: put this instead in your onEnable:

    getServer().getPluginManager().registerEvents(this, this);
     
  10. Offline

    thefiscster510

    I'm using a 1.7.3 api...
     
  11. Offline

    wiigor

    Just curious, Why are you using such an old api?
     
  12. Offline

    thefiscster510

    It was for a nastolgic server.
     
Thread Status:
Not open for further replies.

Share This Page