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
ConstructorDescriptionResearch
(NamespacedKey key, int id, String defaultName, int defaultCost) The constructor for aResearch
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addItems
(SlimefunItem... items) Bind the specifiedSlimefunItems
to thisResearch
.Bind the specified ItemStacks to thisResearch
.boolean
Lists everySlimefunItem
that is bound to thisResearch
.int
getCost()
Gets the cost in XP levels to unlock thisResearch
.int
getID()
Deprecated.getKey()
This method gives you a localized name for thisResearch
.getResearch
(NamespacedKey key) Attempts to get aResearch
with the givenNamespacedKey
.Retrieve the name of thisResearch
without any localization nor coloring.boolean
This method checks whether there is at least one enabledSlimefunItem
included in thisResearch
.boolean
This method returns whether thisResearch
is enabled.void
register()
Registers thisResearch
.void
setCost
(int cost) Sets the cost in XP levels to unlock thisResearch
.toString()
void
void
void
unlockFromGuide
(SlimefunGuideImplementation guide, Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup itemGroup, int page) Handle what to do when aPlayer
clicks 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 thisResearch
is enabled.false
can mean that this particularResearch
was disabled or that researches altogether have been disabled.- Returns:
- Whether this
Research
is 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 aNamespacedKey
in the future.- Returns:
- The ID of this
Research
-
getName
-
getUnlocalizedName
Retrieve the name of thisResearch
without 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 specifiedSlimefunItems
to thisResearch
.- Parameters:
items
- Instances ofSlimefunItem
to bind to thisResearch
-
addItems
Bind the specified ItemStacks to thisResearch
. -
getAffectedItems
Lists everySlimefunItem
that 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 enabledSlimefunItem
included in thisResearch
.- Returns:
- whether there is at least one enabled
SlimefunItem
included in thisResearch
.
-
unlockFromGuide
@ParametersAreNonnullByDefault public void unlockFromGuide(SlimefunGuideImplementation guide, Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup itemGroup, int page) Handle what to do when aPlayer
clicks on an un-researched item in aSlimefunGuideImplementation
.- Parameters:
guide
- TheSlimefunGuideImplementation
used.player
- ThePlayer
who clicked on the item.profile
- ThePlayerProfile
of thatPlayer
.sfItem
- TheSlimefunItem
on which thePlayer
clicked.itemGroup
- TheItemGroup
where thePlayer
was.page
- The page number of where thePlayer
was in theItemGroup
;
-
canUnlock
-
unlock
-
unlock
-
register
public void register()Registers thisResearch
. -
getResearch
Attempts to get aResearch
with the givenNamespacedKey
.- Parameters:
key
- theNamespacedKey
of theResearch
you are looking for- Returns:
- An
Optional
with or without the foundResearch
-
toString
-
getKey()
for identification instead.