Run a console command in a plugin?

Discussion in 'Plugin Development' started by Tauryuu, Jan 7, 2012.

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


    I couldn't find anything about running a command as console through a plugin. Is there an easy way to do it?

    Thanks in advance. :)
  2. Offline


    getSever().dispatchCommand(getServer().getConsoleSender, "command goes here");
    htmlman1, hammale and tomjw64 like this.
  3. Offline


    Oh, that's quicker! I've been using PluginCommand to execute commands up until now. Thanks for the quicker and better way of doing that, Technius!
  4. I know, this thread is old, and I hope that you will read this:

    I wanna use this console command too, and how I can make, that in the command, theres the Playername of the player, who sent the command. Example:

            if (sender instanceof Player)  {
                Player player = (Player) sender;
                if(cmd.getName().equalsIgnoreCase ("IReadTheRules"))  {
                    if(args.length == 0) {
                        getServer().dispatchCommand(getServer().getConsoleSender(), "permissions player addgroup [B](sender)[/B] user");
    And at (sender) it writes the name of the player

  5. Basic Java string formatting:
    "permissions player addgroup " + sender.getName() + " user"

    Still, I don't think you need to use a command to do that, hook the permissions plugin and use their interface.
    black_ixx likes this.
  6. Offline


    getServer().dispatchCommand(getServer().getConsoleSender(), "permissions player addgroup " + player.getName() + " user");
    black_ixx likes this.
  7. I have it, thanks to both of you
  8. Offline

    I am trying to run this as a script when I do I get an error that says "getServer is not defined"
  9. Offline


    Use Bukkit.getServer().
  10. Offline


    "Bukkit" is not defined.
  11. Offline


    Then import it!

    (You are using an IDE, right? In Eclipse, hit Ctrl-1 on the line where you have the error, and choose to import org.bukkit.Bukkit. I'm sure NetBeans & Intellij have similar functionality).
  12. Offline


    Lol I have the smallest working knowledge of java. I am not making a plugin, I am simply trying to run a script within a plugin that someone else made. This script is written in notepad++ (>.<)

    Where have I seen your profile pic from!?
  13. Offline


    Not sure what you mean by "script". Java isn't a scripting language as such.

    Read Terry Pratchett at all?
  14. Offline


Thread Status:
Not open for further replies.

Share This Page