Interface GameTypeService
public interface GameTypeService
Service for managing game types within Zentrix.
Game types define different modes of play (e.g., Solos, Duos, Squads) with their own team sizes, player limits, and scoreboards. This service allows registration, querying, and management of game types.
Example Usage
GameTypeService gameTypeService = ZentrixAPI.get().getGameTypeService();
// Register a new 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);
// Query 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.This method performs in-memory registration 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 the game-types.yml configuration file.
- 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.This method performs in-memory removal 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
-