Class BasicNeedsHandler

java.lang.Object
me.fami6xx.rpuniverse.core.basicneeds.BasicNeedsHandler

public class BasicNeedsHandler extends Object
The BasicNeedsHandler is the main class for handling the basic needs. It is responsible for adding, removing, and updating the basic needs.

The BasicNeedsHandler is a singleton class, so only one instance of it should be created.

The BasicNeedsHandler is also a listener for the PlayerJoinEvent and PlayerQuitEvent. This means that the BasicNeedsHandler will also listen for these events and update the basic needs accordingly.

  • Constructor Details

    • BasicNeedsHandler

      public BasicNeedsHandler()
  • Method Details

    • initialize

      public void initialize(RPUniverse plugin)
      Initialize the BasicNeedsHandler. Loads the consumables and starts the tasks.
      Parameters:
      plugin - The plugin instance
    • shutdown

      public void shutdown()
      Shutdown the BasicNeedsHandler. Stops the tasks and removes the consumables.
    • formatNeedForActionBar

      public static String formatNeedForActionBar(int level, boolean isPoopOrPee)
      Format the need for the action bar.
      Parameters:
      level - The level
      isPoopOrPee - true for poop or pee, false for food or water
      Returns:
      The formatted need
    • getConsumables

      public HashMap<org.bukkit.inventory.ItemStack,​ConsumableItem> getConsumables()
      Get the consumable items.
      Returns:
      the consumable items
    • addConsumable

      public void addConsumable(org.bukkit.inventory.ItemStack item, ConsumableItem consumable)
      Add a consumable item to the handler.
      Parameters:
      item - the item to add
      consumable - the consumable item
    • getConsumable

      public ConsumableItem getConsumable(org.bukkit.inventory.ItemStack item)
      Get the consumable item for the given item.
      Parameters:
      item - the item to get the consumable item for
      Returns:
      the consumable item
    • removeConsumable

      public void removeConsumable(org.bukkit.inventory.ItemStack item)
      Remove a consumable item from the handler.
      Parameters:
      item - the item to remove
    • isConsumable

      public boolean isConsumable(org.bukkit.inventory.ItemStack item)
      Check if the given item is a consumable.
      Parameters:
      item - the item to check
      Returns:
      true if the item is a consumable, false otherwise
    • getConfig

      public BasicNeedsConfig getConfig()
      Gets the basic need config.
      Returns:
      the basic needs config