Class BattleshipGame

java.lang.Object
com.storytimeproductions.stweaks.games.BattleshipGame
All Implemented Interfaces:
Minigame, org.bukkit.event.Listener

public class BattleshipGame extends Object implements Minigame, org.bukkit.event.Listener
Represents a Battleship game where players place ships on a board and take turns.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new Battleship game with the specified configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called after the game has been initialized.
    Gets the game configuration.
    List<org.bukkit.entity.Player>
    Gets the list of players currently in the game.
    void
    join(org.bukkit.entity.Player player)
    Allows a player to join the game.
    void
    leave(org.bukkit.entity.Player player)
    Allows a player to leave the game.
    void
    Called when the game is destroyed or stopped.
    void
    Initializes the Battleship game.
    void
    onInteract(org.bukkit.event.player.PlayerInteractEvent event)
    Handles player interactions to place or remove ship blocks on the board.
    void
    removeItems(org.bukkit.entity.Player player)
    Removes all game-related items from the player's inventory.
    void
    Renders the game state.
    boolean
    Determines if the game should quit.
    void
    Updates the game state.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Minigame

    allowsConcurrentJoins, onCommand, onDamage, onDeath, onMove, onSneak, shouldTeleportOnExit
    Modifier and Type
    Method
    Description
    default boolean
    Returns true if players can join this game while it is already running.
    default void
    onCommand(org.bukkit.event.player.PlayerCommandPreprocessEvent event)
    Called when a player in this game runs a command.
    default void
    onDamage(org.bukkit.event.entity.EntityDamageByEntityEvent event)
    Called when a player in this game damages another player in this game.
    default void
    onDeath(org.bukkit.event.entity.PlayerDeathEvent event)
    Called when a player in this game dies.
    default void
    onMove(org.bukkit.event.player.PlayerMoveEvent event)
    Called when a player in this game moves.
    default void
    onSneak(org.bukkit.event.player.PlayerToggleSneakEvent event)
    Called when a player in this game toggles sneak.
    default boolean
    Returns true if players should be teleported to the exit area when the game ends.
  • Constructor Details

    • BattleshipGame

      public BattleshipGame(GameConfig config)
      Constructs a new Battleship game with the specified configuration.
      Parameters:
      config - the game configuration
  • Method Details

    • onInit

      public void onInit()
      Initializes the Battleship game.
      Specified by:
      onInit in interface Minigame
    • afterInit

      public void afterInit()
      Called after the game has been initialized.
      Specified by:
      afterInit in interface Minigame
    • update

      public void update()
      Updates the game state.
      Specified by:
      update in interface Minigame
    • render

      public void render()
      Renders the game state.
      Specified by:
      render in interface Minigame
    • onDestroy

      public void onDestroy()
      Called when the game is destroyed or stopped.
      Specified by:
      onDestroy in interface Minigame
    • join

      public void join(org.bukkit.entity.Player player)
      Allows a player to join the game.
      Specified by:
      join in interface Minigame
      Parameters:
      player - the player to add
    • leave

      public void leave(org.bukkit.entity.Player player)
      Allows a player to leave the game.
      Specified by:
      leave in interface Minigame
      Parameters:
      player - the player to remove
    • getPlayers

      public List<org.bukkit.entity.Player> getPlayers()
      Gets the list of players currently in the game.
      Specified by:
      getPlayers in interface Minigame
      Returns:
      a list of players in the minigame
    • getConfig

      public GameConfig getConfig()
      Gets the game configuration.
      Specified by:
      getConfig in interface Minigame
      Returns:
      the minigame configuration
    • shouldQuit

      public boolean shouldQuit()
      Determines if the game should quit.
      Specified by:
      shouldQuit in interface Minigame
      Returns:
      true if the minigame should quit, false otherwise
    • onInteract

      public void onInteract(org.bukkit.event.player.PlayerInteractEvent event)
      Handles player interactions to place or remove ship blocks on the board.
      Specified by:
      onInteract in interface Minigame
      Parameters:
      event - the PlayerInteractEvent triggered by the player
    • removeItems

      public void removeItems(org.bukkit.entity.Player player)
      Description copied from interface: Minigame
      Removes all game-related items from the player's inventory.
      Specified by:
      removeItems in interface Minigame
      Parameters:
      player - the player whose items will be removed