31.05.2015, 08:24
@dusk:
You can choose yourself, if your command should be case sensitive or not, and you can also set it's priority. Sadly, you can't use java keywords as command names such as "goto". You just need to add some parameters to the @Command Annotation like this:
Function Parameters can be everything, but you need to make sure that shoebill knows how to handle the text that the user inputs. You can add your own "Type-Parser" in your CommandManager instance like this:
You can do that with all classes, even your custom ones, but you need to provide a way for shoebill to get a object from the user's inputed text. I will give you one more example:
Already existing types are:
- String
- int & Integer
- short & Short
- byte & Byte
- char & Character
- float & Float
- double & Double
- Boolean
- Player
- Color
but you can also overwrite them yourself, if you are not happy with it's behavior.
You can choose yourself, if your command should be case sensitive or not, and you can also set it's priority. Sadly, you can't use java keywords as command names such as "goto". You just need to add some parameters to the @Command Annotation like this:
Код:
@Command(priority = 1, caseSensitive = true)
public boolean test(Player player) {
player.sendMessage(Color.RED, "Hello! from case sensitive test-command with priority 1");
return true;
}
Код:
commandManager.replaceTypeParser(Player.class, s -> {
return Player.getByPartOfName(s);
});
Код:
commandManager.replaceTypeParser(House.class, s -> {
return House.findById(Integer.parseInt(s));
});
//A sample command
@Command
public boolean edithouse(Player player, House house) {
if(house == null) {
player.sendMessage(Color.RED, "* Invalid house id!");
return true;
}
//Access house instance like everything in java ;)
return true;
}
- String
- int & Integer
- short & Short
- byte & Byte
- char & Character
- float & Float
- double & Double
- Boolean
- Player
- Color
but you can also overwrite them yourself, if you are not happy with it's behavior.

