Class Research
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.researches.Research
- All Implemented Interfaces:
Keyed
Represents a research, which is bound to one
SlimefunItem or more and requires XP levels to unlock said item(s).- Author:
- TheBusyBiscuit
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionResearch(NamespacedKey key, int id, String defaultName, int defaultCost) The constructor for aResearch. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddItems(SlimefunItem... items) Bind the specifiedSlimefunItemsto thisResearch.Bind the specified ItemStacks to thisResearch.booleanLists everySlimefunItemthat is bound to thisResearch.intgetCost()Gets the cost in XP levels to unlock thisResearch.intgetID()Deprecated.getKey()This method gives you a localized name for thisResearch.getResearch(NamespacedKey key) Attempts to get aResearchwith the givenNamespacedKey.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) Sets the cost in XP levels to unlock thisResearch.toString()voidvoidvoidunlockFromGuide(SlimefunGuideImplementation guide, Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup itemGroup, int page) Handle what to do when aPlayerclicks on an un-researched item in aSlimefunGuideImplementation.
-
Constructor Details
-
Research
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
-
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
-
getUnlocalizedName
Retrieve the name of thisResearchwithout any localization nor coloring.- Returns:
- The unlocalized, decolorized name for this
Research
-
getCost
public int getCost()Gets the cost in XP levels to unlock thisResearch.- Returns:
- The cost in XP levels for this
Research
-
setCost
public void setCost(int cost) Sets the cost in XP levels to unlock thisResearch.- Parameters:
cost- 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, 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
-
unlock
-
unlock
-
register
public void register()Registers thisResearch. -
getResearch
Attempts to get aResearchwith the givenNamespacedKey.- Parameters:
key- theNamespacedKeyof theResearchyou are looking for- Returns:
- An
Optionalwith or without the foundResearch
-
toString
-
getKey()for identification instead.