Class KnockdownManager

java.lang.Object
stawa.vitalstrike.systems.KnockdownManager

public class KnockdownManager extends Object
Manages the knockdown system in VitalStrike, providing a second-chance mechanic for players in combat. When a player would normally die, they enter a "downed" state where they are temporarily incapacitated but can be revived by teammates or use special items for self-revival.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes the KnockdownManager with configuration settings from the plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    attemptSelfRevive(org.bukkit.entity.Player player)
    Attempts to initiate a self-revival process for a downed player using a Vital Awakening item.
    void
    cancelRevive(UUID reviverId)
    Cancels an ongoing revival attempt by a player.
    void
    cancelSelfRevive(org.bukkit.entity.Player player)
    Cancels an ongoing self-revival attempt for a player.
    void
    Performs cleanup of all active knockdown-related tasks and resources.
    double
    Gets the maximum range at which players can be revived
    void
    handlePlayerDeath(org.bukkit.entity.Player player)
    Initiates the knockdown state for a player who would normally die.
    void
    handlePlayerJoin(org.bukkit.entity.Player player)
    Manages the state restoration of a player who rejoins the server while in a downed state.
    void
    handlePlayerQuit(org.bukkit.entity.Player player)
    Handles a player disconnecting from the server while in a downed state.
    boolean
    isAttemptingRevive(org.bukkit.entity.Player player)
    Checks if a player is currently attempting to revive another player.
    boolean
    isPlayerDowned(org.bukkit.entity.Player player)
    Checks if a player is currently in a downed state.
    void
    revivePlayer(org.bukkit.entity.Player player)
    Revives a player from their downed state by restoring their normal gameplay state.
    void
    startRevive(org.bukkit.entity.Player reviver, org.bukkit.entity.Player target)
    Starts the revival process for a downed player by another player.
    void
    startSelfRevive(org.bukkit.entity.Player player)
    Starts the self-revival process for a downed player.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • attemptSelfRevive

      public void attemptSelfRevive(org.bukkit.entity.Player player)
      Attempts to initiate a self-revival process for a downed player using a Vital Awakening item. If instant use is enabled, the revival happens immediately. Otherwise, it starts a progress bar.
      Parameters:
      player - The player attempting to self-revive
    • cancelSelfRevive

      public void cancelSelfRevive(org.bukkit.entity.Player player)
      Cancels an ongoing self-revival attempt for a player. Cleans up associated tasks and progress bars.
      Parameters:
      player - The player whose self-revival attempt should be cancelled
    • startSelfRevive

      public void startSelfRevive(org.bukkit.entity.Player player)
      Starts the self-revival process for a downed player. Creates a boss bar to show progress and schedules the task to handle the revival.
      Parameters:
      player - The player attempting to self-revive
    • cleanup

      public void cleanup()
      Performs cleanup of all active knockdown-related tasks and resources. This should be called when the plugin is being disabled or reloaded.
    • handlePlayerDeath

      public void handlePlayerDeath(org.bukkit.entity.Player player)
      Initiates the knockdown state for a player who would normally die. This method handles the complete
      Parameters:
      player - The player entering the knockdown state
    • handlePlayerQuit

      public void handlePlayerQuit(org.bukkit.entity.Player player)
      Handles a player disconnecting from the server while in a downed state. Preserves their downed state but cancels active tasks.
      Parameters:
      player - The player who disconnected
    • handlePlayerJoin

      public void handlePlayerJoin(org.bukkit.entity.Player player)
      Manages the state restoration of a player who rejoins the server while in a downed state. This method handles several scenarios:
      • Checks if the player's downed timer expired during their absence
      • Restores the downed state with appropriate health and effects if time remains
      • Resumes the countdown timer and UI elements
      • Ensures proper cleanup if the player disconnects again
      Parameters:
      player - The player who joined the server
    • revivePlayer

      public void revivePlayer(org.bukkit.entity.Player player)
      Revives a player from their downed state by restoring their normal gameplay state. This method handles the complete revival process including:
      • Canceling all active downed state tasks
      • Removing UI elements and visual indicators
      • Clearing all downed state tracking data
      • Restoring the player's normal movement, health, and status effects
      Parameters:
      player - The player to revive from the downed state
    • startRevive

      public void startRevive(org.bukkit.entity.Player reviver, org.bukkit.entity.Player target)
      Starts the revival process for a downed player by another player.
      Parameters:
      reviver - The player attempting to revive the downed player
      target - The downed player being revived
    • cancelRevive

      public void cancelRevive(UUID reviverId)
      Cancels an ongoing revival attempt by a player. Cleans up associated tasks and progress bars.
      Parameters:
      reviverId - The UUID of the player attempting the revival
    • isPlayerDowned

      public boolean isPlayerDowned(org.bukkit.entity.Player player)
      Checks if a player is currently in a downed state.
      Parameters:
      player - The player to check
      Returns:
      true if the player is downed, false otherwise
    • getReviveRange

      public double getReviveRange()
      Gets the maximum range at which players can be revived
      Returns:
      The revival range in blocks
    • isAttemptingRevive

      public boolean isAttemptingRevive(org.bukkit.entity.Player player)
      Checks if a player is currently attempting to revive another player.
      Parameters:
      player - The player to check
      Returns:
      true if the player is attempting to revive someone, false otherwise