Console Commands (SimpleCommandMap)?

Discussion in 'Plugin Development' started by mkaltner, Feb 13, 2011.

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

    mkaltner

    Having a hard time finding out how to get my plugin to call other plugin commands.
    I can't find much in the way of documentation on this subject and from the JavaDoc it seems like this is the correct approach however the command I try via the console works, but doesn't when called from my plugin.

    Code:
    SimpleCommandMap map = new SimpleCommandMap(plugin.getServer());
    String cmd = "/command arg";
    if (map.dispatch(new ConsoleCommandSender(), cmd)) {
      // Command worked
    }
    else {
      // Command didn't work
    }
    
    Anyone have any success with this?
    Thanks!
    - Mike
    --- merged: Feb 15, 2011 5:04 AM ---
    For anyone interested, I figured it out by digging through the Bukkit code...

    Code:
    Plugin p = plugin.getServer().getPluginManager().getPlugin("PluginName");
    PluginCommand cmd = new PluginCommand("/command", p);
    if (cmd.execute(new ConsoleCommandSender(), "label", new String[]{"arg1","arg2"})) {
    	// Command succeeded
    }
    else {
    	// Command failed
    }
    
     
Thread Status:
Not open for further replies.

Share This Page