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 Classes
    Modifier and Type
    Interface
    Description
    static enum 
    The outcome of a join request.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    cancel(@NotNull UUID customGameId)
    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.
    Every game that is not over yet - upcoming or running - in no particular order.
    getGame(@NotNull ZentrixGame runtime)
    The custom game a runtime lobby or match belongs to, if it is one.
    getGame(@NotNull UUID customGameId)
    The game with this ID, while it is not over.
    getGamesHostedBy(@NotNull UUID hostId)
    The games a player hosts that are not over yet.
    Every published game that has not started yet, soonest first.
    boolean
    Whether custom games are enabled on this server.
    join(@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.
    boolean
    terminate(@NotNull UUID customGameId)
    Ends a running custom game's match, as an administrator would.
  • Method Details

    • isEnabled

      boolean isEnabled()
      Whether custom games are enabled on this server.
    • getUpcomingGames

      @NotNull @NotNull List<CustomGameInfo> getUpcomingGames()
      Every published game that has not started yet, soonest first.
    • getActiveGames

      @NotNull @NotNull List<CustomGameInfo> getActiveGames()
      Every game that is not over yet - upcoming or running - in no particular order.
    • getGame

      @NotNull @NotNull Optional<CustomGameInfo> getGame(@NotNull @NotNull UUID customGameId)
      The game with this ID, while it is not over.
    • getGamesHostedBy

      @NotNull @NotNull List<CustomGameInfo> getGamesHostedBy(@NotNull @NotNull UUID hostId)
      The games a player hosts that are not over yet.
    • getGame

      @NotNull @NotNull Optional<CustomGameInfo> getGame(@NotNull @NotNull ZentrixGame runtime)
      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.JOINING means the join was accepted and is underway
    • cancel

      boolean cancel(@NotNull @NotNull UUID customGameId)
      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

      boolean terminate(@NotNull @NotNull UUID customGameId)
      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