Class ItemGroup
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.items.ItemGroup
- All Implemented Interfaces:
net.kyori.adventure.key.Keyed
,org.bukkit.Keyed
- Direct Known Subclasses:
FlexItemGroup
,LockedItemGroup
,SeasonalItemGroup
,SubItemGroup
Represents an item group, which structure
multiple
SlimefunItem
in the SlimefunGuide
.- Author:
- TheBusyBiscuit
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected final org.bukkit.inventory.ItemStack
protected final List
<SlimefunItem> protected final org.bukkit.NamespacedKey
protected int
-
Constructor Summary
ConstructorsConstructorDescriptionItemGroup
(org.bukkit.NamespacedKey key, org.bukkit.inventory.ItemStack item) Constructs a newItemGroup
with the givenNamespacedKey
as an identifier and the givenItemStack
as its display item.ItemGroup
(org.bukkit.NamespacedKey key, org.bukkit.inventory.ItemStack item, int tier) Constructs a newItemGroup
with the givenNamespacedKey
as an identifier and the givenItemStack
as its display item. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(SlimefunItem item) Adds the givenSlimefunItem
to thisItemGroup
.boolean
contains
(SlimefunItem item) This method returns whether a givenSlimefunItem
exists in thisItemGroup
.final boolean
final SlimefunAddon
getAddon()
This returns theSlimefunAddon
which has registered thisItemGroup
.getDisplayName
(org.bukkit.entity.Player p) This returns the localized display name of thisItemGroup
for the givenPlayer
.org.bukkit.inventory.ItemStack
getItem
(org.bukkit.entity.Player p) This method returns a localized display item of thisItemGroup
for the specifiedPlayer
.getItems()
Returns all instances ofSlimefunItem
bound to thisItemGroup
.final org.bukkit.NamespacedKey
getKey()
int
getTier()
Returns the tier of thisItemGroup
.This method makes Walshy happy.final int
hashCode()
boolean
isAccessible
(org.bukkit.entity.Player p) This method returns whether thisItemGroup
can be accessed by the givenPlayer
.boolean
Returns if items from other addons are allowed to be added to thisItemGroup
.boolean
isHidden
(org.bukkit.entity.Player p) Deprecated.boolean
This method returns whether thisItemGroup
has been registered yet.boolean
isVisible
(org.bukkit.entity.Player p) This method returns whether thisItemGroup
can be viewed by the givenPlayer
.void
register
(SlimefunAddon addon) Registers thisItemGroup
.void
remove
(SlimefunItem item) Removes the givenSlimefunItem
from thisItemGroup
.void
setCrossAddonItemGroup
(boolean crossAddonItemGroup) This method will set if thisItemGroup
will allowSlimefunItem
s from other addons to be added, without a warning, into the group.void
setTier
(int tier) This sets the tier of thisItemGroup
.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.bukkit.Keyed
key
-
Field Details
-
items
-
key
protected final org.bukkit.NamespacedKey key -
item
protected final org.bukkit.inventory.ItemStack item -
tier
protected int tier -
crossAddonItemGroup
protected boolean crossAddonItemGroup
-
-
Constructor Details
-
ItemGroup
@ParametersAreNonnullByDefault public ItemGroup(org.bukkit.NamespacedKey key, org.bukkit.inventory.ItemStack item) Constructs a newItemGroup
with the givenNamespacedKey
as an identifier and the givenItemStack
as its display item. The tier is set to a default value of3
. -
ItemGroup
@ParametersAreNonnullByDefault public ItemGroup(org.bukkit.NamespacedKey key, org.bukkit.inventory.ItemStack item, int tier) Constructs a newItemGroup
with the givenNamespacedKey
as an identifier and the givenItemStack
as its display item.- Parameters:
key
- TheNamespacedKey
that is used to identify thisItemGroup
item
- TheItemStack
that is used to display thisItemGroup
tier
- The tier of thisItemGroup
, higher tiers will make thisItemGroup
appear further down in theSlimefunGuide
-
-
Method Details
-
getKey
@Nonnull public final org.bukkit.NamespacedKey getKey()- Specified by:
getKey
in interfaceorg.bukkit.Keyed
-
register
Registers thisItemGroup
.By default, an
ItemGroup
is automatically registered when aSlimefunItem
was added to it.- Parameters:
addon
- TheSlimefunAddon
that wants to register thisItemGroup
-
isRegistered
public boolean isRegistered()This method returns whether thisItemGroup
has been registered yet. More specifically: Whetherregister(SlimefunAddon)
was called or not.- Returns:
- Whether this
ItemGroup
has been registered
-
getTier
public int getTier()Returns the tier of thisItemGroup
. The tier determines the position of thisItemGroup
in theSlimefunGuide
.- Returns:
- the tier of this
ItemGroup
-
setTier
public void setTier(int tier) This sets the tier of thisItemGroup
. The tier determines the position of thisItemGroup
in theSlimefunGuide
.- Parameters:
tier
- The tier for thisItemGroup
-
getAddon
This returns theSlimefunAddon
which has registered thisItemGroup
. Or null if it has not been registered yet.- Returns:
- The
SlimefunAddon
or null if unregistered
-
add
Adds the givenSlimefunItem
to thisItemGroup
.- Parameters:
item
- theSlimefunItem
that should be added to thisItemGroup
-
remove
Removes the givenSlimefunItem
from thisItemGroup
.- Parameters:
item
- theSlimefunItem
that should be removed from thisItemGroup
-
getItem
@Nonnull public org.bukkit.inventory.ItemStack getItem(@Nonnull org.bukkit.entity.Player p) This method returns a localized display item of thisItemGroup
for the specifiedPlayer
.- Parameters:
p
- The Player to create thisItemStack
for- Returns:
- A localized display item for this
ItemGroup
-
getUnlocalizedName
This method makes Walshy happy. It adds a way to get the name of aItemGroup
without localization nor coloring.- Returns:
- The unlocalized name of this
ItemGroup
-
getDisplayName
This returns the localized display name of thisItemGroup
for the givenPlayer
. The method will fall back togetUnlocalizedName()
if no translation was found.- Parameters:
p
- ThePlayer
who to translate the name for- Returns:
- The localized name of this
ItemGroup
-
getItems
Returns all instances ofSlimefunItem
bound to thisItemGroup
.- Returns:
- the list of SlimefunItems bound to this
ItemGroup
-
contains
This method returns whether a givenSlimefunItem
exists in thisItemGroup
.- Parameters:
item
- TheSlimefunItem
to find- Returns:
- Whether the given
SlimefunItem
was found in thisItemGroup
-
isAccessible
public boolean isAccessible(@Nonnull org.bukkit.entity.Player p) This method returns whether thisItemGroup
can be accessed by the givenPlayer
. If anItemGroup
is not accessible, it will not show up in theSlimefunGuide
nor will items from thisItemGroup
show up in the guide search.- Parameters:
p
- ThePlayer
to check for- Returns:
- Whether this
ItemGroup
is accessible by the givenPlayer
-
isVisible
public boolean isVisible(@Nonnull org.bukkit.entity.Player p) This method returns whether thisItemGroup
can be viewed by the givenPlayer
. EmptyItemGroups
will not be visible. This includesItemGroups
where everySlimefunItem
is disabled. If anItemGroup
is not accessible by thePlayer
, seeisAccessible(Player)
, this method will also return false.- Parameters:
p
- ThePlayer
to check for- Returns:
- Whether this
ItemGroup
is visible to the givenPlayer
-
isCrossAddonItemGroup
public boolean isCrossAddonItemGroup()Returns if items from other addons are allowed to be added to thisItemGroup
.- Returns:
- true if items from other addons are allowed to be added to this
ItemGroup
.
-
setCrossAddonItemGroup
public void setCrossAddonItemGroup(boolean crossAddonItemGroup) This method will set if thisItemGroup
will allowSlimefunItem
s from other addons to be added, without a warning, into the group. False by default. If set to true, Slimefun will not warn about items being added.- Parameters:
crossAddonItemGroup
- Whether items from another addon are allowable
-
equals
-
hashCode
public final int hashCode() -
toString
-
isHidden
Deprecated.This method checks whether thisItemGroup
will be hidden for the specifiedPlayer
. Categories are hidden if all of their items have been disabled.- Parameters:
p
- ThePlayer
to check for- Returns:
- Whether this
ItemGroup
will be hidden to the givenPlayer
-