Listening to the Events

You can find all the available events here: https://github.com/xF3d33/UltimateTeams/tree/main/src/main/java/dev/xf3d3/ultimateteams/api/events

TeamPreCreateEvent

In this example we will listen to the TeamPreCreateEvent, and cancel the creation of the team if the name equals "cat".

import dev.xf3d3.ultimateteams.api.UltimateTeamsAPI;
import dev.xf3d3.ultimateteams.api.events.TeamPreCreateEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

public class UltimateTeamsHook implements Listener {
    private final UltimateTeamsAPI teamsAPI;

    public UltimateTeamsHook() {
        this.teamsAPI = UltimateTeamsAPI.getInstance();
    }

    @EventHandler
    public void onTeamPreCreate(TeamPreCreateEvent event) {
        String teamName = event.getName();
        Player teamCreator = event.getUser();
        
        if (teamName.equalsIgnoreCase("cat")) {
            event.setCancelled(true);
            
            teamCreator.sendMessage("The team creation has been cancelled because you are using a banned name");
        }
    }
}

You can also modify the team name by listening to this event:

If the event is not cancelled, the team creation will proceed and you will be able to access the newly created Team with the TeamCreateEvent.

TeamCreateEvent

Let's say you just modified the team name like the code above:

TeamWarpSetEvent

Let's see how to send a message to all team members containing the coordinates of a Warp that the team owner has just created:

The coordinates are a double, so to avoid long decimal values remember to format it.

Last updated