Interface IStructureConst

All Superinterfaces:
IPropertyHolderConst
All Known Implementing Classes:
Structure, StructureSnapshot

public interface IStructureConst extends IPropertyHolderConst
Represents a read-only structure.

Please read the documentation of nl.pim16aap2.animatedarchitecture.core.structures for more information about the structure system.

Never cast an IStructureConst to a Structure, even when it looks like it might be possible. Doing so can lead to all kinds of issues, including deadlocks.

  • Method Details

    • getSnapshot

      StructureSnapshot getSnapshot()
      Returns:
      A StructureSnapshot of this IStructureConst.
    • getType

      StructureType getType()
      Returns:
      The StructureType of this structure.
    • getCuboid

      Cuboid getCuboid()
      Gets the Cuboid representing the area taken up by this structure.
      Returns:
      The Cuboid representing the area taken up by this structure.
    • getAnimationRange

      Rectangle getAnimationRange()
      Gets the rectangle describing the limits within an animation of this door takes place.

      At no point during an animation will any animated block leave this cuboid, though not guarantees are given regarding how tight the cuboid fits around the animated blocks.

      Returns:
      The animation range.
    • getName

      String getName()
      Gets the name of this structure.
      Returns:
      The name of this structure.
    • formatNameAndUid

      static String formatNameAndUid(String name, long uid)
      Formats a name and UID into a string.
      Parameters:
      name - The name of the structure.
      uid - The UID of the structure.
      Returns:
      The name and UID formatted as "name (uid)".
    • getNameAndUid

      default String getNameAndUid()
      Returns:
      The name and UID of this structure formatted as "name (uid)".
    • getWorld

      IWorld getWorld()
      Gets the IWorld this Structure exists in.
      Returns:
      The IWorld this Structure exists in
    • getUid

      long getUid()
      Gets the UID of the Structure as used in the database. Guaranteed to be unique and available.
      Returns:
      The UID of the Structure as used in the database.
    • getBasicInfo

      default String getBasicInfo()
      Gets the basic information of this structure.

      This includes the name, UID, type, and prime owner of this structure.

      Returns:
      The basic information of this structure.
    • getMinimumAnimationTime

      double getMinimumAnimationTime()
      Gets the lower time limit for an animation.

      Because animated blocks have a speed limit, as determined by IConfig.maxBlockSpeed(), there is also a minimum amount of time for its animation.

      The exact time limit depends on the shape, size, and type of structure.

      Returns:
      The lower animation time limit for this structure in seconds.
    • isLocked

      boolean isLocked()
      Check if the Structure is currently locked. When locked, structures cannot be opened.
      Returns:
      True if the Structure is locked
    • getPrimeOwner

      StructureOwner getPrimeOwner()
      Gets the prime owner (permission = 0) of this structure. In most cases, this will be the original creator of the structure.
      Returns:
      The prime owner of this structure.
    • getOwners

      Gets all StructureOwners of this structure, including the original creator.
      Returns:
      All StructureOwners of this structure, including the original creator.
    • getOwner

      Optional<StructureOwner> getOwner(UUID player)
      Attempts to get the StructureOwner of this structure represented by the UUID of a player.
      Parameters:
      player - The UUID of the player that may or may not be an owner of this structure.
      Returns:
      The StructureOwner of this structure for the given player, if this player is a StructureOwner of this structure.
    • getOwner

      default Optional<StructureOwner> getOwner(IPlayer player)
      Attempts to get the StructureOwner of this structure represented by an IPlayer.
      Parameters:
      player - The player that may or may not be an owner of this structure.
      Returns:
      The StructureOwner of this structure for the given player, if this player is a StructureOwner of this structure.
    • isOwner

      boolean isOwner(UUID player)
      Checks if a player with a given UUID is a (co-)owner of this structure with any level of ownership.

      If the level of ownership matters, use getOwner(UUID) instead.

      Parameters:
      player - The UUID of a player.
      Returns:
      True if the player with the given UUID is an owner of this structure with any level of ownership.
    • isOwner

      default boolean isOwner(IPlayer player)
      Checks if a player with a given UUID is a (co-)owner of this structure with any level of ownership.

      If the level of ownership matters, use getOwner(UUID) instead.

      Parameters:
      player - The player.
      Returns:
      True if the player with the given UUID is an owner of this structure with any level of ownership.
    • isOwner

      boolean isOwner(UUID player, PermissionLevel permissionLevel)
      Checks if a player with a given UUID is a (co-)owner of this structure with a given level of ownership.
      Parameters:
      player - The UUID of a player.
      permissionLevel - The maximum level of ownership the player may have.

      E.g. when permissionLevel is PermissionLevel.ADMIN, this method will return true if the player has admin access or lower (PermissionLevel.ADMIN or PermissionLevel.CREATOR).

      Returns:
      True if the player with the given UUID is an owner of this structure with the given level of ownership (or lower).
    • isOwner

      default boolean isOwner(IPlayer player, PermissionLevel permissionLevel)
      Checks if a player with a given UUID is a (co-)owner of this structure with a given level of ownership.
      Parameters:
      player - The player.
      permissionLevel - The maximum level of ownership the player may have.

      E.g. when permissionLevel is PermissionLevel.ADMIN, this method will return true if the player has admin access or lower (PermissionLevel.ADMIN or PermissionLevel.CREATOR).

      Returns:
      True if the player with the given UUID is an owner of this structure with the given level of ownership (or lower).
    • getOpenDirection

      MovementDirection getOpenDirection()
      Gets the MovementDirection this Structure will open if currently closed.

      Note that if it's currently in the open status, it is supposed go in the opposite direction, as the closing direction is the opposite of the opening direction. This isn't taken into account by this method.

      Returns:
      The MovementDirection this Structure will open in.
    • getPowerBlock

      Vector3Di getPowerBlock()
      Gets the position of power block of this structure.
      Returns:
      The position of the power block of this structure.
    • getMinimum

      default Vector3Di getMinimum()
      Gets the minimum position of this structure.
      Returns:
      The minimum coordinates of this structure.
    • getMaximum

      default Vector3Di getMaximum()
      Gets a copy of the maximum position of this structure.
      Returns:
      A copy of the maximum position of this structure.
    • getBlockCount

      default int getBlockCount()
      Retrieve the total number of blocks this Structure is made out of. If invalidated or not calculated * yet, it is (re)calculated first.

      It's calculated once and then stored until invalidated.

      Returns:
      Total number of blocks this Structure is made out of.
    • getDimensions

      default Vector3Di getDimensions()
      Gets the dimensions of this structure.

      If a structure has a min and max X value of 120, for example, it would have an X-dimension of 0. If the min X value is 119 instead, it would have an X-dimension of 1.

      Returns:
      The dimensions of this structure.
    • getChunkId

      default long getChunkId()
      Returns:
      The simple hash of the chunk in which the power block resides.
    • getCycledOpenDirection

      MovementDirection getCycledOpenDirection()
      Cycle the MovementDirection direction this Structure will open in. By default, it will loop over all valid directions. See StructureType.getValidOpenDirectionsList(). However, subclasses may override this behavior.

      Note that this does not actually change the open direction; it merely tells you which direction comes next!

      Returns:
      The new MovementDirection direction this Structure will open in.
    • equals

      boolean equals(Object o)
      Overrides:
      equals in class Object
    • getPropertyContainerSnapshot

      IPropertyContainerConst getPropertyContainerSnapshot()
      Gets the PropertyContainerSnapshot of this structure.
      Returns:
      The PropertyContainerSnapshot of this structure.
    • canMovePerpetually

      boolean canMovePerpetually()
      Checks if this structure can move perpetually.
      Returns:
      True if this structure can move perpetually.