Interface GameContext<P,L,W,M,I,S,B,E>
- Type Parameters:
P- the player type (platform-specific)L- the location type (platform-specific)W- the world type (platform-specific)M- the material/block type (platform-specific)I- the item stack type (platform-specific)S- the sound type (platform-specific)B- the block type (platform-specific)E- the entity type (platform-specific)
GameContext is the primary interface game modules use to interact with the game engine. It provides access to player management, APIs for UI/world manipulation, game state, and configuration. This context is available during all game lifecycle phases.
-
Method Summary
Modifier and TypeMethodDescriptionvoideliminatePlayer(P player, String reason) Eliminates a player from the game with a specific reason.voidendGame()Ends the current game immediately.voidfinishPlayer(P player) Marks a player as having finished the game successfully.Gets all players who are still actively playing (not eliminated or spectating).Gets the Arena API for arena management.intGets the ID of the arena this game is running in.Gets the Blocks API for world manipulation.Gets the Config API for core configuration access.Gets the Core Config API for core settings.intGets the current round number (1-based).Gets the Data Access API for reading arena configuration.Gets the unique identifier of this game module.getGamePlayer(P player) Gets the GamePlayer wrapper for a specific player.Gets the Hologram API for creating floating text displays.default HytaleMenuAPI<P> Gets the experimental Hytale menu API for HyUI-backed custom pages.Gets the Item API for item manipulation.default LanguageAPI<P> Gets the language API for locale-aware module translations.intGets the maximum number of rounds configured for this game.Gets the Menu API for creating custom menus.Gets the Message API for sending chat messages.Get module-specific configuration API.Get module metadata from module.yml.default PersistentPlayerDataAPI<P> Gets the player data API for module-scoped persistent player data.getPhase()Gets the current phase of the game.Gets all players in the game (playing, spectating, and eliminated).Gets the Player Util for player-related utilities.Gets the Scheduler API for running delayed/repeated tasks.Gets the Scoreboard API for managing scoreboards.Deprecated.Use getModuleConfig() instead for better flexibilityGets the Sounds API for playing sound effects.Gets all players who are spectating the game.Access summary and reward toggles for the current game session.Gets the Teams API for team-based games.Gets the Titles API for displaying titles and subtitles.Gets the Vote Menu API for game voting.booleanChecks if a player is in this game.booleanisInsideBounds(L location) Checks if a location is within the arena boundaries.booleanisPlayerPlaying(P player) Checks if a player is actively playing (not spectating or eliminated).default booleanisPlayerSpectating(P player) Checks whether a player is currently spectating this game.voidmarkSharedFirstPlace(List<P> players) Marks multiple players as sharing first place (tie).voidrespawnPlayer(P player) Respawns a player at their designated spawn point.voidSets the current phase of the game.voidsetPlayers(List<P> players) Sets the list of players in the game.default voidsetPlayerSpectating(P player, boolean spectating) Marks whether a player is currently spectating this game.voidSets a single winner for the game.voidTeleports all players to their assigned spawn points.
-
Method Details
-
getArenaId
int getArenaId()Gets the ID of the arena this game is running in.- Returns:
- the arena ID
-
getGameId
String getGameId()Gets the unique identifier of this game module.- Returns:
- the game module ID
-
getPhase
GamePhase getPhase()Gets the current phase of the game.- Returns:
- the current game phase
-
setPhase
Sets the current phase of the game.This should be used carefully as it affects game flow and lifecycle hooks.
- Parameters:
phase- the new game phase
-
getCurrentRound
int getCurrentRound()Gets the current round number (1-based).- Returns:
- the current round
-
getMaxRounds
int getMaxRounds()Gets the maximum number of rounds configured for this game.- Returns:
- the max rounds, or 1 if not a multi-round game
-
isInsideBounds
Checks if a location is within the arena boundaries.- Parameters:
location- the location to check- Returns:
- true if inside bounds, false otherwise
-
respawnPlayer
Respawns a player at their designated spawn point.- Parameters:
player- the player to respawn
-
finishPlayer
Marks a player as having finished the game successfully.This is typically used in race-type games when a player crosses the finish line.
- Parameters:
player- the player who finished
-
isPlayerPlaying
Checks if a player is actively playing (not spectating or eliminated).- Parameters:
player- the player to check- Returns:
- true if the player is in PLAYING state
-
setPlayerSpectating
Marks whether a player is currently spectating this game.Modules should use this method instead of changing the native platform spectator mode directly. The Core may represent spectators with a custom state, visibility, inventory, and movement policy.
- Parameters:
player- the player to updatespectating- true to move the player to spectator state, false to restore playing state
-
isPlayerSpectating
Checks whether a player is currently spectating this game.- Parameters:
player- the player to check- Returns:
- true if the player is spectating
-
getPlayers
Gets all players in the game (playing, spectating, and eliminated).- Returns:
- list of all players in the arena
-
getAlivePlayers
Gets all players who are still actively playing (not eliminated or spectating).- Returns:
- list of alive players
-
getSpectators
Gets all players who are spectating the game.- Returns:
- list of spectator players
-
hasPlayer
Checks if a player is in this game.- Parameters:
player- the player to check- Returns:
- true if the player is in this game
-
getGamePlayer
Gets the GamePlayer wrapper for a specific player.- Parameters:
player- the platform player- Returns:
- the GamePlayer instance, or null if not in game
-
eliminatePlayer
Eliminates a player from the game with a specific reason.- Parameters:
player- the player to eliminatereason- the elimination reason (for events/logging)
-
setWinner
Sets a single winner for the game.This should be called when determining the game result.
- Parameters:
player- the winning player
-
teleportPlayersToSpawns
void teleportPlayersToSpawns()Teleports all players to their assigned spawn points. -
setPlayers
Sets the list of players in the game.This is typically used during game initialization.
- Parameters:
players- the players to set
-
getArenaAPI
Gets the Arena API for arena management.- Returns:
- the arena API
-
getBlocksAPI
Gets the Blocks API for world manipulation.- Returns:
- the blocks API
-
getMessagesAPI
MessageAPI<P> getMessagesAPI()Gets the Message API for sending chat messages.- Returns:
- the message API
-
getTitlesAPI
Gets the Titles API for displaying titles and subtitles.- Returns:
- the titles API
-
getSoundsAPI
Gets the Sounds API for playing sound effects.- Returns:
- the sounds API
-
getScoreboardAPI
ScoreboardAPI<P> getScoreboardAPI()Gets the Scoreboard API for managing scoreboards.- Returns:
- the scoreboard API
-
getItemAPI
Gets the Item API for item manipulation.- Returns:
- the item API
-
getHologramAPI
HologramAPI<L> getHologramAPI()Gets the Hologram API for creating floating text displays.- Returns:
- the hologram API
-
getSchedulerAPI
SchedulerAPI<E,L> getSchedulerAPI()Gets the Scheduler API for running delayed/repeated tasks.- Returns:
- the scheduler API
-
getTeamsAPI
Gets the Teams API for team-based games.- Returns:
- the teams API
-
getDataAccess
DataAccess<L> getDataAccess()Gets the Data Access API for reading arena configuration.- Returns:
- the data access API
-
getPlayerUtil
PlayerUtil<P> getPlayerUtil()Gets the Player Util for player-related utilities.- Returns:
- the player util
-
getConfigAPI
ConfigAPI getConfigAPI()Gets the Config API for core configuration access.- Returns:
- the config API
-
getVoteMenuAPI
VoteMenuAPI<M> getVoteMenuAPI()Gets the Vote Menu API for game voting.- Returns:
- the vote menu API
-
getMenuAPI
Gets the Menu API for creating custom menus.- Returns:
- the menu API
-
getHytaleMenuAPI
Gets the experimental Hytale menu API for HyUI-backed custom pages.Non-Hytale runtimes return
null.- Returns:
- Hytale menu API or
null - Since:
- 3.2
-
getCoreConfig
CoreConfigAPI getCoreConfig()Gets the Core Config API for core settings.- Returns:
- the core config API
-
getModuleConfig
ModuleConfigAPI getModuleConfig()Get module-specific configuration API. Allows modules to manage multiple config files (config.yml, settings.yml, items.yml, etc.)- Returns:
- ModuleConfigAPI instance for this game module
-
getPersistentPlayerDataAPI
Gets the player data API for module-scoped persistent player data.- Returns:
- player data API, or
nullif not supported by this runtime - Since:
- 3.4
-
getLanguageAPI
Gets the language API for locale-aware module translations.- Returns:
- language API, or
nullif not supported by this runtime - Since:
- 3.4
-
getModuleInfo
ModuleInfo getModuleInfo()Get module metadata from module.yml. Provides access to module name, version, authors, etc.- Returns:
- ModuleInfo with module metadata
-
getSettings
Deprecated.Use getModuleConfig() instead for better flexibility -
endGame
void endGame()Ends the current game immediately.This triggers the game ending sequence, including result calculation, summary display, and rewards distribution.
-
getSummarySettings
SummarySettings getSummarySettings()Access summary and reward toggles for the current game session.- Returns:
- mutable summary settings
-