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 TypeMethodDescriptionvoid
addItems
(SlimefunItem... items) Bind the specifiedSlimefunItems
to thisResearch
.addItems
(org.bukkit.inventory.ItemStack... items) Bind the specified ItemStacks to thisResearch
.boolean
canUnlock
(org.bukkit.entity.Player p) Checks if thePlayer
can unlock thisResearch
.void
disable()
Unregisters thisResearch
.Lists everySlimefunItem
that is bound to thisResearch
.int
getCost()
Deprecated.double
int
getID()
Deprecated.org.bukkit.NamespacedKey
getKey()
int
Gets 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 aResearch
with the givenNamespacedKey
.getResearchByID
(Integer oldID) Deprecated.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) Deprecated.void
setCurrencyCost
(double currencyCost) void
setLevelCost
(int levelCost) Sets the cost in XP levels to unlock thisResearch
.toString()
void
unlock
(org.bukkit.entity.Player p, boolean instant) This unlocks thisResearch
for the givenPlayer
without any form of callback.void
Unlocks thisResearch
for the specifiedPlayer
.void
unlockFromGuide
(SlimefunGuideImplementation guide, org.bukkit.entity.Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup itemGroup, int page) Handle what to do when aPlayer
clicks on an un-researched item in aSlimefunGuideImplementation
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:
getKey
in interfaceorg.bukkit.Keyed
-
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
This method gives you a localized name for thisResearch
. The name is automatically taken from the currently selectedLanguage
of the specifiedPlayer
.- Parameters:
p
- ThePlayer
to translate this name for.- Returns:
- The localized Name of this
Research
.
-
getUnlocalizedName
Retrieve the name of thisResearch
without 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 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, org.bukkit.entity.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
public boolean canUnlock(@Nonnull org.bukkit.entity.Player p) - Parameters:
p
- ThePlayer
to check- Returns:
- Whether that
Player
can unlock thisResearch
-
unlock
public void unlock(@Nonnull org.bukkit.entity.Player p, boolean instant) This unlocks thisResearch
for the givenPlayer
without any form of callback.- Parameters:
p
- ThePlayer
who should unlock thisResearch
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 thisResearch
for the specifiedPlayer
. -
register
public void register()Registers thisResearch
. -
disable
public void disable()Unregisters thisResearch
. -
getResearch
Attempts to get aResearch
with the givenNamespacedKey
. -
getResearchByID
Deprecated. -
toString
-
getCurrencyCost
public double getCurrencyCost() -
setCurrencyCost
public void setCurrencyCost(double currencyCost)
-
getKey()
for identification instead.