Interface SpecialItem
public interface SpecialItem
Represents the type of a SpecialItem and not one for every given item to the player.
Meaning there's only one global instance of every type.
Use GameAPI.registerSpecialItem(String, Plugin, String, ItemStack)
to initiate a new one.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the handler that's been called whenever someone uses an item
UsesDeadSpecialItemUseHandler
as the default onegetId()
Returns the id that's being used in e.g.Returns the item that the player will receive once he purchases the item.Returns a set with every listener that has been registered to this special itemdefault String
getName()
Same asgetName(CommandSender)
, but uses the default languagegetName
(@Nullable CommandSender sender) Returns the name of this item in the language of the given sender.
If sender is null then it'll use the default language insteadReturns the original ItemStack that's being passed during initiation.Returns the plugin that created the itemgetType()
Returns the type to make it easier for you to differentiate itdefault boolean
Returns whether or not this item has been registered usingGameAPI.registerSpecialItem(SpecialItem)
boolean
isSpecialItem
(ItemStack itemStack) Returns whether or not the givenItemStack
is running this SpecialItem when used.boolean
registerListener
(SpecialItemListener listener) Adds an listener to handle events of this special item
You should use theSpecialItemAdapter
as more things might get added in the futurevoid
setHandler
(SpecialItemUseHandler handler) Set the handler that's been called whenever someone uses the item
Plugins should use this rather thanregisterListener(SpecialItemListener)
as it's providing a useful APIboolean
unregisterListener
(SpecialItemListener listener) Removes the listener and stops it from receiving any future events
-
Method Details
-
getType
SpecialItemType getType()Returns the type to make it easier for you to differentiate it- Returns:
- The type of this special item
-
getId
String getId()Returns the id that's being used in e.g. the shop config- Returns:
- The id of this item
-
getName
Same asgetName(CommandSender)
, but uses the default language- Returns:
- The name of the item in the default language
-
getName
Returns the name of this item in the language of the given sender.
If sender is null then it'll use the default language instead- Parameters:
sender
- The person from which it should look up the language. Null if it should take the default language- Returns:
- The name of the item in the language of the sender
-
getItemStack
ItemStack getItemStack()Returns the item that the player will receive once he purchases the item.Keep in mind that this is not the original ItemStack. The plugin may add its own tags to make it unique and more identifiable from others. Use
getOriginalItemStack()
if you look to obtain the original one.- Returns:
- The ItemStack of the item that's useable ingame
-
getOriginalItemStack
ItemStack getOriginalItemStack()Returns the original ItemStack that's being passed during initiation.The returned ItemStack is not usable ingame. Use
getItemStack()
instead if that's what you're looking for.- Returns:
- The original, non-modified ItemStack
-
isSpecialItem
Returns whether or not the givenItemStack
is running this SpecialItem when used.- Returns:
true
if it's the one for this SpecialItem. Otherwisefalse
-
getPlugin
Plugin getPlugin()Returns the plugin that created the item- Returns:
- The plugin that created this special item
-
getHandler
SpecialItemUseHandler getHandler()Returns the handler that's been called whenever someone uses an item
UsesDeadSpecialItemUseHandler
as the default one- Returns:
- The use handler of the special item
-
setHandler
Set the handler that's been called whenever someone uses the item
Plugins should use this rather thanregisterListener(SpecialItemListener)
as it's providing a useful API- Parameters:
handler
- The new use handler
-
registerListener
Adds an listener to handle events of this special item
You should use theSpecialItemAdapter
as more things might get added in the future- Parameters:
listener
- The listener that shall be added- Returns:
false
if the listener has already been registered
-
unregisterListener
Removes the listener and stops it from receiving any future events- Parameters:
listener
- The listener that shall be removed- Returns:
true
if it has been successfully removed
-
getListeners
Set<SpecialItemListener> getListeners()Returns a set with every listener that has been registered to this special item- Returns:
- A set with all listeners
-
isRegistered
default boolean isRegistered()Returns whether or not this item has been registered usingGameAPI.registerSpecialItem(SpecialItem)
- Returns:
- Whether or not this item is registered
-