Class Research
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.researches.Research
- All Implemented Interfaces:
net.kyori.adventure.key.Keyed,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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddItems(SlimefunItem... items) Bind the specifiedSlimefunItemsto thisResearch.addItems(org.bukkit.inventory.ItemStack... items) Bind the specified ItemStacks to thisResearch.booleancanUnlock(org.bukkit.entity.Player p) Checks if thePlayercan unlock thisResearch.voiddisable()Unregisters thisResearch.Lists everySlimefunItemthat is bound to thisResearch.intgetCost()Deprecated.doubleintgetID()Deprecated.org.bukkit.NamespacedKeygetKey()intGets the cost in XP levels to unlock thisResearch.getName(org.bukkit.entity.Player p) This method gives you a localized name for thisResearch.getResearch(org.bukkit.NamespacedKey key) Attempts to get aResearchwith the givenNamespacedKey.getResearchByID(Integer oldID) Deprecated.Retrieve the name of thisResearchwithout any localization nor coloring.booleanThis method checks whether there is at least one enabledSlimefunItemincluded in thisResearch.booleanThis method returns whether thisResearchis enabled.voidregister()Registers thisResearch.voidsetCost(int cost) Deprecated.voidsetCurrencyCost(double currencyCost) voidsetLevelCost(int levelCost) Sets the cost in XP levels to unlock thisResearch.toString()voidunlock(org.bukkit.entity.Player p, boolean instant) This unlocks thisResearchfor the givenPlayerwithout any form of callback.voidUnlocks thisResearchfor the specifiedPlayer.voidunlockFromGuide(SlimefunGuideImplementation guide, org.bukkit.entity.Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup itemGroup, int page) Handle what to do when aPlayerclicks on an un-researched item in aSlimefunGuideImplementation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bukkit.Keyed
key
-
Constructor Details
-
Research
public Research(@Nonnull org.bukkit.NamespacedKey key, int id, @Nonnull String defaultName, int levelCost, double currencyCost) The constructor for aResearch. Create a new research, then bind this research to the Slimefun items you want by callingaddItems(SlimefunItem...). Once you're finished, callregister()to register it. -
Research
public Research(@Nonnull org.bukkit.NamespacedKey key, int id, @Nonnull String defaultName, int defaultCost) The constructor for aResearch. Create a new research, then bind this research to the Slimefun items you want by callingaddItems(SlimefunItem...). Once you're finished, callregister()to register it.
-
-
Method Details
-
getKey
@Nonnull public org.bukkit.NamespacedKey getKey()- Specified by:
getKeyin interfaceorg.bukkit.Keyed
-
isEnabled
public boolean isEnabled()This method returns whether thisResearchis enabled.falsecan mean that this particularResearchwas disabled or that researches altogether have been disabled.- Returns:
- Whether this
Researchis enabled or not
-
getID
Deprecated.Numeric Ids for Researches are deprecated, usegetKey()for identification instead.Gets the ID of thisResearch. This is the old way of identifying Researches, use aNamespacedKeyin the future.- Returns:
- The ID of this
Research
-
getName
This method gives you a localized name for thisResearch. The name is automatically taken from the currently selectedLanguageof the specifiedPlayer.- Parameters:
p- ThePlayerto translate this name for.- Returns:
- The localized Name of this
Research.
-
getUnlocalizedName
Retrieve the name of thisResearchwithout any localization nor coloring.- Returns:
- The unlocalized, decolorized name for this
Research
-
getCost
Deprecated.Gets the cost in XP levels to unlock thisResearch. Deprecated, usegetLevelCost()instead.- Returns:
- The cost in XP levels for this
Research
-
getLevelCost
public int getLevelCost()Gets the cost in XP levels to unlock thisResearch.- Returns:
- The cost in XP levels for this
Research
-
setCost
Deprecated.Sets the cost in XP levels to unlock thisResearch. Deprecated, usesetLevelCost(int)instead.- Parameters:
cost- The cost in XP levels
-
setLevelCost
public void setLevelCost(int levelCost) Sets the cost in XP levels to unlock thisResearch.- Parameters:
levelCost- The cost in XP levels
-
addItems
Bind the specifiedSlimefunItemsto thisResearch.- Parameters:
items- Instances ofSlimefunItemto bind to thisResearch
-
addItems
Bind the specified ItemStacks to thisResearch. -
getAffectedItems
Lists everySlimefunItemthat is bound to thisResearch.- Returns:
- The Slimefun items bound to this
Research.
-
hasEnabledItems
public boolean hasEnabledItems()This method checks whether there is at least one enabledSlimefunItemincluded in thisResearch.- Returns:
- whether there is at least one enabled
SlimefunItemincluded in thisResearch.
-
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 aPlayerclicks on an un-researched item in aSlimefunGuideImplementation.- Parameters:
guide- TheSlimefunGuideImplementationused.player- ThePlayerwho clicked on the item.profile- ThePlayerProfileof thatPlayer.sfItem- TheSlimefunItemon which thePlayerclicked.itemGroup- TheItemGroupwhere thePlayerwas.page- The page number of where thePlayerwas in theItemGroup;
-
canUnlock
public boolean canUnlock(@Nonnull org.bukkit.entity.Player p) - Parameters:
p- ThePlayerto check- Returns:
- Whether that
Playercan unlock thisResearch
-
unlock
public void unlock(@Nonnull org.bukkit.entity.Player p, boolean instant) This unlocks thisResearchfor the givenPlayerwithout any form of callback.- Parameters:
p- ThePlayerwho should unlock thisResearchinstant- 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 thisResearchfor the specifiedPlayer. -
register
public void register()Registers thisResearch. -
disable
public void disable()Unregisters thisResearch. -
getResearch
Attempts to get aResearchwith the givenNamespacedKey. -
getResearchByID
Deprecated. -
toString
-
getCurrencyCost
public double getCurrencyCost() -
setCurrencyCost
public void setCurrencyCost(double currencyCost)
-
getKey()for identification instead.