Package me.mrCookieSlime.Slimefun.api
Class Slimefun
- java.lang.Object
-
- me.mrCookieSlime.Slimefun.api.Slimefun
-
public final class Slimefun extends Object
Provides a few convenience methods.- Since:
- 4.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static List<GuideHandler>
getGuideHandlers(int tier)
Deprecated.static io.github.thebusybiscuit.cscorelib2.config.Config
getItemConfig()
Returns the Config instance of Items.yml file.static Object
getItemValue(String id, String key)
Returns the value associated to this key for the SlimefunItem corresponding to this id.static Logger
getLogger()
static boolean
hasPermission(Player p, SlimefunItem item, boolean message)
Checks if this player has the permission to use this item.static boolean
hasUnlocked(Player p, SlimefunItem sfItem, boolean message)
Checks if this player can use this item.static boolean
hasUnlocked(Player p, ItemStack item, boolean message)
Checks if this player can use this item.static boolean
isEnabled(Player p, SlimefunItem sfItem, boolean message)
Checks if this item is enabled in the world this player is in.static boolean
isEnabled(Player p, ItemStack item, boolean message)
Checks if this item is enabled in the world this player is in.static void
registerGuideHandler(GuideHandler handler)
Deprecated.static void
registerResearch(Research research, ItemStack... items)
Registers this Research and automatically binds these ItemStacks to it.static void
registerResearch(NamespacedKey key, int id, String name, int cost, ItemStack... items)
static BukkitTask
runSync(Runnable r)
static BukkitTask
runSync(Runnable r, long delay)
static void
setItemVariable(String id, String key, Object value)
Sets a default value associated to this key for the SlimefunItem corresponding to this id.
-
-
-
Method Detail
-
registerGuideHandler
@Deprecated public static void registerGuideHandler(GuideHandler handler)
Deprecated.
-
getLogger
public static Logger getLogger()
-
getItemValue
public static Object getItemValue(String id, String key)
Returns the value associated to this key for the SlimefunItem corresponding to this id.- Parameters:
id
- the id of the SlimefunItem, not nullkey
- the key of the value to get, not null- Returns:
- the value associated to the key for the SlimefunItem corresponding to the id, or null if it doesn't exist.
-
setItemVariable
public static void setItemVariable(String id, String key, Object value)
Sets a default value associated to this key for the SlimefunItem corresponding to this id.- Parameters:
id
- the id of the SlimefunItem, not nullkey
- the key of the value to set, not nullvalue
- the value to set, can be null
-
getItemConfig
public static io.github.thebusybiscuit.cscorelib2.config.Config getItemConfig()
Returns the Config instance of Items.yml file.It calls
SlimefunStartup#getItemCfg()
.- Returns:
- the Items.yml Config instance.
-
registerResearch
public static void registerResearch(Research research, ItemStack... items)
Registers this Research and automatically binds these ItemStacks to it.This convenience method spares from doing the code below:
Research r = new Research(7, "Glowstone Armor", 3); r.addItems(SlimefunItem.getByItem(SlimefunItems.GLOWSTONE_HELMET), SlimefunItem.getByItem(SlimefunItems.GLOWSTONE_CHESTPLATE), SlimefunItem.getByItem(SlimefunItems.GLOWSTONE_LEGGINGS), SlimefunItem.getByItem(SlimefunItems.GLOWSTONE_BOOTS)); r.register();
*- Parameters:
research
- the research to register, not nullitems
- the items to bind, not null
-
registerResearch
public static void registerResearch(NamespacedKey key, int id, String name, int cost, ItemStack... items)
-
hasUnlocked
public static boolean hasUnlocked(Player p, ItemStack item, boolean message)
Checks if this player can use this item.- Parameters:
p
- the player to check, not nullitem
- the item to check, not nullmessage
- whether a message should be sent to the player or not- Returns:
true
if the item is a SlimefunItem, enabled, researched and if the player has the permission to use it,false
otherwise.
-
hasUnlocked
public static boolean hasUnlocked(Player p, SlimefunItem sfItem, boolean message)
Checks if this player can use this item.- Parameters:
p
- the player to check, not nullsfItem
- the item to check, not nullmessage
- whether a message should be sent to the player or not- Returns:
true
if the item is enabled, researched and the player has the permission to use it,false
otherwise.
-
hasPermission
public static boolean hasPermission(Player p, SlimefunItem item, boolean message)
Checks if this player has the permission to use this item.- Parameters:
p
- the player to check, not nullitem
- the item to check, null returnstrue
message
- whether a message should be sent to the player or not- Returns:
true
if the item is not null and if the player has the permission to use it,false
otherwise.
-
isEnabled
public static boolean isEnabled(Player p, ItemStack item, boolean message)
Checks if this item is enabled in the world this player is in.- Parameters:
p
- the player to get the world he is in, not nullitem
- the item to check, not nullmessage
- whether a message should be sent to the player or not- Returns:
true
if the item is a SlimefunItem and is enabled in the world the player is in,false
otherwise.
-
isEnabled
public static boolean isEnabled(Player p, SlimefunItem sfItem, boolean message)
Checks if this item is enabled in the world this player is in.- Parameters:
p
- the player to get the world he is in, not nullsfItem
- the item to check, not nullmessage
- whether a message should be sent to the player or not- Returns:
true
if the item is enabled in the world the player is in,false
otherwise.
-
getGuideHandlers
@Deprecated public static List<GuideHandler> getGuideHandlers(int tier)
Deprecated.
-
runSync
public static BukkitTask runSync(Runnable r)
-
runSync
public static BukkitTask runSync(Runnable r, long delay)
-
-