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)

public interface GameContext<P,L,W,M,I,S,B,E>
Provides runtime access to all game APIs and state during gameplay.

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 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

      void setPhase(GamePhase phase)
      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

      boolean isInsideBounds(L location)
      Checks if a location is within the arena boundaries.
      Parameters:
      location - the location to check
      Returns:
      true if inside bounds, false otherwise
    • respawnPlayer

      void respawnPlayer(P player)
      Respawns a player at their designated spawn point.
      Parameters:
      player - the player to respawn
    • finishPlayer

      void finishPlayer(P player)
      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

      boolean isPlayerPlaying(P player)
      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

      default void setPlayerSpectating(P player, boolean spectating)
      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 update
      spectating - true to move the player to spectator state, false to restore playing state
    • isPlayerSpectating

      default boolean isPlayerSpectating(P player)
      Checks whether a player is currently spectating this game.
      Parameters:
      player - the player to check
      Returns:
      true if the player is spectating
    • getPlayers

      List<P> getPlayers()
      Gets all players in the game (playing, spectating, and eliminated).
      Returns:
      list of all players in the arena
    • getAlivePlayers

      List<P> getAlivePlayers()
      Gets all players who are still actively playing (not eliminated or spectating).
      Returns:
      list of alive players
    • getSpectators

      List<P> getSpectators()
      Gets all players who are spectating the game.
      Returns:
      list of spectator players
    • hasPlayer

      boolean hasPlayer(P player)
      Checks if a player is in this game.
      Parameters:
      player - the player to check
      Returns:
      true if the player is in this game
    • getGamePlayer

      GamePlayer<P> getGamePlayer(P player)
      Gets the GamePlayer wrapper for a specific player.
      Parameters:
      player - the platform player
      Returns:
      the GamePlayer instance, or null if not in game
    • eliminatePlayer

      void eliminatePlayer(P player, String reason)
      Eliminates a player from the game with a specific reason.
      Parameters:
      player - the player to eliminate
      reason - the elimination reason (for events/logging)
    • setWinner

      void setWinner(P player)
      Sets a single winner for the game.

      This should be called when determining the game result.

      Parameters:
      player - the winning player
    • markSharedFirstPlace

      void markSharedFirstPlace(List<P> players)
      Marks multiple players as sharing first place (tie).
      Parameters:
      players - the players who tied for first
    • teleportPlayersToSpawns

      void teleportPlayersToSpawns()
      Teleports all players to their assigned spawn points.
    • setPlayers

      void setPlayers(List<P> players)
      Sets the list of players in the game.

      This is typically used during game initialization.

      Parameters:
      players - the players to set
    • getArenaAPI

      ArenaAPI<L,W> getArenaAPI()
      Gets the Arena API for arena management.
      Returns:
      the arena API
    • getBlocksAPI

      BlocksAPI<L,M,B> 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

      TitlesAPI<P> getTitlesAPI()
      Gets the Titles API for displaying titles and subtitles.
      Returns:
      the titles API
    • getSoundsAPI

      SoundsAPI<P,L,S> 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

      ItemAPI<P,I,M> 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

      TeamsAPI<P,M> 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

      MenuAPI<P,M> getMenuAPI()
      Gets the Menu API for creating custom menus.
      Returns:
      the menu API
    • getHytaleMenuAPI

      default HytaleMenuAPI<P> 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

      default PersistentPlayerDataAPI<P> getPersistentPlayerDataAPI()
      Gets the player data API for module-scoped persistent player data.
      Returns:
      player data API, or null if not supported by this runtime
      Since:
      3.4
    • getLanguageAPI

      default LanguageAPI<P> getLanguageAPI()
      Gets the language API for locale-aware module translations.
      Returns:
      language API, or null if 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