Interface GameTypeService


public interface GameTypeService
Manages game types within Zentrix.

A game type defines a mode of play, such as Solos, Duos, or Squads, with its team size, player limits, and scoreboards. The service registers and queries game types.

Example


 GameTypeService gameTypeService = ZentrixAPI.get().getGameTypeService();

 // Register a game type
 GameTypeBuilder trios = new GameTypeBuilder()
     .name("trios")
     .teamSize(3)
     .minimumPlayers(6)
     .maximumPlayers(30)
     .startTime(45)
     .scoreboard(GameTypeState.WAITING, sb -> sb
         .title("&#FFD700&lTRIOS")
         .line("&#AAAAAA Players: &#55FF55%players%/%max%"))
     .addonId(getAddonId());

 gameTypeService.registerGameType(trios);

 // List game types
 Collection<ZentrixGameType> allTypes = gameTypeService.getAllGameTypes();
 
Since:
1.1.0
  • Method Details

    • registerGameType

      boolean registerGameType(@NotNull @NotNull GameTypeBuilder builder)
      Registers a custom game type from a builder.

      The registration is kept in memory only.

      Parameters:
      builder - The game type builder with configuration
      Returns:
      true if registration was successful
      Throws:
      IllegalArgumentException - if the builder is invalid
    • registerGameTypeAsync

      @NotNull @NotNull CompletableFuture<Boolean> registerGameTypeAsync(@NotNull @NotNull GameTypeBuilder builder)
      Registers a custom game type asynchronously with persistence.

      The game type is registered and saved to game-types.yml.

      Parameters:
      builder - The game type builder with configuration
      Returns:
      A future that completes with true if successful
      Throws:
      IllegalArgumentException - if the builder is invalid
    • unregisterGameType

      boolean unregisterGameType(@NotNull @NotNull String gameTypeName)
      Unregisters a game type by name.

      The removal affects memory only. Built-in game types cannot be unregistered.

      Parameters:
      gameTypeName - The name of the game type to unregister
      Returns:
      true if the game type was found and removed
    • updateGameType

      boolean updateGameType(@NotNull @NotNull GameTypeBuilder builder)
      Updates an existing game type with new configuration.

      The game type must already exist.

      Parameters:
      builder - The game type builder with updated configuration
      Returns:
      true if the game type was found and updated
    • getGameType

      @NotNull @NotNull Optional<ZentrixGameType> getGameType(@NotNull @NotNull String name)
      Gets a game type by its name.
      Parameters:
      name - The game type name (case-insensitive)
      Returns:
      Optional containing the game type, or empty if not found
    • getAllGameTypes

      @NotNull @NotNull Collection<ZentrixGameType> getAllGameTypes()
      Gets all registered game types.
      Returns:
      An unmodifiable collection of all game types (never null, may be empty)
    • getGameTypesByAddon

      @NotNull @NotNull Collection<ZentrixGameType> getGameTypesByAddon(@NotNull @NotNull String addonId)
      Gets all game types registered by a specific addon.
      Parameters:
      addonId - The addon identifier
      Returns:
      Collection of game types registered by the addon (never null, may be empty)
    • gameTypeExists

      boolean gameTypeExists(@NotNull @NotNull String name)
      Checks if a game type exists with the given name.
      Parameters:
      name - The game type name to check
      Returns:
      true if the game type exists
    • getGameTypeNames

      @NotNull @NotNull Collection<String> getGameTypeNames()
      Gets all game type names.
      Returns:
      Collection of game type names (never null, may be empty)
    • isBuiltIn

      boolean isBuiltIn(@NotNull @NotNull String name)
      Checks if a game type is built-in (from configuration).
      Parameters:
      name - The game type name
      Returns:
      true if the game type is built-in
    • createGameTypeBuilder

      @NotNull default @NotNull GameTypeBuilder createGameTypeBuilder()
      Creates a new GameTypeBuilder instance.
      Returns:
      A new GameTypeBuilder