Interface CustomGameService
public interface CustomGameService
Player-hosted custom games: listing, joining and moderating them.
Hosts draft and publish games through the custom games menu, when their perk tier allows
Perk.CUSTOM_GAMES_CREATE (since 1.10.0); this service exposes the
published games and the same join, cancel and terminate operations the menus use, so an addon
can build its own listings or moderation tools. Each change of state fires
CustomGameStateChangeEvent; a successful
publication fires CustomGamePublishEvent.
Every method must be called on the main thread. Returned games are snapshots.
- Since:
- 1.8.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe outcome of a join request. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCalls off a game that has not started, as an administrator would: its waiting players are told and returned to the lobby, and its arena is released.@NotNull List<CustomGameInfo> Every game that is not over yet - upcoming or running - in no particular order.@NotNull Optional<CustomGameInfo> getGame(@NotNull ZentrixGame runtime) The custom game a runtime lobby or match belongs to, if it is one.@NotNull Optional<CustomGameInfo> The game with this ID, while it is not over.@NotNull List<CustomGameInfo> getGamesHostedBy(@NotNull UUID hostId) The games a player hosts that are not over yet.@NotNull List<CustomGameInfo> Every published game that has not started yet, soonest first.booleanWhether custom games are enabled on this server.@NotNull CustomGameService.JoinResultjoin(@NotNull org.bukkit.entity.Player player, @NotNull UUID customGameId, @Nullable String password) Puts a player - or, for a party leader, their whole party - into one specific custom game, exactly as choosing it in the custom games menu would.booleanEnds a running custom game's match, as an administrator would.
-
Method Details
-
isEnabled
boolean isEnabled()Whether custom games are enabled on this server. -
getUpcomingGames
Every published game that has not started yet, soonest first. -
getActiveGames
Every game that is not over yet - upcoming or running - in no particular order. -
getGame
The game with this ID, while it is not over. -
getGamesHostedBy
The games a player hosts that are not over yet. -
getGame
The custom game a runtime lobby or match belongs to, if it is one. -
join
@NotNull @NotNull CustomGameService.JoinResult join(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull UUID customGameId, @Nullable @Nullable String password) Puts a player - or, for a party leader, their whole party - into one specific custom game, exactly as choosing it in the custom games menu would.A password-protected game requires its password unless the player is its host; it is checked here, so pass what the player typed. Main thread only.
- Parameters:
password- the password the player gave, or null when they gave none- Returns:
- the outcome;
CustomGameService.JoinResult.JOININGmeans the join was accepted and is underway
-
cancel
Calls off a game that has not started, as an administrator would: its waiting players are told and returned to the lobby, and its arena is released.- Returns:
- whether the game was called off
-
terminate
Ends a running custom game's match, as an administrator would. No winner is declared and no reward is paid.- Returns:
- whether the match was ended
-