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

public class ItemGroup extends Object implements org.bukkit.Keyed
Represents an item group, which structure multiple SlimefunItem in the SlimefunGuide.
Author:
TheBusyBiscuit
See Also:
  • Field Details

    • items

      protected final List<SlimefunItem> 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 new ItemGroup with the given NamespacedKey as an identifier and the given ItemStack as its display item. The tier is set to a default value of 3.
      Parameters:
      key - The NamespacedKey that is used to identify this ItemGroup
      item - The ItemStack that is used to display this ItemGroup
    • ItemGroup

      @ParametersAreNonnullByDefault public ItemGroup(org.bukkit.NamespacedKey key, org.bukkit.inventory.ItemStack item, int tier)
      Constructs a new ItemGroup with the given NamespacedKey as an identifier and the given ItemStack as its display item.
      Parameters:
      key - The NamespacedKey that is used to identify this ItemGroup
      item - The ItemStack that is used to display this ItemGroup
      tier - The tier of this ItemGroup, higher tiers will make this ItemGroup appear further down in the SlimefunGuide
  • Method Details

    • getKey

      @Nonnull public final org.bukkit.NamespacedKey getKey()
      Specified by:
      getKey in interface org.bukkit.Keyed
    • register

      public void register(@Nonnull SlimefunAddon addon)
      Registers this ItemGroup.

      By default, an ItemGroup is automatically registered when a SlimefunItem was added to it.

      Parameters:
      addon - The SlimefunAddon that wants to register this ItemGroup
    • isRegistered

      public boolean isRegistered()
      This method returns whether this ItemGroup has been registered yet. More specifically: Whether register(SlimefunAddon) was called or not.
      Returns:
      Whether this ItemGroup has been registered
    • getTier

      public int getTier()
      Returns the tier of this ItemGroup. The tier determines the position of this ItemGroup in the SlimefunGuide.
      Returns:
      the tier of this ItemGroup
    • setTier

      public void setTier(int tier)
      This sets the tier of this ItemGroup. The tier determines the position of this ItemGroup in the SlimefunGuide.
      Parameters:
      tier - The tier for this ItemGroup
    • getAddon

      @Nullable public final SlimefunAddon getAddon()
      This returns the SlimefunAddon which has registered this ItemGroup. Or null if it has not been registered yet.
      Returns:
      The SlimefunAddon or null if unregistered
    • add

      public void add(@Nonnull SlimefunItem item)
      Adds the given SlimefunItem to this ItemGroup.
      Parameters:
      item - the SlimefunItem that should be added to this ItemGroup
    • remove

      public void remove(@Nonnull SlimefunItem item)
      Removes the given SlimefunItem from this ItemGroup.
      Parameters:
      item - the SlimefunItem that should be removed from this ItemGroup
    • getItem

      @Nonnull public org.bukkit.inventory.ItemStack getItem(@Nonnull org.bukkit.entity.Player p)
      This method returns a localized display item of this ItemGroup for the specified Player.
      Parameters:
      p - The Player to create this ItemStack for
      Returns:
      A localized display item for this ItemGroup
    • getUnlocalizedName

      @Nonnull public String getUnlocalizedName()
      This method makes Walshy happy. It adds a way to get the name of a ItemGroup without localization nor coloring.
      Returns:
      The unlocalized name of this ItemGroup
    • getDisplayName

      @Nonnull public String getDisplayName(@Nonnull org.bukkit.entity.Player p)
      This returns the localized display name of this ItemGroup for the given Player. The method will fall back to getUnlocalizedName() if no translation was found.
      Parameters:
      p - The Player who to translate the name for
      Returns:
      The localized name of this ItemGroup
    • getItems

      @Nonnull public List<SlimefunItem> getItems()
      Returns all instances of SlimefunItem bound to this ItemGroup.
      Returns:
      the list of SlimefunItems bound to this ItemGroup
    • contains

      public boolean contains(@Nullable SlimefunItem item)
      This method returns whether a given SlimefunItem exists in this ItemGroup.
      Parameters:
      item - The SlimefunItem to find
      Returns:
      Whether the given SlimefunItem was found in this ItemGroup
    • isAccessible

      public boolean isAccessible(@Nonnull org.bukkit.entity.Player p)
      This method returns whether this ItemGroup can be accessed by the given Player. If an ItemGroup is not accessible, it will not show up in the SlimefunGuide nor will items from this ItemGroup show up in the guide search.
      Parameters:
      p - The Player to check for
      Returns:
      Whether this ItemGroup is accessible by the given Player
    • isVisible

      public boolean isVisible(@Nonnull org.bukkit.entity.Player p)
      This method returns whether this ItemGroup can be viewed by the given Player. Empty ItemGroups will not be visible. This includes ItemGroups where every SlimefunItem is disabled. If an ItemGroup is not accessible by the Player, see isAccessible(Player), this method will also return false.
      Parameters:
      p - The Player to check for
      Returns:
      Whether this ItemGroup is visible to the given Player
    • isCrossAddonItemGroup

      public boolean isCrossAddonItemGroup()
      Returns if items from other addons are allowed to be added to this ItemGroup.
      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 this ItemGroup will allow SlimefunItems 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

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isHidden

      @Deprecated public boolean isHidden(@Nonnull org.bukkit.entity.Player p)
      Deprecated.
      This method checks whether this ItemGroup will be hidden for the specified Player. Categories are hidden if all of their items have been disabled.
      Parameters:
      p - The Player to check for
      Returns:
      Whether this ItemGroup will be hidden to the given Player