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: 7FF55%players%/%max%"))
.addonId(getAddonId());
gameTypeService.registerGameType(trios);
// List game types
Collection<ZentrixGameType> allTypes = gameTypeService.getAllGameTypes();
- Since:
- 1.1.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NotNull GameTypeBuilderCreates a new GameTypeBuilder instance.booleangameTypeExists(@NotNull String name) Checks if a game type exists with the given name.@NotNull Collection<ZentrixGameType> Gets all registered game types.@NotNull Optional<ZentrixGameType> getGameType(@NotNull String name) Gets a game type by its name.@NotNull Collection<String> Gets all game type names.@NotNull Collection<ZentrixGameType> getGameTypesByAddon(@NotNull String addonId) Gets all game types registered by a specific addon.booleanChecks if a game type is built-in (from configuration).booleanregisterGameType(@NotNull GameTypeBuilder builder) Registers a custom game type from a builder.@NotNull CompletableFuture<Boolean> registerGameTypeAsync(@NotNull GameTypeBuilder builder) Registers a custom game type asynchronously with persistence.booleanunregisterGameType(@NotNull String gameTypeName) Unregisters a game type by name.booleanupdateGameType(@NotNull GameTypeBuilder builder) Updates an existing game type with new configuration.
-
Method Details
-
registerGameType
Registers a custom game type from a builder.The registration is kept in memory only.
- Parameters:
builder- The game type builder with configuration- Returns:
trueif 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
trueif successful - Throws:
IllegalArgumentException- if the builder is invalid
-
unregisterGameType
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:
trueif the game type was found and removed
-
updateGameType
Updates an existing game type with new configuration.The game type must already exist.
- Parameters:
builder- The game type builder with updated configuration- Returns:
trueif the game type was found and updated
-
getGameType
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
Gets all registered game types.- Returns:
- An unmodifiable collection of all game types (never null, may be empty)
-
getGameTypesByAddon
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
Checks if a game type exists with the given name.- Parameters:
name- The game type name to check- Returns:
trueif the game type exists
-
getGameTypeNames
Gets all game type names.- Returns:
- Collection of game type names (never null, may be empty)
-
isBuiltIn
Checks if a game type is built-in (from configuration).- Parameters:
name- The game type name- Returns:
trueif the game type is built-in
-
createGameTypeBuilder
Creates a new GameTypeBuilder instance.- Returns:
- A new GameTypeBuilder
-