Class DexterityDisplay

java.lang.Object
me.c7dev.dexterity.displays.DexterityDisplay

public class DexterityDisplay extends Object
Defines a selection of DexBlock, possibly with a saved display label or sub-displays
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes an empty selection.
    DexterityDisplay(Dexterity plugin, org.bukkit.Location center, org.bukkit.util.Vector scale)
    Initializes a selection
    DexterityDisplay(Dexterity plugin, org.bukkit.Location center, org.bukkit.util.Vector scale, String label)
    Initializes a new saved display with a unique label
    DexterityDisplay(Dexterity plugin, org.bukkit.Location center, org.bukkit.util.Vector scale, String label, List<org.bukkit.OfflinePlayer> owners)
    Initializes a new saved display with a unique label
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Registers a new animation type, as long as no animation type was already registered to this display
    void
    Adds a DexBlock to the selection.
    void
    Adds a command to run when display is clicked
    void
    addOwner(org.bukkit.OfflinePlayer p)
    Appends a player who can edit this display
    void
     
    void
    Teleport the selection so that its corner aligns with the nearest whole block
    void
    align(boolean toCenter)
    Teleport the selection so that its corner or center aligns with the nearest whole block
    void
    align(boolean toCenter, boolean x, boolean y, boolean z)
    Teleport the selection so that its corner or center aligns with the nearest whole block along a certain axis of movement
    boolean
    Checks whether it is appropriate to merge this display with another to form one display
    void
    consolidate(int axis, Mask m)
    Deprecated.
    void
    Consolidate along all axes to reduce the number of entities where possible without altering the selection's shape
    void
    Consolidate along all axes to reduce the number of entities where possible without altering the selection's shape
    boolean
    Determines if passed in display is this or any descendant display node
    void
    Remove the display but drop it as an item if an item has been defined
    boolean
     
    getAnimation(Class<?> clazz)
    Retrieves a registered animation type if it exists
    int
     
    Retrieves a list of DexBlock that can be iterated over
    int
     
    org.bukkit.util.BoundingBox
     
    org.bukkit.Location
    Retrieves the center of the display
    int
    Retrieves the size of the command list
    Retrieves a list of commands to run when display is clicked
    org.bukkit.inventory.ItemStack
    Gets a copy of the item that will be dropped when the player breaks the display
     
    Retrieve the UUID of the offline player who has this display in editing lock
    int
    Gets the total count of nodes in the sub-display tree, including this node
    Retrieves the label if one is set
    org.bukkit.OfflinePlayer[]
    Returns an array of the player(s) that own this display
    Retrieves the parent display if this is a child display
    double
     
    Gets the instance of the plugin
    double
     
    Retrieves the root node of the sub-display tree
    Gets the rotation manager if one is already created
    getRotationManager(boolean createNew)
    Gets or creates a rotation manager
    org.bukkit.util.Vector
    Retrieves the vector representing the overall scale of the display
    int
     
     
     
    org.bukkit.World
     
    double
     
    boolean
    Merges the DexBlocks in the display into this display
    boolean
    hasOwner(org.bukkit.entity.Player p)
    Returns true if the player is one of the owners OR if the player has permission dexterity.select.unowned
    boolean
    Checks whether there are running animations on this display
    boolean
    Checks if display is listed on normal list
    boolean
    Checks if selection is a saved display or not
    boolean
    Checks whether the rotation is simple enough to not involve pitch or roll
    merge(DexterityDisplay newParent, String newGroup)
    Make this display become a child node of either a new display saved as new_group, or a child display of newparent
    void
    Recalculates the average block display location and the overall selection's scale.
    void
    recalculateCenter(boolean rescale)
    Recalculates the average block display location and optionally recalculates the overall selection's scale
    void
    Delete this display and sub-displays from the world
    void
    remove(boolean restore)
    Delete this display and sub-displays from the world
    void
    Unregisters an animation from display
    void
    Removes a DexBlock to the selection.
    void
    Removes a command from being run when display is clicked
    void
    removeOwner(org.bukkit.OfflinePlayer p)
    Removes a player from the owners list
    void
     
    void
    resetScale(org.bukkit.util.Vector v)
    Deprecated.
    Retrieves the root node of the sub-display tree of a display
    org.joml.Quaterniond
    rotate(float yawDeg, float pitchDeg, float rollDeg)
    Rotate the display along the yaw, pitch, and roll directions
    org.joml.Quaterniond
    Rotate the selection
    void
    scale(double s)
    Scale by a multiplier
    void
    scale(org.bukkit.util.Vector v)
    Skew by a multiplier along x, y, and z, respectively
    void
    setBaseRotation(float yaw, float pitch, float roll)
    Reset the direction axes to the specified yaw, pitch, and roll in degrees
    void
    setBaseRotation(org.bukkit.util.Vector x, org.bukkit.util.Vector y, org.bukkit.util.Vector z)
    Reset the direction axes to the specified x, y, and z orthonormal vectors
    void
    setBlocks(List<DexBlock> entities, boolean recalcCenter)
    Overrides the blocks in this display
    void
    setCenter(org.bukkit.Location loc)
    Sets the center of the display
    void
    Saves the display with the ascending default label ('display-#')
    void
    setDropItem(org.bukkit.inventory.ItemStack item, String schemName)
    Sets the item that will be dropped if a player breaks the display
    void
    Lock this display so that it cannot be selected by any other player
    void
    setGlow(org.bukkit.Color c, boolean propegate)
    Sets the glow color of the blocks in this display
    boolean
    Saves the selection and turns it into a display by giving it a label
    void
    setListed(boolean b)
    Set to false to hide display from /d list.
    void
    setOwners(List<org.bukkit.OfflinePlayer> newOwners)
    Sets the players that own this display
    void
    Sets the parent display without affecting any child displays
    org.joml.Quaterniond
    setRotation(float yawDeg, float pitchDeg, float rollDeg)
    Reset the rotation for yaw, pitch, and roll directions
    void
    setScale(double s)
    Set the scale
    void
    setScale(org.bukkit.util.Vector s)
    Set the skew for x, y, and z, respectively
    void
    setZeroPitch(boolean b)
    Deprecated.
    void
    Re-sorts the blocks list in the standard y, x, z order
    void
    Starts all registered animation types for this display
    void
    stopAnimations(boolean force)
    Stops or kills all registered animations for this display
    void
    teleport(org.bukkit.Location loc)
    Moves the display or transfers it to another world
    void
    teleport(org.bukkit.util.Vector diff)
    Moves the display by an offset
    void
    Remove this display from its parent node
    void
    Unsaves the display and turns it into a regular selection

    Methods inherited from class java.lang.Object

    getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DexterityDisplay

      public DexterityDisplay(Dexterity plugin)
      Initializes an empty selection.
      Parameters:
      plugin -
    • DexterityDisplay

      public DexterityDisplay(Dexterity plugin, org.bukkit.Location center, org.bukkit.util.Vector scale)
      Initializes a selection
      Parameters:
      plugin -
      center -
      scale - Vector with the regular block size being [1, 1, 1]
    • DexterityDisplay

      public DexterityDisplay(Dexterity plugin, org.bukkit.Location center, org.bukkit.util.Vector scale, String label)
      Initializes a new saved display with a unique label
      Parameters:
      plugin -
      center -
      scale - Vector with the regular block size being [1, 1, 1]
      label -
    • DexterityDisplay

      public DexterityDisplay(Dexterity plugin, org.bukkit.Location center, org.bukkit.util.Vector scale, String label, List<org.bukkit.OfflinePlayer> owners)
      Initializes a new saved display with a unique label
      Parameters:
      plugin -
      center -
      scale - Vector with the regular block size being [1, 1, 1]
      label -
      owners -
  • Method Details

    • getUniqueId

      public UUID getUniqueId()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getLabel

      public String getLabel()
      Retrieves the label if one is set
      Returns:
      Unmodifiable label string if selection is saved, otherwise null
    • setListed

      public void setListed(boolean b)
      Set to false to hide display from /d list. All saved displays are listed by default
      Parameters:
      b -
    • isListed

      public boolean isListed()
      Checks if display is listed on normal list
      Returns:
      true if display will show on the saved display list (/d list), or false if display is only intended to be temporary.
    • getYaw

      public double getYaw()
    • getPitch

      public double getPitch()
    • getRoll

      public double getRoll()
    • getOwners

      public org.bukkit.OfflinePlayer[] getOwners()
      Returns an array of the player(s) that own this display
      Returns:
    • setOwners

      public void setOwners(List<org.bukkit.OfflinePlayer> newOwners)
      Sets the players that own this display
      Parameters:
      newOwners -
    • hasOwner

      public boolean hasOwner(org.bukkit.entity.Player p)
      Returns true if the player is one of the owners OR if the player has permission dexterity.select.unowned
      Parameters:
      p -
      Returns:
    • addOwner

      public void addOwner(org.bukkit.OfflinePlayer p)
      Appends a player who can edit this display
      Parameters:
      p -
    • removeOwner

      public void removeOwner(org.bukkit.OfflinePlayer p)
      Removes a player from the owners list
      Parameters:
      p -
    • recalculateCenter

      public void recalculateCenter()
      Recalculates the average block display location and the overall selection's scale.
    • recalculateCenter

      public void recalculateCenter(boolean rescale)
      Recalculates the average block display location and optionally recalculates the overall selection's scale
      Parameters:
      rescale - If false, does not change scale
    • setDefaultLabel

      public void setDefaultLabel()
      Saves the display with the ascending default label ('display-#')
    • setLabel

      public boolean setLabel(String s)
      Saves the selection and turns it into a display by giving it a label
      Parameters:
      s - Unused label to save the display, or null to unsave it.
      Returns:
      true if label is unique and the display is saved successfully
      See Also:
    • isSaved

      public boolean isSaved()
      Checks if selection is a saved display or not
      Returns:
      true if the display has a label, otherwise it is only a selection
    • unregister

      public void unregister()
      Unsaves the display and turns it into a regular selection
    • getBlocks

      public DexBlock[] getBlocks()
      Retrieves a list of DexBlock that can be iterated over
      Returns:
      Unmodifiable array of DexBlocks
      See Also:
    • getBlocksCount

      public int getBlocksCount()
      Returns:
      The integer number of DexBlocks within the selection
    • addBlock

      public void addBlock(DexBlock db)
      Adds a DexBlock to the selection. If the DexBlock is not previously registered to a saved display, it will be registered to this
      Parameters:
      db -
      See Also:
    • removeBlock

      public void removeBlock(DexBlock db)
      Removes a DexBlock to the selection. The DexBlock must be killed or registered to another display.
      Parameters:
      db -
      See Also:
    • getAnimationsCount

      public int getAnimationsCount()
      Returns:
      The integer number of animations registered, active or not.
      See Also:
    • addAnimation

      public void addAnimation(Animation a)
      Registers a new animation type, as long as no animation type was already registered to this display
      Parameters:
      a -
      See Also:
    • removeAnimation

      public void removeAnimation(Animation a)
      Unregisters an animation from display
      Parameters:
      a -
      See Also:
    • getAnimation

      public Animation getAnimation(Class<?> clazz)
      Retrieves a registered animation type if it exists
      Parameters:
      clazz -
      Returns:
      null if no animation of this type has been registered
      See Also:
    • getCommands

      public InteractionCommand[] getCommands()
      Retrieves a list of commands to run when display is clicked
      Returns:
      Unmodifiable array of InteractionCommand cmd data
    • getCommandCount

      public int getCommandCount()
      Retrieves the size of the command list
      Returns:
      size of array
    • addCommand

      public void addCommand(InteractionCommand cmd)
      Adds a command to run when display is clicked
      Parameters:
      cmd -
    • removeCommand

      public void removeCommand(InteractionCommand cmd)
      Removes a command from being run when display is clicked
      Parameters:
      cmd -
    • getScale

      public org.bukkit.util.Vector getScale()
      Retrieves the vector representing the overall scale of the display
      Returns:
    • setDropItem

      public void setDropItem(org.bukkit.inventory.ItemStack item, String schemName)
      Sets the item that will be dropped if a player breaks the display
      Parameters:
      item -
    • getDropItemSchematicName

      public String getDropItemSchematicName()
    • getDropItem

      public org.bukkit.inventory.ItemStack getDropItem()
      Gets a copy of the item that will be dropped when the player breaks the display
      Returns:
    • dropNaturally

      public void dropNaturally()
      Remove the display but drop it as an item if an item has been defined
    • setBlocks

      public void setBlocks(List<DexBlock> entities, boolean recalcCenter)
      Overrides the blocks in this display
      Parameters:
      entities - A list of unique DexBlocks
      recalcCenter - Recalculates the center point and scale if true
      See Also:
    • getSubdisplays

      public DexterityDisplay[] getSubdisplays()
      Returns:
      Unmodifiable array of sub-displays registered to this
    • getSubdisplayCount

      public int getSubdisplayCount()
    • addSubdisplay

      public void addSubdisplay(DexterityDisplay d)
    • removeSubdisplay

      public void removeSubdisplay(DexterityDisplay d)
    • getParent

      public DexterityDisplay getParent()
      Retrieves the parent display if this is a child display
      Returns:
      The parent display if defined
    • setParent

      public void setParent(DexterityDisplay p)
      Sets the parent display without affecting any child displays
      Parameters:
      p - parent display
    • getRootDisplay

      public DexterityDisplay getRootDisplay()
      Retrieves the root node of the sub-display tree
      Returns:
      the root display node
    • rootDisplay

      public static DexterityDisplay rootDisplay(DexterityDisplay d)
      Retrieves the root node of the sub-display tree of a display
      Parameters:
      d -
      Returns:
      the root display node
    • containsSubdisplay

      public boolean containsSubdisplay(DexterityDisplay d)
      Determines if passed in display is this or any descendant display node
      Parameters:
      d -
      Returns:
      true if display passed in is a child or descendant of this
    • canHardMerge

      public boolean canHardMerge()
      Checks whether it is appropriate to merge this display with another to form one display
      Returns:
      true if can hard-merge
    • hasStartedAnimations

      public boolean hasStartedAnimations()
      Checks whether there are running animations on this display
      Returns:
      true if there are animations running
    • isYawOnly

      public boolean isYawOnly()
      Checks whether the rotation is simple enough to not involve pitch or roll
      Returns:
      true if only yaw is involved
    • setZeroPitch

      @Deprecated public void setZeroPitch(boolean b)
      Deprecated.
    • hardMerge

      public boolean hardMerge(DexterityDisplay subdisplay)
      Merges the DexBlocks in the display into this display
      Parameters:
      subdisplay - The display that will be unregistered and whose blocks will be merged
      Returns:
      true if operation is successful
    • merge

      public DexterityDisplay merge(DexterityDisplay newParent, String newGroup)
      Make this display become a child node of either a new display saved as new_group, or a child display of newparent
      Parameters:
      newParent - The display that will either be a brother node or parent node depending on if a new parent display is created
      newGroup - Label of the new parent display, or null for no new parent display
      Returns:
      The parent display after the merge operation
    • getEditingLock

      public UUID getEditingLock()
      Retrieve the UUID of the offline player who has this display in editing lock
      Returns:
      UUID of the offline player if in editing lock, otherwise null
    • setEditingLock

      public void setEditingLock(UUID u)
      Lock this display so that it cannot be selected by any other player
      Parameters:
      u - The UUID of the player who has this display locked to them
    • unmerge

      public void unmerge()
      Remove this display from its parent node
    • remove

      public void remove(boolean restore)
      Delete this display and sub-displays from the world
      Parameters:
      restore - true if the DexBlocks are to be deconverted into regular blocks
    • remove

      public void remove()
      Delete this display and sub-displays from the world
    • getGroupSize

      public int getGroupSize()
      Gets the total count of nodes in the sub-display tree, including this node
      Returns:
    • getPlugin

      public Dexterity getPlugin()
      Gets the instance of the plugin
      Returns:
    • getCenter

      public org.bukkit.Location getCenter()
      Retrieves the center of the display
      Returns:
    • getWorld

      public org.bukkit.World getWorld()
    • setCenter

      public void setCenter(org.bukkit.Location loc)
      Sets the center of the display
      Parameters:
      loc -
    • startAnimations

      public void startAnimations()
      Starts all registered animation types for this display
    • stopAnimations

      public void stopAnimations(boolean force)
      Stops or kills all registered animations for this display
      Parameters:
      force - true if the animations should be killed instead of allowed to stop
    • teleport

      public void teleport(org.bukkit.Location loc)
      Moves the display or transfers it to another world
      Parameters:
      loc -
    • teleport

      public void teleport(org.bukkit.util.Vector diff)
      Moves the display by an offset
      Parameters:
      diff -
    • setGlow

      public void setGlow(org.bukkit.Color c, boolean propegate)
      Sets the glow color of the blocks in this display
      Parameters:
      c - The color of the glow
      propegate - true if descendant displays should receive this update
    • scale

      public void scale(double s)
      Scale by a multiplier
      Parameters:
      s -
    • setScale

      public void setScale(double s)
      Set the scale
      Parameters:
      s - Representing x, y, and z scale
    • setScale

      public void setScale(org.bukkit.util.Vector s)
      Set the skew for x, y, and z, respectively
      Parameters:
      s -
    • scale

      public void scale(org.bukkit.util.Vector v)
      Skew by a multiplier along x, y, and z, respectively
      Parameters:
      v -
      Throws:
      DexterityException - if skewing a selection with more than 1 rotation orientation, as it is impossible to create parallelograms
    • resetScale

      @Deprecated public void resetScale(org.bukkit.util.Vector v)
      Deprecated.
    • align

      public void align()
      Teleport the selection so that its corner aligns with the nearest whole block
    • align

      public void align(boolean toCenter)
      Teleport the selection so that its corner or center aligns with the nearest whole block
      Parameters:
      toCenter - If true, aligns based on the display's center, otherwise by its corner.
    • align

      public void align(boolean toCenter, boolean x, boolean y, boolean z)
      Teleport the selection so that its corner or center aligns with the nearest whole block along a certain axis of movement
      Parameters:
      toCenter - If true, aligns based on the display's center, otherwise by its corner.
      x - If x axis movement is allowed
      y - If y axis movement is allowed
      z - If z axis movement is allowed
    • rotate

      public org.joml.Quaterniond rotate(float yawDeg, float pitchDeg, float rollDeg)
      Rotate the display along the yaw, pitch, and roll directions
      Parameters:
      yawDeg -
      pitchDeg -
      rollDeg -
      Returns:
      The quaternion representing the rotation
    • setRotation

      public org.joml.Quaterniond setRotation(float yawDeg, float pitchDeg, float rollDeg)
      Reset the rotation for yaw, pitch, and roll directions
      Parameters:
      yawDeg -
      pitchDeg -
      rollDeg -
      Returns:
      The quaternion representing the rotation
    • setBaseRotation

      public void setBaseRotation(float yaw, float pitch, float roll)
      Reset the direction axes to the specified yaw, pitch, and roll in degrees
      Parameters:
      yaw -
      pitch -
      roll -
    • setBaseRotation

      public void setBaseRotation(org.bukkit.util.Vector x, org.bukkit.util.Vector y, org.bukkit.util.Vector z)
      Reset the direction axes to the specified x, y, and z orthonormal vectors
      Parameters:
      x -
      y -
      z -
    • getRotationManager

      public DexRotation getRotationManager()
      Gets the rotation manager if one is already created
      Returns:
    • getRotationManager

      public DexRotation getRotationManager(boolean createNew)
      Gets or creates a rotation manager
      Parameters:
      createNew -
      Returns:
      the existing or new rotation manager
    • rotate

      public org.joml.Quaterniond rotate(RotationPlan plan)
      Rotate the selection
      Parameters:
      plan -
      Returns:
      The quaternion representing the rotation
    • getBoundingBox

      public org.bukkit.util.BoundingBox getBoundingBox()
    • sortBlocks

      public void sortBlocks()
      Re-sorts the blocks list in the standard y, x, z order
    • consolidate

      public void consolidate(Mask m)
      Consolidate along all axes to reduce the number of entities where possible without altering the selection's shape
      Parameters:
      m - Mask to use, or null for no mask
    • consolidate

      public void consolidate(Mask m, BlockTransaction t)
      Consolidate along all axes to reduce the number of entities where possible without altering the selection's shape
      Parameters:
      m - Mask to use, or null for no mask
      t - The transaction to set blocks to or null
    • consolidate

      @Deprecated public void consolidate(int axis, Mask m)
      Deprecated.