Class CompletePortal
java.lang.Object
me.xxastaspastaxx.dimensions.completePortal.CompletePortal
Class containing the info of a built portal
-
Constructor Summary
ConstructorDescriptionCompletePortal(CustomPortal customPortal, org.bukkit.World world, PortalGeometry portalGeometry)
Construct the CompletePortal If portalGeometry is not null, create PortalEntitiesCompletePortal(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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy(org.bukkit.entity.Player p)
Despawn the entities or change the block to air inside the portalvoid
fill(org.bukkit.entity.Player p)
Set the block or summon the falling block entities for all the PortalEntitiesorg.bukkit.Location
Get the center of the portalGet the CustomPortalorg.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 heightsgetDestinationPortal(boolean buildNewPortal, org.bukkit.Location overrideLocation, org.bukkit.World overrideWorld)
Get the destination portal to useGet the portal that is linked withGet the PortalEntity listGet the portal geometry of the portalGet the value of the taggetTags()
Get the portal tagsorg.bukkit.World
getWorld()
Get the world of the portaldouble
getWorldRatio(org.bukkit.World destinationWorld)
Calculate the world ratio from the world sizesvoid
handleEntity(org.bukkit.entity.Entity en)
Start the teleport countdown for the entity if they are not in hold.boolean
hasInHold(org.bukkit.entity.Entity en)
Check if the entity is on hold or in the queue to teleportboolean
isActive()
Check if the chunk the portal is in is loadedboolean
isInChunk(org.bukkit.World world2, int x, int z)
Check if the portal is inside the given chunkboolean
isInsidePortal(org.bukkit.Location loc, boolean outside, boolean corner)
Check if the location is inside the portalvoid
pushToHold(org.bukkit.entity.Entity en)
Add the entity to hold so it won't be teleportedvoid
removeFromHold(org.bukkit.entity.Entity en)
Remove the entity from hold and cancel the teleport taskvoid
setLinkedPortal(CompletePortal complete)
Link to a portalvoid
Set a portal tag (tags are stored even after restart)void
Override the portal tagsvoid
Unlink the portalvoid
Check for nearby entities to teleport
-
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 builtworld
- the world that is builtportalGeometry
- 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 builtworld
- the world that is builtportalGeometry
- PortalGeometry of the portallinked
- The portal to be linked with
-
-
Method Details
-
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
Get the portal geometry of the portal- Returns:
- the portal geometry of the portal
-
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
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
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 checkoutside
- true to count the frame of the portalcorner
- 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 thisoverrideWorld
- 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 portaloverrideLocation
- location to overrideoverrideWorld
- 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 chunkx
- the X of the chunkz
- 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
Set a portal tag (tags are stored even after restart)- Parameters:
key
- the key of the tagvalue
- the value of the tag
-
getTag
Get the value of the tag- Parameters:
key
-- Returns:
- the value
-
getTags
Get the portal tags- Returns:
- the portal tags
-
setTags
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
-