Class TeamEliminatedEvent
This event is fired when all members of a team have been eliminated (killed or left the game). At this point:
- All team members have been eliminated
- The team is marked as eliminated
- Remaining teams count has been updated
- Win condition may be checked next
This event is NOT cancellable.
Example Usage
@EventHandler
public void onTeamEliminated(TeamEliminatedEvent event) {
ZentrixTeam team = event.getTeam();
ZentrixGame game = event.getGame();
// Announce team elimination
game.broadcast("&c" + team.getDisplayName() + " has been eliminated!");
// Check remaining teams
int remaining = event.getRemainingTeamCount();
game.broadcast("&7" + remaining + " teams remain!");
// Check if this triggers a win
if (event.triggersWin()) {
event.getWinningTeam().ifPresent(winner -> {
game.broadcast("&6" + winner.getDisplayName() + " wins!");
});
}
// Get the player who caused the final elimination
event.getFinalKiller().ifPresent(killer -> {
getLogger().info(killer.getName() + " got the final kill on " +
team.getDisplayName());
});
}
- Since:
- 1.0.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionTeamEliminatedEvent(@NotNull ZentrixGame game, @NotNull ZentrixTeam team, @NotNull ZentrixPlayer lastMemberEliminated, @Nullable ZentrixPlayer finalKiller, @NotNull Collection<ZentrixPlayer> teamMembers, int placement, int remainingTeamCount) Constructs a new TeamEliminatedEvent. -
Method Summary
Modifier and TypeMethodDescription@NotNull Optional<ZentrixPlayer> Gets the player who killed the last team member.static @NotNull org.bukkit.event.HandlerListGets the static handler list for this event type.@NotNull org.bukkit.event.HandlerListGets the handler list for this event.@NotNull ZentrixPlayerGets the last member of the team to be eliminated.intGets the team's final placement.@NotNull StringGets the placement as an ordinal string.intGets the number of teams still alive after this elimination.@NotNull ZentrixTeamgetTeam()Gets the team that was eliminated.@NotNull StringGets the team's display name.@NotNull StringGets the team's ID.intGets the number of members that were on this team.@NotNull Collection<ZentrixPlayer> Gets all members who were on this team.intGets the team's number.@NotNull Optional<ZentrixPlayer> Gets the member with the most kills on this team.intGets the total kills achieved by this team during the game.@NotNull Optional<ZentrixTeam> Gets the winning team if this elimination triggers a win.booleanChecks if there was a killer for the final team member.booleanChecks if this elimination triggers a win condition.booleanChecks if this was the last team to be eliminated before the winner.Methods inherited from class dev.itsharshxd.zentrix.api.events.ZentrixGameEvent
getArenaName, getGame, getGameId, getGameState, getGameTypeName, getPlayerCountMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
TeamEliminatedEvent
public TeamEliminatedEvent(@NotNull @NotNull ZentrixGame game, @NotNull @NotNull ZentrixTeam team, @NotNull @NotNull ZentrixPlayer lastMemberEliminated, @Nullable @Nullable ZentrixPlayer finalKiller, @NotNull @NotNull Collection<ZentrixPlayer> teamMembers, int placement, int remainingTeamCount) Constructs a new TeamEliminatedEvent.- Parameters:
game- The game where the elimination occurredteam- The team that was eliminatedlastMemberEliminated- The last member of the team to be eliminatedfinalKiller- The player who killed the last team member (null if environmental)teamMembers- All members who were on this teamplacement- The team's final placement (e.g., 5th place = 5)remainingTeamCount- The number of teams still alive after this elimination
-
-
Method Details
-
getTeam
Gets the team that was eliminated.- Returns:
- The eliminated team (never null)
-
getTeamDisplayName
Gets the team's display name.Convenience method equivalent to
getTeam().getDisplayName().- Returns:
- The team's display name (never null)
-
getTeamId
Gets the team's ID.Convenience method equivalent to
getTeam().getTeamId().- Returns:
- The team ID (never null)
-
getTeamNumber
public int getTeamNumber()Gets the team's number.Convenience method equivalent to
getTeam().getTeamNumber().- Returns:
- The team number
-
getLastMemberEliminated
Gets the last member of the team to be eliminated.This is the player whose death triggered the team elimination.
- Returns:
- The last eliminated member (never null)
-
getFinalKiller
Gets the player who killed the last team member.Returns empty if the last member died to environmental damage.
- Returns:
- Optional containing the killer, or empty if environmental death
-
hasFinalKiller
public boolean hasFinalKiller()Checks if there was a killer for the final team member.- Returns:
trueif the last member was killed by another player
-
getTeamMembers
Gets all members who were on this team.This includes all players who were assigned to this team during the game, regardless of when they were eliminated.
- Returns:
- An unmodifiable collection of team members (never null)
-
getTeamMemberCount
public int getTeamMemberCount()Gets the number of members that were on this team.- Returns:
- The team member count
-
getPlacement
public int getPlacement()Gets the team's final placement.This is calculated based on when the team was eliminated relative to others. A placement of 1 means the team won, 2 means second place, etc.
- Returns:
- The placement (1-indexed, higher is worse)
-
getPlacementOrdinal
Gets the placement as an ordinal string.Examples: "1st", "2nd", "3rd", "4th", etc.
- Returns:
- The ordinal placement string (never null)
-
getRemainingTeamCount
public int getRemainingTeamCount()Gets the number of teams still alive after this elimination.- Returns:
- Remaining team count
-
triggersWin
public boolean triggersWin()Checks if this elimination triggers a win condition.Returns true if only one team remains after this elimination.
- Returns:
trueif this elimination results in a winner
-
getWinningTeam
Gets the winning team if this elimination triggers a win.Returns empty if there is no winner yet (more than one team remains).
- Returns:
- Optional containing the winning team, or empty if no winner yet
-
getTotalTeamKills
public int getTotalTeamKills()Gets the total kills achieved by this team during the game.- Returns:
- Total team kills
-
getTopKiller
Gets the member with the most kills on this team.- Returns:
- Optional containing the top killer, or empty if no kills
-
wasRunnerUp
public boolean wasRunnerUp()Checks if this was the last team to be eliminated before the winner.Returns true if this team got second place (placement == 2).
- Returns:
trueif this team got second place
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()Gets the handler list for this event.- Overrides:
getHandlersin classZentrixGameEvent- Returns:
- The handler list
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()Gets the static handler list for this event type.- Returns:
- The handler list
-