All Implemented Interfaces:
Flippable, Orientable

public class PercentageBar extends VariableBar
A percentage bar for a graphical interface into what amount of a whole is set.
Since:
0.5.0
  • Constructor Details

    • PercentageBar

      public PercentageBar(int x, int y, int length, int height, @NotNull @NotNull Pane.Priority priority)
    • PercentageBar

      public PercentageBar(int x, int y, int length, int height)
    • PercentageBar

      public PercentageBar(int length, int height)
  • Method Details

    • click

      public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull InventoryComponent inventoryComponent, @NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight)
      Description copied from class: Pane
      Called whenever there is being clicked on this pane
      Specified by:
      click in class Pane
      Parameters:
      gui - the gui in which was clicked
      inventoryComponent - the inventory component in which this pane resides
      event - the event that occurred while clicking on this item
      slot - the slot that was clicked in
      paneOffsetX - the pane's offset on the x axis
      paneOffsetY - the pane's offset on the y axis
      maxLength - the maximum length of the pane
      maxHeight - the maximum height of the pane
      Returns:
      whether the item was found or not
    • setPercentage

      public void setPercentage(float percentage)
      Sets the percentage of this bar. The percentage has to be in (0,1). If not, this method will throw an IllegalArgumentException.
      Parameters:
      percentage - the new percentage.
      Throws:
      IllegalArgumentException - when the percentage is out of range
      Since:
      0.5.0
      See Also:
      the implementation
    • copy

      @NotNull @Contract(pure=true) public @NotNull PercentageBar copy()
      Description copied from class: Pane
      Makes a copy of this pane and returns it. This makes a deep copy of the pane. This entails that the underlying panes and/or items will be copied as well. The returned pane will never be reference equal to the current pane.
      Overrides:
      copy in class Pane
      Returns:
      a copy of this pane
    • getPercentage

      public float getPercentage()
      Gets the percentage as a float in between (0,1) this bar is currently set at.
      Returns:
      the percentage
      Since:
      0.5.0
    • load

      @NotNull @Contract(pure=true) public static @NotNull PercentageBar load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element)
      Loads a percentage bar from a given element
      Parameters:
      instance - the instance class
      element - the element
      Returns:
      the percentage bar