Class GymGame

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

public class GymGame extends Object implements Minigame, org.bukkit.event.Listener
Represents a gym-themed minigame where players can interact with punching bags, treadmills, and trampolines to earn time tickets.

This class implements the Minigame interface and handles game initialization, player interactions, and game logic.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new GymGame with the specified configuration and plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called after the game has been initialized.
    boolean
    Returns true if players can join this game while it is already running.
    Returns the game configuration.
    List<org.bukkit.entity.Player>
    Returns the list of players currently in the game.
    void
    join(org.bukkit.entity.Player player)
    Adds the player to the game.
    void
    leave(org.bukkit.entity.Player player)
    Removes the player from the game.
    void
    Destroys the game, unregistering all events and cleaning up resources.
    void
    Initializes the minigame.
    void
    onInteract(org.bukkit.event.player.PlayerInteractEvent event)
    Handles player interactions with punching bags.
    void
    onMove(org.bukkit.event.player.PlayerMoveEvent event)
    Handles player movement to detect treadmill and trampoline interactions.
    void
    onSneak(org.bukkit.event.player.PlayerToggleSneakEvent event)
    Handles player crouch (sneak) actions to detect squat interactions.
    void
    removeItems(org.bukkit.entity.Player player)
    Removes specific items from the player's inventory as required by the minigame.
    void
    Renders any visual elements or updates required by the minigame.
    void
    Resets all gym station counts and displays back to the goal value.
    boolean
    Determines whether the game should end or quit.
    boolean
    Returns true if players should be teleported to the exit area when the game ends.
    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

    onCommand, onDamage, onDeath
    Modifier and Type
    Method
    Description
    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.
  • Constructor Details

    • GymGame

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

    • onInit

      public void onInit()
      Description copied from interface: Minigame
      Initializes the minigame.
      Specified by:
      onInit in interface Minigame
    • join

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

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

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

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

      public void onDestroy()
      Destroys the game, unregistering all events and cleaning up resources.
      Specified by:
      onDestroy in interface Minigame
    • allowsConcurrentJoins

      public boolean allowsConcurrentJoins()
      Description copied from interface: Minigame
      Returns true if players can join this game while it is already running. Defaults to false (players must wait for the previous round to finish).
      Specified by:
      allowsConcurrentJoins in interface Minigame
    • shouldTeleportOnExit

      public boolean shouldTeleportOnExit()
      Description copied from interface: Minigame
      Returns true if players should be teleported to the exit area when the game ends. Defaults to true; override to false for games that manage their own exit flow.
      Specified by:
      shouldTeleportOnExit in interface Minigame
    • onInteract

      public void onInteract(org.bukkit.event.player.PlayerInteractEvent event)
      Handles player interactions with punching bags.
      Specified by:
      onInteract in interface Minigame
      Parameters:
      event - the PlayerInteractEvent triggered by a player
    • onMove

      public void onMove(org.bukkit.event.player.PlayerMoveEvent event)
      Handles player movement to detect treadmill and trampoline interactions.
      Specified by:
      onMove in interface Minigame
      Parameters:
      event - the PlayerMoveEvent triggered by a player moving
    • resetAllCounts

      public void resetAllCounts()
      Resets all gym station counts and displays back to the goal value.
    • afterInit

      public void afterInit()
      Called after the game has been initialized. Use this method to perform any post-initialization logic required by the minigame.
      Specified by:
      afterInit in interface Minigame
    • update

      public void update()
      Updates the game state. This method should be called periodically to handle game logic, timers, or state changes.
      Specified by:
      update in interface Minigame
    • render

      public void render()
      Renders any visual elements or updates required by the minigame. This method can be used to update scoreboards, holograms, or other UI elements.
      Specified by:
      render in interface Minigame
    • shouldQuit

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

      public void removeItems(org.bukkit.entity.Player player)
      Removes specific items from the player's inventory as required by the minigame.
      Specified by:
      removeItems in interface Minigame
      Parameters:
      player - the player from whom to remove items
    • onSneak

      public void onSneak(org.bukkit.event.player.PlayerToggleSneakEvent event)
      Handles player crouch (sneak) actions to detect squat interactions.
      Specified by:
      onSneak in interface Minigame
      Parameters:
      event - the PlayerToggleSneakEvent triggered by a player