StellaStella

Stella API

##Stella API

The StellaAPI exposes static methods to interact with Stella from your own plugin — query teams, manage members, edit team properties and check membership, all without creating an instance.

INFO

Players are identified by UUID throughout the API. Use StellaAPI.resolvePlayer(name) to turn a name into a UUID, and StellaAPI.getPlayerName(uuid) for the reverse.


###Installation

Add the JitPack repository and the dependency. Replace the version with the latest published tag.

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.33drygo</groupId>
    <artifactId>Stella</artifactId>
    <version>1.0.0</version>
    <scope>provided</scope>
</dependency>

Then declare Stella as a dependency in your plugin.yml:

name: MyPlugin
main: com.example.MyPlugin
version: 1.0
depend:      # use soft-depend instead if Stella is optional
  - stella

###StellaAPI Methods

All methods are static on dev.drygo.stella.api.StellaAPI.

WARNING

Mutating methods (create/delete/set/add/remove) fire Bukkit events and must be called from the main thread. The player-team events are cancellable, so a mutation can return false if a listener cancels it.

Team queries
  • ####Team getTeam(String id)

    Returns a team by its id, or null if it doesn't exist.
Team red = StellaAPI.getTeam("red");
  • ####boolean teamExists(String id)

    Whether a team with that id exists.

  • ####List<Team> getTeams()

    Every registered team.

  • ####List<String> getTeamIds()

    The ids of every registered team.

Player queries
  • ####Team getMainTeam(UUID player)

    The player's highest-priority team, or null if they're in none.
Team main = StellaAPI.getMainTeam(player.getUniqueId());
  • ####List<Team> getPlayerTeams(UUID player)

    Every team the player belongs to, highest priority first.

  • ####boolean isInTeam(UUID player, String teamId)

    Whether the player is a member of a specific team.

  • ####boolean isInAnyTeam(UUID player)

    Whether the player belongs to at least one team.

  • ####UUID resolvePlayer(String name)

    Resolves a name to a UUID (online, cached, or known offline), or null.

  • ####String getPlayerName(UUID player)

    The last known name for a UUID, or null.

Team mutations
  • ####Team createTeam(String id, int priority)

    Creates a team and returns it. Returns null if the id is invalid or already in use. Fires TeamCreateEvent.
Team team = StellaAPI.createTeam("red", 10);
  • ####boolean deleteTeam(String id)

    Deletes a team. Returns false if it didn't exist. Fires TeamDeleteEvent.

  • ####boolean setColor(String teamId, String color)

    Sets the team's hex color (#RRGGBB). Returns false if the team is unknown.

  • ####boolean setDisplayName(String teamId, String displayName)

    Sets the team's display name.

  • ####boolean setPriority(String teamId, int priority)

    Sets the team's priority.

Membership mutations
  • ####boolean addMember(String teamId, UUID player)

    Adds a player to a team. Returns false if the team/player is invalid, the player is already a member, or a listener cancelled PlayerJoinTeamEvent.
StellaAPI.addMember("red", player.getUniqueId());
  • ####boolean removeMember(String teamId, UUID player)

    Removes a player from a team. Returns false if the team/player is invalid, the player isn't a member, or a listener cancelled PlayerLeaveTeamEvent.

###Team Model

The dev.drygo.stella.team.Team object exposes:

Method Returns Notes
getId() String The team id (always lowercase).
getDisplayName() String The display name. May contain color codes.
getColor() String Hex color, e.g. #FF5555.
getPriority() int Higher = more important.
getMembers() Set<UUID> Member UUIDs.

Prefer the StellaAPI mutators (setColor, addMember, …) over the Team setters — they persist to teams.yml, fire events and refresh hooks. Mutating the Team directly does none of that.


###Stella Events

All events live in dev.drygo.stella.api.event and are handled with normal Bukkit listeners.

Click to expand
  • ####PlayerJoinTeamEvent

    Cancellable. Fired before a player is added to a team.
@EventHandler
public void onJoin(PlayerJoinTeamEvent event) {
    UUID player = event.getPlayer();
    Team team = event.getTeam();
    // event.setCancelled(true); // to veto the membership
}
  • ####PlayerLeaveTeamEvent

    Cancellable. Fired before a player is removed from a team.
@EventHandler
public void onLeave(PlayerLeaveTeamEvent event) {
    UUID player = event.getPlayer();
    Team team = event.getTeam();
}
  • ####TeamCreateEvent

    Fired after a team is created. Not cancellable.
@EventHandler
public void onCreate(TeamCreateEvent event) {
    Bukkit.getLogger().info("Team created: " + event.getTeam().getId());
}
  • ####TeamDeleteEvent

    Fired after a team is deleted. Not cancellable. The Team snapshot is still readable.
@EventHandler
public void onDelete(TeamDeleteEvent event) {
    Bukkit.getLogger().info("Team deleted: " + event.getTeam().getId());
}

###Notes

  • All StellaAPI methods are static — no instantiation needed.
  • Mutations persist to teams.yml automatically and refresh the LuckPerms / Minecraft team hooks.
  • getMainTeam / getPlayerTeams resolve order by priority (highest first); make priorities unique if exact ordering matters.
  • The player-team events fire before the change is applied and can be cancelled; the team create/delete events fire after and cannot.

###References