Player.performCommand

Discussion in 'Plugin Development' started by Jerry Larsson, Feb 15, 2011.

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

    Jerry Larsson

    Hi!

    I thought I could use Player.performCommand to run a command like when the player enters a command in the chat window. For ex. /money.

    So I tried to use Player.performCommand("/money"); but nothing happened in the game.

    Am I missing something here?
     
  2. Offline

    retsrif

    Yes. In your file with your onEnable method, you should let the pluginmanager listen for a PLAYER_CHAT event. In your player listener, you have to create a method that goes something like this:
    Code:
    public void onPlayerCommand(PlayerChatEvent event) {
       String[] split = event.getMessage().split(" ");
    
       if((split[0].equalsIgnoreCase("/money")) {
       //Whatever you want to do here
       }
    }
     
  3. Offline

    Jerry Larsson

    I don't think you understood me. I want to run a command that already exists that's not part of my plugin at all.
    For ex. when a player runs one of my commands /test I want it to run another command automatically, like /money deposit testuser 100 or maybe /region define testarea testuser.

    :)
     
  4. Offline

    yottabyte

    I have no idea if I know what I'm talking about but I think what you want to do is create a new event eg.
    Code:
    new PlayerChatEvent(player, "/money")
    Will look at it when my Eclipse download finishes on this mobile network :d
     
Thread Status:
Not open for further replies.

Share This Page