Class Research
- java.lang.Object
-
- me.mrCookieSlime.Slimefun.Objects.Research
-
- All Implemented Interfaces:
Keyed
public class Research extends Object implements Keyed
Statically handles researches. Represents a research, which is bound to oneSlimefunItem
or more and require XP levels to unlock this/these item(s).- Author:
- TheBusyBiscuit
- See Also:
ResearchSetup
,ResearchUnlockEvent
-
-
Constructor Summary
Constructors Constructor Description Research(NamespacedKey key, int id, String name, int defaultCost)
The constructor for aResearch
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItems(SlimefunItem... items)
Bind the specified Slimefun items to thisResearch
.boolean
canUnlock(Player p)
List<SlimefunItem>
getAffectedItems()
Lists everySlimefunItem
that is bound to thisResearch
.static Research
getByID(int id)
Attempts to get aResearch
with the given ID.int
getCost()
Gets the cost in XP levels to unlock thisResearch
.int
getID()
Gets the ID of thisResearch
.NamespacedKey
getKey()
String
getName(Player p)
This method gives you a localized name for thisResearch
.boolean
isEnabled()
This method returns whether thisResearch
is enabled.void
register()
Registers thisResearch
.void
setCost(int cost)
Sets the cost in XP levels to unlock thisResearch
.String
toString()
void
unlock(Player p, boolean instant)
-
-
-
Constructor Detail
-
Research
public Research(NamespacedKey key, int id, String name, 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. To speed up, directly setup the research by callingSlimefun.registerResearch(Research, org.bukkit.inventory.ItemStack...)
.
-
-
Method Detail
-
getKey
public NamespacedKey getKey()
-
isEnabled
public boolean isEnabled()
This method returns whether thisResearch
is enabled.false
can mean that this particularResearch
was disabled or that researches alltogether have been disabled.- Returns:
- Whether this
Research
is enabled or not
-
getID
public int getID()
Gets the ID of thisResearch
. This is the old way of identifying Researches, use aNamespacedKey
in the future.- Returns:
- The ID of 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
public void addItems(SlimefunItem... items)
Bind the specified Slimefun items to thisResearch
.- Parameters:
items
- Instances ofSlimefunItem
to bind to thisResearch
-
getAffectedItems
public List<SlimefunItem> getAffectedItems()
Lists everySlimefunItem
that is bound to thisResearch
.- Returns:
- The Slimefun items bound to this
Research
.
-
canUnlock
public boolean canUnlock(Player p)
-
unlock
public void unlock(Player p, boolean instant)
-
register
public void register()
Registers thisResearch
.
-
getByID
public static Research getByID(int id)
Attempts to get aResearch
with the given ID. We will useNamespacedKey
for this in the future.- Parameters:
id
- ID of the research to get- Returns:
Research
if found, or null
-
-