java.lang.Object
io.github.thebusybiscuit.slimefun4.api.researches.Research
All Implemented Interfaces:
net.kyori.adventure.key.Keyed, org.bukkit.Keyed

public class Research extends Object implements org.bukkit.Keyed
Represents a research, which is bound to one SlimefunItem or more and requires XP levels/In-game economy to unlock said item(s).
Author:
TheBusyBiscuit
See Also:
  • Constructor Details

    • Research

      public Research(@Nonnull org.bukkit.NamespacedKey key, int id, @Nonnull String defaultName, int levelCost, double currencyCost)
      The constructor for a Research. Create a new research, then bind this research to the Slimefun items you want by calling addItems(SlimefunItem...). Once you're finished, call register() to register it.
      Parameters:
      key - A unique identifier for this Research
      id - old way of identifying researches
      defaultName - The displayed name of this Research
      levelCost - The Cost in XP levels to unlock this Research
      currencyCost - The Cost in economy to unlock this Research
    • Research

      public Research(@Nonnull org.bukkit.NamespacedKey key, int id, @Nonnull String defaultName, int defaultCost)
      The constructor for a Research. Create a new research, then bind this research to the Slimefun items you want by calling addItems(SlimefunItem...). Once you're finished, call register() to register it.
      Parameters:
      key - A unique identifier for this Research
      id - old way of identifying researches
      defaultName - The displayed name of this Research
      defaultCost - The Cost in XP levels to unlock this Research
  • Method Details

    • getKey

      @Nonnull public org.bukkit.NamespacedKey getKey()
      Specified by:
      getKey in interface org.bukkit.Keyed
    • isEnabled

      public boolean isEnabled()
      This method returns whether this Research is enabled. false can mean that this particular Research was disabled or that researches altogether have been disabled.
      Returns:
      Whether this Research is enabled or not
    • getID

      @Deprecated public int getID()
      Deprecated.
      Numeric Ids for Researches are deprecated, use getKey() for identification instead.
      Gets the ID of this Research. This is the old way of identifying Researches, use a NamespacedKey in the future.
      Returns:
      The ID of this Research
    • getName

      @Nonnull public String getName(@Nonnull org.bukkit.entity.Player p)
      This method gives you a localized name for this Research. The name is automatically taken from the currently selected Language of the specified Player.
      Parameters:
      p - The Player to translate this name for.
      Returns:
      The localized Name of this Research.
    • getUnlocalizedName

      @Nonnull public String getUnlocalizedName()
      Retrieve the name of this Research without any localization nor coloring.
      Returns:
      The unlocalized, decolorized name for this Research
    • getCost

      @Deprecated public int getCost()
      Deprecated.
      Gets the cost in XP levels to unlock this Research. Deprecated, use getLevelCost() instead.
      Returns:
      The cost in XP levels for this Research
    • getLevelCost

      public int getLevelCost()
      Gets the cost in XP levels to unlock this Research.
      Returns:
      The cost in XP levels for this Research
    • setCost

      @Deprecated public void setCost(int cost)
      Deprecated.
      Sets the cost in XP levels to unlock this Research. Deprecated, use setLevelCost(int) instead.
      Parameters:
      cost - The cost in XP levels
    • setLevelCost

      public void setLevelCost(int levelCost)
      Sets the cost in XP levels to unlock this Research.
      Parameters:
      levelCost - The cost in XP levels
    • addItems

      public void addItems(SlimefunItem... items)
      Bind the specified SlimefunItems to this Research.
      Parameters:
      items - Instances of SlimefunItem to bind to this Research
    • addItems

      @Nonnull public Research addItems(org.bukkit.inventory.ItemStack... items)
      Bind the specified ItemStacks to this Research.
      Parameters:
      items - Instances of ItemStack to bind to this Research
      Returns:
      The current instance of Research
    • getAffectedItems

      @Nonnull public List<SlimefunItem> getAffectedItems()
      Lists every SlimefunItem that is bound to this Research.
      Returns:
      The Slimefun items bound to this Research.
    • hasEnabledItems

      public boolean hasEnabledItems()
      This method checks whether there is at least one enabled SlimefunItem included in this Research.
      Returns:
      whether there is at least one enabled SlimefunItem included in this Research.
    • unlockFromGuide

      @ParametersAreNonnullByDefault public void unlockFromGuide(SlimefunGuideImplementation guide, org.bukkit.entity.Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup itemGroup, int page)
      Handle what to do when a Player clicks on an un-researched item in a SlimefunGuideImplementation.
      Parameters:
      guide - The SlimefunGuideImplementation used.
      player - The Player who clicked on the item.
      profile - The PlayerProfile of that Player.
      sfItem - The SlimefunItem on which the Player clicked.
      itemGroup - The ItemGroup where the Player was.
      page - The page number of where the Player was in the ItemGroup;
    • canUnlock

      public boolean canUnlock(@Nonnull org.bukkit.entity.Player p)
      Checks if the Player can unlock this Research.

      已魔改支持 Vault

      Parameters:
      p - The Player to check
      Returns:
      Whether that Player can unlock this Research
    • unlock

      public void unlock(@Nonnull org.bukkit.entity.Player p, boolean instant)
      This unlocks this Research for the given Player without any form of callback.
      Parameters:
      p - The Player who should unlock this Research
      instant - Whether to unlock it instantly
    • unlock

      public void unlock(@Nonnull org.bukkit.entity.Player p, boolean isInstant, @Nullable Consumer<org.bukkit.entity.Player> callback)
      Unlocks this Research for the specified Player.
      Parameters:
      p - The Player for which to unlock this Research
      isInstant - Whether to unlock this Research instantly
      callback - A callback which will be run when the Research animation completed
    • register

      public void register()
      Registers this Research.
    • disable

      public void disable()
      Unregisters this Research.
    • getResearch

      @Nonnull public static Optional<Research> getResearch(@Nullable org.bukkit.NamespacedKey key)
      Attempts to get a Research with the given NamespacedKey.
      Parameters:
      key - the NamespacedKey of the Research you are looking for
      Returns:
      An Optional with or without the found Research
    • getResearchByID

      @Deprecated public static Optional<Research> getResearchByID(@Nonnull Integer oldID)
      Deprecated.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getCurrencyCost

      public double getCurrencyCost()
    • setCurrencyCost

      public void setCurrencyCost(double currencyCost)