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 Details

    • DexterityDisplay

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

      public DexterityDisplay(me.c7dev.dexterity.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(me.c7dev.dexterity.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 -
  • 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
    • getYaw

      public double getYaw()
    • getPitch

      public double getPitch()
    • getRoll

      public double getRoll()
    • recalculateCenter

      public void recalculateCenter()
      Recalculates the average block display location and determines the overall selection's 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:
    • setBlocks

      public void setBlocks(List<DexBlock> entities, boolean recalc_center)
      Overrides the blocks in this display
      Parameters:
      entities - A list of unique DexBlocks
      recalc_center - 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
    • 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 new_group)
      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
      new_group - 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 me.c7dev.dexterity.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 -
    • align

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

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

      public org.joml.Quaterniond setRotation(float yaw_deg, float pitch_deg, float roll_deg)
      Reset the rotation for yaw, pitch, and roll directions
      Parameters:
      yaw_deg -
      pitch_deg -
      roll_deg -
      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 -
    • getRotationManager

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

      public DexRotation getRotationManager(boolean create_new)
      Gets or creates a rotation manager
      Parameters:
      create_new -
      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
    • 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