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 booleanprotected final org.bukkit.inventory.ItemStackprotected final List<SlimefunItem> protected final org.bukkit.NamespacedKeyprotected int -
Constructor Summary
ConstructorsConstructorDescriptionItemGroup(org.bukkit.NamespacedKey key, org.bukkit.inventory.ItemStack item) Constructs a newItemGroupwith the givenNamespacedKeyas an identifier and the givenItemStackas its display item.ItemGroup(org.bukkit.NamespacedKey key, org.bukkit.inventory.ItemStack item, int tier) Constructs a newItemGroupwith the givenNamespacedKeyas an identifier and the givenItemStackas its display item. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(SlimefunItem item) Adds the givenSlimefunItemto thisItemGroup.booleancontains(SlimefunItem item) This method returns whether a givenSlimefunItemexists in thisItemGroup.final booleanfinal SlimefunAddongetAddon()This returns theSlimefunAddonwhich has registered thisItemGroup.getDisplayName(org.bukkit.entity.Player p) This returns the localized display name of thisItemGroupfor the givenPlayer.org.bukkit.inventory.ItemStackgetItem(org.bukkit.entity.Player p) This method returns a localized display item of thisItemGroupfor the specifiedPlayer.getItems()Returns all instances ofSlimefunItembound to thisItemGroup.final org.bukkit.NamespacedKeygetKey()intgetTier()Returns the tier of thisItemGroup.This method makes Walshy happy.final inthashCode()booleanisAccessible(org.bukkit.entity.Player p) This method returns whether thisItemGroupcan be accessed by the givenPlayer.booleanReturns if items from other addons are allowed to be added to thisItemGroup.booleanisHidden(org.bukkit.entity.Player p) Deprecated.booleanThis method returns whether thisItemGrouphas been registered yet.booleanisVisible(org.bukkit.entity.Player p) This method returns whether thisItemGroupcan be viewed by the givenPlayer.voidregister(SlimefunAddon addon) Registers thisItemGroup.voidremove(SlimefunItem item) Removes the givenSlimefunItemfrom thisItemGroup.voidsetCrossAddonItemGroup(boolean crossAddonItemGroup) This method will set if thisItemGroupwill allowSlimefunItems from other addons to be added, without a warning, into the group.voidsetTier(int tier) This sets the tier of thisItemGroup.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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 newItemGroupwith the givenNamespacedKeyas an identifier and the givenItemStackas 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 newItemGroupwith the givenNamespacedKeyas an identifier and the givenItemStackas its display item.- Parameters:
key- TheNamespacedKeythat is used to identify thisItemGroupitem- TheItemStackthat is used to display thisItemGrouptier- The tier of thisItemGroup, higher tiers will make thisItemGroupappear further down in theSlimefunGuide
-
-
Method Details
-
getKey
@Nonnull public final org.bukkit.NamespacedKey getKey()- Specified by:
getKeyin interfaceorg.bukkit.Keyed
-
register
Registers thisItemGroup.By default, an
ItemGroupis automatically registered when aSlimefunItemwas added to it.- Parameters:
addon- TheSlimefunAddonthat wants to register thisItemGroup
-
isRegistered
public boolean isRegistered()This method returns whether thisItemGrouphas been registered yet. More specifically: Whetherregister(SlimefunAddon)was called or not.- Returns:
- Whether this
ItemGrouphas been registered
-
getTier
public int getTier()Returns the tier of thisItemGroup. The tier determines the position of thisItemGroupin 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 thisItemGroupin theSlimefunGuide.- Parameters:
tier- The tier for thisItemGroup
-
getAddon
This returns theSlimefunAddonwhich has registered thisItemGroup. Or null if it has not been registered yet.- Returns:
- The
SlimefunAddonor null if unregistered
-
add
Adds the givenSlimefunItemto thisItemGroup.- Parameters:
item- theSlimefunItemthat should be added to thisItemGroup
-
remove
Removes the givenSlimefunItemfrom thisItemGroup.- Parameters:
item- theSlimefunItemthat 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 thisItemGroupfor the specifiedPlayer.- Parameters:
p- The Player to create thisItemStackfor- Returns:
- A localized display item for this
ItemGroup
-
getUnlocalizedName
This method makes Walshy happy. It adds a way to get the name of aItemGroupwithout localization nor coloring.- Returns:
- The unlocalized name of this
ItemGroup
-
getDisplayName
This returns the localized display name of thisItemGroupfor the givenPlayer. The method will fall back togetUnlocalizedName()if no translation was found.- Parameters:
p- ThePlayerwho to translate the name for- Returns:
- The localized name of this
ItemGroup
-
getItems
Returns all instances ofSlimefunItembound to thisItemGroup.- Returns:
- the list of SlimefunItems bound to this
ItemGroup
-
contains
This method returns whether a givenSlimefunItemexists in thisItemGroup.- Parameters:
item- TheSlimefunItemto find- Returns:
- Whether the given
SlimefunItemwas found in thisItemGroup
-
isAccessible
public boolean isAccessible(@Nonnull org.bukkit.entity.Player p) This method returns whether thisItemGroupcan be accessed by the givenPlayer. If anItemGroupis not accessible, it will not show up in theSlimefunGuidenor will items from thisItemGroupshow up in the guide search.- Parameters:
p- ThePlayerto check for- Returns:
- Whether this
ItemGroupis accessible by the givenPlayer
-
isVisible
public boolean isVisible(@Nonnull org.bukkit.entity.Player p) This method returns whether thisItemGroupcan be viewed by the givenPlayer. EmptyItemGroupswill not be visible. This includesItemGroupswhere everySlimefunItemis disabled. If anItemGroupis not accessible by thePlayer, seeisAccessible(Player), this method will also return false.- Parameters:
p- ThePlayerto check for- Returns:
- Whether this
ItemGroupis 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 thisItemGroupwill allowSlimefunItems 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 thisItemGroupwill be hidden for the specifiedPlayer. Categories are hidden if all of their items have been disabled.- Parameters:
p- ThePlayerto check for- Returns:
- Whether this
ItemGroupwill be hidden to the givenPlayer
-