FANDOM


Die WeaponState Variable enthält den Zustand einer angegebenen Waffe.

Funktion:

Funktion Returntype
.getWeaponState() WeaponState
.getWeaponState(int slot) WeaponState


Beispiel:

public void onPlayerCommand(PlayerCommandEvent event) {
    String command = event.getCommand();
    String[] splits = command.split(" ", 2);
    String operation = splits[0].toLowerCase();
    Queue<String> args = new LinkedList<>();
    if (splits.length > 1) {
        String[] argsArray = splits[1].split(" ");
        args.addAll(Arrays.asList(argsArray));
    }
    if(operation.equals("/getweaponstate")) {
        WeaponState state = player.getWeaponState();
        switch (state) {
            case UNKNOWN:
                player.sendMessage(Color.RED, "* Unbekannter Zustand");
                break;
            case NO_BULLETS:
                player.sendMessage(Color.RED, "* Keine Munition");
                break;
            case RELOADING:
                player.sendMessage(Color.GREEN, "* Am nachladen");
                break;
            case MORE_BULLETS:
                player.sendMessage(Color.GREEN, "* Kugeln vorhanden");
                break;
            case LAST_BULLET:
                player.sendMessage(Color.GREEN, "* Letzte Kugel!");
                break;
        }
        event.setProcessed();
        return;
    }
}