Class SoulPowerManager

java.lang.Object
valorless.rarespawns.soulpower.SoulPowerManager
All Implemented Interfaces:
org.bukkit.event.Listener

public class SoulPowerManager extends Object implements org.bukkit.event.Listener
Manages Soul Powers and Soul Harvester progression for players.

Responsibilities include:

  • Discovering soul powers and Soul Harvester items equipped or held by a player.
  • Applying and checking cooldowns for powers.
  • Evaluating unlock conditions and applying upgrades.
  • Adding and persisting souls on items via PDC.
This class is stateless except for an in-memory cooldown map keyed by player and power ID.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Boolean
    addSouls(org.bukkit.inventory.ItemStack item, Integer amount)
    Adds souls to a Soul Harvester item, respecting the configured maxSouls cap.
    static Boolean
    checkConditions(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item, ItemData data)
    Evaluates whether the given item now meets any Soul Harvester upgrade conditions and applies the first matching upgrade.
    static void
    clearCooldown(org.bukkit.entity.Player player, String id)
    Clears any active cooldown for the given player's power.
    static HashMap<org.bukkit.inventory.ItemStack,ItemData>
    getSoulHarvesterItems(org.bukkit.entity.Player player)
    Lists all items in the player's inventory that contain a Soul Harvester component.
    getSoulPowers(org.bukkit.entity.Player player)
    Collects all soul powers available to the player from their equipped armor and main-hand item, regardless of trigger type.
    getSoulPowers(org.bukkit.entity.Player player, SoulPowerInfo.SoulPowerType type)
    Collects soul powers of a specific trigger type from the player's equipped armor and main-hand item.
    static Boolean
    isOnCooldown(org.bukkit.entity.Player player, String id)
    Checks whether the specified power is still on cooldown for the player.
    static boolean
    isPowerUnlocked(org.bukkit.entity.Player player, String id)
    Determines if any equipped item for the player has unlocked and applied the provided power ID.
    static boolean
    isWorldWhitelisted(org.bukkit.World world, SoulHarvesterComponent data)
     
    static void
    setCooldown(org.bukkit.entity.Player player, String id)
    Sets/refreshes the cooldown timestamp for a player's power to now.

    Methods inherited from class java.lang.Object

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

    • SoulPowerManager

      public SoulPowerManager()
  • Method Details

    • getSoulPowers

      public static HashMap<String,ItemData> getSoulPowers(org.bukkit.entity.Player player)
      Collects all soul powers available to the player from their equipped armor and main-hand item, regardless of trigger type.
      Parameters:
      player - the player to inspect
      Returns:
      a map of powerId -> ItemData providing the power's source data, or null if none
    • getSoulHarvesterItems

      public static HashMap<org.bukkit.inventory.ItemStack,ItemData> getSoulHarvesterItems(org.bukkit.entity.Player player)
      Lists all items in the player's inventory that contain a Soul Harvester component.
      Parameters:
      player - the player to inspect
      Returns:
      a map of ItemStack -> ItemData for items with a Soul Harvester, or null if none
    • getSoulPowers

      public static HashMap<String,ItemData> getSoulPowers(org.bukkit.entity.Player player, SoulPowerInfo.SoulPowerType type)
      Collects soul powers of a specific trigger type from the player's equipped armor and main-hand item.
      Parameters:
      player - the player to inspect
      type - the trigger type to filter by
      Returns:
      a map of powerId -> ItemData for matching powers, or null if none
    • isOnCooldown

      public static Boolean isOnCooldown(org.bukkit.entity.Player player, String id)
      Checks whether the specified power is still on cooldown for the player.
      Parameters:
      player - the player
      id - the power ID
      Returns:
      true if cooldown remains; false otherwise
    • setCooldown

      public static void setCooldown(org.bukkit.entity.Player player, String id)
      Sets/refreshes the cooldown timestamp for a player's power to now.
      Parameters:
      player - the player
      id - the power ID
    • clearCooldown

      public static void clearCooldown(org.bukkit.entity.Player player, String id)
      Clears any active cooldown for the given player's power.
      Parameters:
      player - the player
      id - the power ID
    • checkConditions

      public static Boolean checkConditions(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item, ItemData data)
      Evaluates whether the given item now meets any Soul Harvester upgrade conditions and applies the first matching upgrade. Plays an optional unlock SFX.
      Parameters:
      player - the owner of the item (used for sounds/feedback)
      item - the item to evaluate
      data - the source item data containing Soul Harvester config
      Returns:
      true if an upgrade was applied; false otherwise
    • addSouls

      public static Boolean addSouls(org.bukkit.inventory.ItemStack item, Integer amount)
      Adds souls to a Soul Harvester item, respecting the configured maxSouls cap.
      Parameters:
      item - the target item
      amount - the number of souls to add
      Returns:
      true if souls were added; false if the item is invalid or has no Soul Harvester
    • isPowerUnlocked

      public static boolean isPowerUnlocked(org.bukkit.entity.Player player, String id)
      Determines if any equipped item for the player has unlocked and applied the provided power ID.
      Parameters:
      player - the player to scan
      id - the power ID to check
      Returns:
      true if a matching upgrade tag is present on any relevant item; false otherwise
    • isWorldWhitelisted

      public static boolean isWorldWhitelisted(org.bukkit.World world, SoulHarvesterComponent data)