Class GameEndEvent

java.lang.Object
com.ohacd.matchbox.api.MatchboxEvent
com.ohacd.matchbox.api.events.GameEndEvent

public class GameEndEvent extends MatchboxEvent
Event fired when a game ends (either by win condition or manual termination).
Since:
0.9.5
  • Constructor Details

    • GameEndEvent

      public GameEndEvent(@NotNull @NotNull String sessionName, @NotNull @NotNull GameEndEvent.EndReason reason, @NotNull @NotNull Collection<org.bukkit.entity.Player> remainingPlayers, @NotNull @NotNull Map<org.bukkit.entity.Player,com.ohacd.matchbox.game.utils.Role> finalRoles, int totalRounds)
      Creates a new game end event.
      Parameters:
      sessionName - session name
      reason - reason for game ending
      remainingPlayers - players still in the game when it ended
      finalRoles - mapping of players to their final roles
      totalRounds - total number of rounds played
  • Method Details

    • dispatch

      public void dispatch(@NotNull @NotNull MatchboxEventListener listener)
      Description copied from class: MatchboxEvent
      Dispatches this event to the appropriate listener method.

      This method uses the visitor pattern to call the correct handler method based on the concrete event type. Implementing classes should call super.dispatch(listener) as the first line.

      Specified by:
      dispatch in class MatchboxEvent
      Parameters:
      listener - the listener to dispatch to
    • getSessionName

      @NotNull public @NotNull String getSessionName()
      Gets the name of the session that ended.
      Returns:
      the session name
    • getReason

      @NotNull public @NotNull GameEndEvent.EndReason getReason()
      Gets the reason why the game ended.
      Returns:
      the end reason
    • getRemainingPlayers

      @NotNull public @NotNull Collection<org.bukkit.entity.Player> getRemainingPlayers()
      Gets all players still in the game when it ended.
      Returns:
      collection of remaining players
    • getFinalRoles

      @NotNull public @NotNull Map<org.bukkit.entity.Player,com.ohacd.matchbox.game.utils.Role> getFinalRoles()
      Gets the final roles of all players who participated.
      Returns:
      mapping of players to their final roles
    • getTotalRounds

      public int getTotalRounds()
      Gets the total number of rounds played.
      Returns:
      total rounds