Class CompletePortal

java.lang.Object
me.xxastaspastaxx.dimensions.completePortal.CompletePortal

public class CompletePortal extends Object
Class containing the info of a built portal
  • Constructor Details

    • CompletePortal

      public CompletePortal(CustomPortal customPortal, org.bukkit.World world, PortalGeometry portalGeometry)
      Construct the CompletePortal If portalGeometry is not null, create PortalEntities
      Parameters:
      customPortal - the customPortal that is built
      world - the world that is built
      portalGeometry - PortalGeometry of the portal
    • CompletePortal

      public CompletePortal(CustomPortal customPortal, org.bukkit.World world, PortalGeometry portalGeometry, CompletePortal linked)
      Construct the CompletePortal If portalGeometry is not null, create PortalEntities If linked is not null, links the portals
      Parameters:
      customPortal - the customPortal that is built
      world - the world that is built
      portalGeometry - PortalGeometry of the portal
      linked - The portal to be linked with
  • Method Details

    • getCustomPortal

      public CustomPortal getCustomPortal()
      Get the CustomPortal
      Returns:
      the CustomPortal
    • getWorld

      public org.bukkit.World getWorld()
      Get the world of the portal
      Returns:
      the world of the portal
    • getPortalGeometry

      public PortalGeometry getPortalGeometry()
      Get the portal geometry of the portal
      Returns:
      the portal geometry of the portal
    • getLinkedPortal

      public CompletePortal getLinkedPortal()
      Get the portal that is linked with
      Returns:
      null if there is no linked portal or the linked portal
    • unlinkPortal

      public void unlinkPortal()
      Unlink the portal
    • setLinkedPortal

      public void setLinkedPortal(CompletePortal complete)
      Link to a portal
      Parameters:
      complete - the portal to link to
    • getCenter

      public org.bukkit.Location getCenter()
      Get the center of the portal
      Returns:
      the center of the portal
    • getPortalEntities

      public ArrayList<PortalEntity> getPortalEntities()
      Get the PortalEntity list
      Returns:
      the PortalEntity list
    • updatePortal

      public void updatePortal()
      Check for nearby entities to teleport
    • handleEntity

      public void handleEntity(org.bukkit.entity.Entity en)
      Start the teleport countdown for the entity if they are not in hold. The delay for Creative and Spectator players is 0 Call the CustomPortalUseEvent and if its not cancelled the teleport the entity
      Parameters:
      en - the entity to teleport
      See Also:
      CustomPortalUseEvent
    • isInsidePortal

      public boolean isInsidePortal(org.bukkit.Location loc, boolean outside, boolean corner)
      Check if the location is inside the portal
      Parameters:
      loc - location to check
      outside - true to count the frame of the portal
      corner - true to count the corners of the portal
      Returns:
      true if the location is inside the portal
    • getDestinationLocation

      public org.bukkit.Location getDestinationLocation(org.bukkit.Location overrideLocation, org.bukkit.World overrideWorld)
      Calculate the teleport destination for the portal Get the destination world if its not being overriden Fix the world ratio using the world sizes Fix the height ratio using the world min/max heights
      Parameters:
      overrideLocation - override the location with this
      overrideWorld - override the world with this
      Returns:
      the destination location to try and build an exit portal to use
    • getDestinationPortal

      public CompletePortal getDestinationPortal(boolean buildNewPortal, org.bukkit.Location overrideLocation, org.bukkit.World overrideWorld)
      Get the destination portal to use
      Parameters:
      buildNewPortal - true to build an exit portal
      overrideLocation - location to override
      overrideWorld - world to override
      Returns:
      the portal to use
    • getWorldRatio

      public double getWorldRatio(org.bukkit.World destinationWorld)
      Calculate the world ratio from the world sizes
      Parameters:
      destinationWorld - world to get the ratio from
      Returns:
      the world ratio
    • fill

      public void fill(org.bukkit.entity.Player p)
      Set the block or summon the falling block entities for all the PortalEntities
      Parameters:
      p - null to broadcast the packets or the player to send the packets to
    • destroy

      public void destroy(org.bukkit.entity.Player p)
      Despawn the entities or change the block to air inside the portal
      Parameters:
      p - null to stop the running tasks or the player to play the destroy packet
    • isInChunk

      public boolean isInChunk(org.bukkit.World world2, int x, int z)
      Check if the portal is inside the given chunk
      Parameters:
      world2 - the world of the chunk
      x - the X of the chunk
      z - the Z of the chunk
      Returns:
      true if all match
    • pushToHold

      public void pushToHold(org.bukkit.entity.Entity en)
      Add the entity to hold so it won't be teleported
      Parameters:
      en - the entity to add
    • hasInHold

      public boolean hasInHold(org.bukkit.entity.Entity en)
      Check if the entity is on hold or in the queue to teleport
      Parameters:
      en - the player to check
      Returns:
      true if the player is in hold or queue
    • removeFromHold

      public void removeFromHold(org.bukkit.entity.Entity en)
      Remove the entity from hold and cancel the teleport task
      Parameters:
      en - the entity to remove
    • setTag

      public void setTag(String key, Object value)
      Set a portal tag (tags are stored even after restart)
      Parameters:
      key - the key of the tag
      value - the value of the tag
    • getTag

      public Object getTag(String key)
      Get the value of the tag
      Parameters:
      key -
      Returns:
      the value
    • getTags

      public HashMap<String,​Object> getTags()
      Get the portal tags
      Returns:
      the portal tags
    • setTags

      public void setTags(HashMap<String,​Object> tags)
      Override the portal tags
      Parameters:
      tags -
    • isActive

      public boolean isActive()
      Check if the chunk the portal is in is loaded
      Returns:
      true if chunk is loaded