Package stawa.vitalstrike.systems
Class KnockdownManager
java.lang.Object
stawa.vitalstrike.systems.KnockdownManager
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
ConstructorsConstructorDescriptionKnockdownManager(VitalStrike plugin) Initializes the KnockdownManager with configuration settings from the plugin. -
Method Summary
Modifier and TypeMethodDescriptionvoidattemptSelfRevive(org.bukkit.entity.Player player) Attempts to initiate a self-revival process for a downed player using a Vital Awakening item.voidcancelRevive(UUID reviverId) Cancels an ongoing revival attempt by a player.voidcancelSelfRevive(org.bukkit.entity.Player player) Cancels an ongoing self-revival attempt for a player.voidcleanup()Performs cleanup of all active knockdown-related tasks and resources.doubleGets the maximum range at which players can be revivedvoidhandlePlayerDeath(org.bukkit.entity.Player player) Initiates the knockdown state for a player who would normally die.voidhandlePlayerJoin(org.bukkit.entity.Player player) Manages the state restoration of a player who rejoins the server while in a downed state.voidhandlePlayerQuit(org.bukkit.entity.Player player) Handles a player disconnecting from the server while in a downed state.booleanisAttemptingRevive(org.bukkit.entity.Player player) Checks if a player is currently attempting to revive another player.booleanisPlayerDowned(org.bukkit.entity.Player player) Checks if a player is currently in a downed state.voidrevivePlayer(org.bukkit.entity.Player player) Revives a player from their downed state by restoring their normal gameplay state.voidstartRevive(org.bukkit.entity.Player reviver, org.bukkit.entity.Player target) Starts the revival process for a downed player by another player.voidstartSelfRevive(org.bukkit.entity.Player player) Starts the self-revival process for a downed player.
-
Constructor Details
-
KnockdownManager
Initializes the KnockdownManager with configuration settings from the plugin.- Parameters:
plugin- The VitalStrike plugin instance- Throws:
Errors.ConfigurationException- If there are issues with the configuration values
-
-
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 playertarget- The downed player being revived
-
cancelRevive
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
-