Class ItemStackBuilder.Unsafe

java.lang.Object
de.maxbossing.maxapi.Builders.ItemStackBuilder.Unsafe
Enclosing class:
ItemStackBuilder

public class ItemStackBuilder.Unsafe extends Object
A class containing sensitive NMS code for manipulating NBT data on an item stack. Use with caution as this code is highly sensitive and can break the ItemStackBuilder if used improperly.
  • Field Details

  • Constructor Details

    • Unsafe

      public Unsafe(ItemStackBuilder builder)
      Initializes the Unsafe class with an ItemStackBuilder.
      Parameters:
      builder - the ItemStackBuilder to initialize the Unsafe class with
  • Method Details

    • setString

      public ItemStackBuilder.Unsafe setString(String key, String value)
      Sets a NBT tag string into the NBT tag compound of the item.
      Parameters:
      key - the name to save the NBT tag under
      value - the value to save
      Returns:
      the current Unsafe instance
    • getString

      public String getString(String key)
      Returns the string saved under the specified key.
      Parameters:
      key - the key to retrieve the string from
      Returns:
      the string saved under the key, or null if not found
    • setInt

      public ItemStackBuilder.Unsafe setInt(String key, int value)
      Sets a NBT tag integer into the NBT tag compound of the item.
      Parameters:
      key - the name to save the NBT tag under
      value - the value to save
      Returns:
      the current Unsafe instance
    • getInt

      public int getInt(String key)
      returns the Integer under the current Key
      Parameters:
      key - the nbt tag name
      Returns:
      int
    • setDouble

      public ItemStackBuilder.Unsafe setDouble(String key, double value)
      Sets a NBT tag double into the NBT tag compound of the item.
      Parameters:
      key - the name to save the NBT tag under
      value - the value to save
      Returns:
      the current Unsafe instance
    • getDouble

      public double getDouble(String key)
      Returns the double saved under the specified key.
      Parameters:
      key - the key to retrieve the double from
      Returns:
      the double saved under the key, or 0 if not found
    • setBoolean

      public ItemStackBuilder.Unsafe setBoolean(String key, boolean value)
      Sets a NBT tag boolean into the NBT tag compound of the item.
      Parameters:
      key - the name to save the NBT tag under
      value - the value to save
      Returns:
      the current Unsafe instance
    • getBoolean

      public boolean getBoolean(String key)
      Returns the boolean saved under the specified key.
      Parameters:
      key - the key to retrieve the boolean from
      Returns:
      the boolean saved under the key, or false if not found
    • containsKey

      public boolean containsKey(String key)
      Returns whether the item has an NBT tag saved under the specified key.
      Parameters:
      key - the key to check
      Returns:
      true if the item has an NBT tag saved under the key, false otherwise
    • builder

      public ItemStackBuilder builder()
      Returns the ItemStackBuilder instance associated with this Unsafe instance.
      Returns:
      the ItemStackBuilder instance