Skip to content

Team arguments

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

Example - Toggling friendly fire in 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

mccmd
/togglepvp <team>

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

java
new CommandAPICommand("togglepvp")
    .withArguments(new TeamArgument("team"))
    .executes((sender, args) -> {
        Team team = (Team) args.get("team");

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