Class Difference

java.lang.Object
com.janboerman.invsee.spigot.api.logging.Difference

public class Difference extends Object
The Difference of a SpectatorInventoryView is the set of items that were added and removed the SpectatorInventory.
  • Constructor Details

    • Difference

      public Difference()
  • Method Details

    • getDifference

      public Map<ItemType,Integer> getDifference()
      Get the difference map. Keys represent items, values represent how many items were added to the . Negative values represent removed items.
      Returns:
      the difference map
    • isEmpty

      public boolean isEmpty()
      Get whether the difference is zero (no items added or removed).
      Returns:
      true if the difference is zero
    • merge

      public void merge(Difference other)
      Merge this difference with another: add all differences from the other Difference to this Difference.
      Parameters:
      other - the other difference
    • accumulate

      public void accumulate(ItemStack stack)
      Add an item to this difference.
      Parameters:
      stack - the item
    • accumulate

      public void accumulate(ItemType itemType, int amount)
      Add an item to this Difference.
      Parameters:
      itemType - the item
      amount - how many of the item
    • calculate

      public static Difference calculate(List<ItemStack> before, List<ItemStack> after)
      Calculate the Difference from a 'before' and 'after' view of a list of items.
      Parameters:
      before - the 'before' view
      after - the 'after' view
      Returns:
      the difference