Package com.ohacd.matchbox.api.events
Class GameEndEvent
java.lang.Object
com.ohacd.matchbox.api.MatchboxEvent
com.ohacd.matchbox.api.events.GameEndEvent
Event fired when a game ends (either by win condition or manual termination).
- Since:
- 0.9.5
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionGameEndEvent(@NotNull String sessionName, @NotNull GameEndEvent.EndReason reason, @NotNull Collection<org.bukkit.entity.Player> remainingPlayers, @NotNull Map<org.bukkit.entity.Player, com.ohacd.matchbox.game.utils.Role> finalRoles, int totalRounds) Creates a new game end event. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispatch(@NotNull MatchboxEventListener listener) Dispatches this event to the appropriate listener method.@NotNull Map<org.bukkit.entity.Player, com.ohacd.matchbox.game.utils.Role> Gets the final roles of all players who participated.@NotNull GameEndEvent.EndReasonGets the reason why the game ended.@NotNull Collection<org.bukkit.entity.Player> Gets all players still in the game when it ended.@NotNull StringGets the name of the session that ended.intGets the total number of rounds played.Methods inherited from class com.ohacd.matchbox.api.MatchboxEvent
getTimestamp, toString
-
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 namereason- reason for game endingremainingPlayers- players still in the game when it endedfinalRoles- mapping of players to their final rolestotalRounds- total number of rounds played
-
-
Method Details
-
dispatch
Description copied from class:MatchboxEventDispatches 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:
dispatchin classMatchboxEvent- Parameters:
listener- the listener to dispatch to
-
getSessionName
Gets the name of the session that ended.- Returns:
- the session name
-
getReason
Gets the reason why the game ended.- Returns:
- the end reason
-
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
-