Team arguments

The TeamArgument class interacts with the Minecraft scoreboard and represents a team.

Example - Toggling friendly fire in a team

Let's say we want to create a command to toggle the state of friendly fire in a team. We want a command of the following form

/togglepvp <team>

To do this, given a team we want to use the setAllowFriendlyFire(boolean) function.

new CommandAPICommand("togglepvp")
    .withArguments(new TeamArgument("team"))
    .executes((sender, args) -> {
        Team team = (Team) args.get(0);
        
        // Toggle pvp
        team.setAllowFriendlyFire(team.allowFriendlyFire());
    })
    .register();
CommandAPICommand("togglepvp")
    .withArguments(TeamArgument("team"))
    .executes(CommandExecutor { _, args ->
        val team = args[0] as Team

        // Toggle pvp
        team.setAllowFriendlyFire(team.allowFriendlyFire())
    })
    .register()
commandAPICommand("togglepvp") {
    teamArgument("team")
    anyExecutor { _, args ->
        val team = args[0] as Team

        // Toggle pvp
        team.setAllowFriendlyFire(team.allowFriendlyFire())
    }
}