Read server console input

Discussion in 'Plugin Development' started by Meldanor, Apr 2, 2011.

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

    Meldanor

    Hi guys,

    I'm looking for a way to use a command of my plugin from the server console, so the admin can call the command by not logging in and joining the server, but tipping it in the server console.
    Is there another way for this instead of starting a thread which read the System.in stream? Like a class created by bukkit?

    Thanks for help.

    Mel
     
  2. Offline

    Plague

    If you mean that you want a plugin to receive commands from the console instead only from the game, that's how it works by default.
     
  3. Offline

    Meldanor

    How do you mean it? When it is handeld by "ServerCommand" I can't have a method to read the command text.
    Sry, when I don't see the goal, but I don't have a clear idea ^^
     
  4. Offline

    gnftoxic

    The "onCommand" in your projects' main file handles both console commands and player commands.
     
  5. Offline

    Meldanor

    I'm sry, but I tried this out and it didn't work.

    Code:
        @Override
        public boolean onCommand (CommandSender sender, Command command, String label, String[] args) {
            super.onCommand(sender, command, label, args);
            System.out.println("TEST");
            return true;
        }
    When I use the command "help" or other command, I can't read an output in my console nor anywhere.
     
  6. Offline

    Plague

    Do we misunderstand each other?
    if you use a command on the console (assuming you have registered it) it arrives in your plugin the same way an in-game command does.

    Do you want to read something else than commands from the console?
     
  7. Offline

    Meldanor

    Okay, I hope, I will explain this cleary enough ^^:

    I'm working on my backup plugin and I want to implement that the admin can write in the console "backup" and the backup is made.
    What I want is a way to handle the console input like it is handeled when the admin wrote "help" or "time" or something else.
    I'm very sorry for the missunderstandings.

    Mel
     
  8. Offline

    Plague

    Okay, so you want to write "backup" to the console to make your plugin do something
    And we keep telling you that that's how it works by default because it doesn't matter if you write "backup" into console or "/backup" in the game. If you register "backup" command in plugin.yml, you will get it in onCommand whether it is from game or from console.
     
  9. Offline

    Meldanor

    Oh I'm sry for this, I am ashamend of this solution. But thanks to you, I know now how it works.
     
Thread Status:
Not open for further replies.

Share This Page