How do I make commands in a java game?
<p>Basically I want to make it so when the user types into the textfield /attack animal it does the attack method and takes animal as a parameter. So if player typed /attack foo it do player.attack(foo). I already have methods that perform chat so I know which player is doing the chat. I just need to know how to reconize what comes after the /attack and take it as a parameter for player.attack() which takes a Player object as an argument. These are my methods that receive input:</p>

<pre><code>public void actionPerformed(ActionEvent textBox) {
        String text = textField.getText();
        player.chat(text);
}
</code></pre>

<p>Which is in my Gui class, and:</p>

<pre><code>public void chat(String chat){
    playerGui.printText(this.getName() + ": " + chat);
    playerGui.textField.selectAll();
}
</code></pre>

<p>Which is in the player class. A gui instance is passed to Player() which creates the variable playerGui.</p>
