Class StargatePortal
- All Implemented Interfaces:
MetadataHolder,Portal,RealPortal
- Author:
- Thorin
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected UUIDstatic final Set<PortalFlag> Used for bStats metrics, this is every flag that has been used by all portalsprotected booleanprotected final LanguageManagerprotected Stringprotected Networkprotected UUIDprotected Portalstatic intUsed in bStats metrics -
Constructor Summary
ConstructorsConstructorDescriptionStargatePortal(Network network, String name, Set<PortalFlag> flags, GateAPI gate, UUID ownerUUID, LanguageManager languageManager, StargateEconomyAPI economyManager, @Nullable String metaData) Instantiates a new abstract portal -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(@Nullable org.bukkit.entity.Player player) Activates this portal for the given player during internally specified timevoidaddFlag(PortalFlag flag) Add a flag from this portal (does not do so to storage)voidclose(boolean forceClose) Closes this portalvoidclose(long relatedOpenTime) Closes this portalvoidDeactivate this portalprotected voiddeactivate(long activatedTime) De-activates this portal if necessaryvoiddestroy()The method used when destroying a portalvoiddoTeleport(@NotNull org.bukkit.entity.Entity target) Teleports the given entity to stored destinationvoiddoTeleport(@NotNull org.bukkit.entity.Entity target, @Nullable Portal destination) Teleports the given entity to given destinationGets all of this portal's portal flags in the form of a stringorg.bukkit.LocationgetExit()Gets the exit location of this portalorg.bukkit.block.BlockFaceGet the facing entities exit from this portal.getGate()Gets the gate belonging to this portalGets the globally unique identifier for this portalgetId()Gets the unique identifier for this portalGet metadata for this portal.getName()Gets the name of this portalGets the network this portal belongs toGets the UUID of this portal's ownerList<org.bukkit.Location> Gets the location of all positions of the specified portal position typeGets how the portal is storedbooleanhasFlag(PortalFlag flag) Checks whether this portal has the given portal flag enabledbooleanisActive()booleanbooleanisOpen()Checks whether this portal is currently openbooleanisOpenFor(org.bukkit.entity.Entity target) Checks whether this portal is currently open and the given target is the one the portal opened forvoidopen(org.bukkit.entity.Player actor) Opens this portal for the given playervoidOpen this portal without any checksvoidoverrideDestination(Portal destination) Forces this portal to temporarily go to the given destination regardless of the normal destination(s)voidRedraw all signs in this portalvoidremoveFlag(PortalFlag flag) Remove a flag from this portal (does not do so from storage)voidsetBehavior(PortalBehavior portalBehavior) Modify the behavior this portal usesvoidsetMetadata(String data) Set metadata for this portal.voidChanges the name of the portal.voidsetNetwork(Network targetNetwork) Changes the network this portal belongs tovoidChanges the player this portal belongs tovoidvoidsetSignColor(@Nullable org.bukkit.DyeColor changedColor, @NotNull PortalPosition portalPosition) Updates the color of this portal's signvoidteleportHere(org.bukkit.entity.Entity target, RealPortal origin) Teleports an entity to this portalvoidLooks into available portals to connect to, and updates appearance and behaviour accordinglyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.sgrewritten.stargate.api.MetadataHolder
getMetadata, setMetadata
-
Field Details
-
portalCount
public static int portalCountUsed in bStats metrics -
allUsedFlags
Used for bStats metrics, this is every flag that has been used by all portals -
network
-
name
-
openFor
-
overriddenDestination
-
activatedTime
protected long activatedTime -
activator
-
isDestroyed
protected boolean isDestroyed -
languageManager
-
-
Constructor Details
-
StargatePortal
public StargatePortal(Network network, String name, Set<PortalFlag> flags, GateAPI gate, UUID ownerUUID, LanguageManager languageManager, StargateEconomyAPI economyManager, @Nullable @Nullable String metaData) throws NameLengthException Instantiates a new abstract portal- Parameters:
network-The network the portal belongs to
name-The name of the portal
flags-The flags enabled for the portal
gate-The gate belonging to this portal
ownerUUID-The UUID of the portal's owner
languageManager-A manager able to provide localized messages
economyManager-A manager able to deal with server economy
- Throws:
NameLengthException-If the portal name is invalid
-
-
Method Details
-
getGlobalId
Description copied from interface:PortalGets the globally unique identifier for this portal- Specified by:
getGlobalIdin interfacePortal- Returns:
The globally unique identifier for this portal
-
getPortalPosition
Description copied from interface:RealPortalGets the location of all positions of the specified portal position type- Specified by:
getPortalPositionin interfaceRealPortal- Parameters:
type-The type of portalPosition
- Returns:
The location of this portal's signs
-
updateState
public void updateState()Description copied from interface:PortalLooks into available portals to connect to, and updates appearance and behaviour accordingly- Specified by:
updateStatein interfacePortal
-
isOpen
public boolean isOpen()Description copied from interface:PortalChecks whether this portal is currently open -
open
public void open(@Nullable @Nullable Portal destination, @Nullable @Nullable org.bukkit.entity.Player actor) Description copied from interface:RealPortalOpen this portal without any checks- Specified by:
openin interfaceRealPortal- Parameters:
destination-The destination to open to
actor-The player which opened this portal
-
open
public void open(org.bukkit.entity.Player actor) Description copied from interface:PortalOpens this portal for the given player -
close
public void close(boolean forceClose) Description copied from interface:PortalCloses this portal -
isOpenFor
public boolean isOpenFor(org.bukkit.entity.Entity target) Description copied from interface:PortalChecks whether this portal is currently open and the given target is the one the portal opened for -
overrideDestination
Description copied from interface:PortalForces this portal to temporarily go to the given destination regardless of the normal destination(s)- Specified by:
overrideDestinationin interfacePortal- Parameters:
destination-The destination this portal should temporarily connect ot
-
getNetwork
Description copied from interface:PortalGets the network this portal belongs to- Specified by:
getNetworkin interfacePortal- Returns:
The network this portal belongs to
-
setNetwork
Description copied from interface:PortalChanges the network this portal belongs to- Specified by:
setNetworkin interfacePortal- Parameters:
targetNetwork-The new network this portal should belong to
- Throws:
NameConflictException-If the given network name is invalid
-
setOwner
Description copied from interface:PortalChanges the player this portal belongs toDOES NOT SAVE TO DATABASE
-
teleportHere
Description copied from interface:PortalTeleports an entity to this portal- Specified by:
teleportHerein interfacePortal- Parameters:
target-The target entity to teleport
origin-The origin portal the entity is teleporting from
-
doTeleport
public void doTeleport(@NotNull @NotNull org.bukkit.entity.Entity target, @Nullable @Nullable Portal destination) Description copied from interface:RealPortalTeleports the given entity to given destination- Specified by:
doTeleportin interfaceRealPortal- Parameters:
target-The entity to teleport
-
doTeleport
public void doTeleport(@NotNull @NotNull org.bukkit.entity.Entity target) Description copied from interface:RealPortalTeleports the given entity to stored destination- Specified by:
doTeleportin interfaceRealPortal- Parameters:
target-The entity to teleport
-
getName
Description copied from interface:PortalGets the name of this portal -
hasFlag
Description copied from interface:PortalChecks whether this portal has the given portal flag enabled -
addFlag
Description copied from interface:PortalAdd a flag from this portal (does not do so to storage)- Specified by:
addFlagin interfacePortal- Parameters:
flag-Flag to add
- Throws:
UnsupportedOperationException
-
removeFlag
Description copied from interface:PortalRemove a flag from this portal (does not do so from storage)- Specified by:
removeFlagin interfacePortal- Parameters:
flag-Flag to remove
- Throws:
UnsupportedOperationException
-
getAllFlagsString
Description copied from interface:PortalGets all of this portal's portal flags in the form of a stringThis returns the concatenation of all character representations for the flags used by this portal.
- Specified by:
getAllFlagsStringin interfacePortal- Returns:
All of this portal's portal flags in the form of a string
-
getOwnerUUID
Description copied from interface:PortalGets the UUID of this portal's ownerA portal's owner is the player that created the portal.
- Specified by:
getOwnerUUIDin interfacePortal- Returns:
The UUID of this portal's owner
-
setSignColor
public void setSignColor(@Nullable @Nullable org.bukkit.DyeColor changedColor, @NotNull @NotNull PortalPosition portalPosition) Description copied from interface:RealPortalUpdates the color of this portal's signReplacement function for
Sign.setColor(org.bukkit.DyeColor), as the portal sign is an interface that is using a combination of various colors; more has to be processed- Specified by:
setSignColorin interfaceRealPortal- Parameters:
changedColor-Color to change the sign text to. If null, then the default color will be used
-
getGate
Description copied from interface:RealPortalGets the gate belonging to this portal- Specified by:
getGatein interfaceRealPortal- Returns:
The gate belonging to this portal
-
destroy
public void destroy()Description copied from interface:PortalThe method used when destroying a portalMainly clears the sign, see
NetworkManager.destroyPortal(RealPortal)to really destroy a portal -
close
public void close(long relatedOpenTime) Description copied from interface:RealPortalCloses this portalEverytime most of the portals opens, there is going to be a scheduled event to close it after a specific time. If a player enters the portal before this, then it is going to close, but the scheduled close event is still going to be there. And if the portal gets activated again, it is going to close prematurely, because of this already scheduled event. Solution to avoid this is to assign an open-time for each scheduled close event and only close if the related open time matches with the most recent time the portal was opened.
- Specified by:
closein interfaceRealPortal- Parameters:
relatedOpenTime-The time this portal was opened
-
getExit
public org.bukkit.Location getExit()Description copied from interface:RealPortalGets the exit location of this portal- Specified by:
getExitin interfaceRealPortal- Returns:
The exit location of this portal
-
getId
Description copied from interface:PortalGets the unique identifier for this portal -
activate
public void activate(@Nullable @Nullable org.bukkit.entity.Player player) Description copied from interface:RealPortalActivates this portal for the given player during internally specified time- Specified by:
activatein interfaceRealPortal- Parameters:
player-The player to activate this portal for
-
isActive
public boolean isActive()- Specified by:
isActivein interfaceRealPortal- Returns:
True if this portal is active
-
getActivatorUUID
- Specified by:
getActivatorUUIDin interfaceRealPortal- Returns:
The uuid activator or null if portal is not active (or always on)
-
deactivate
protected void deactivate(long activatedTime) De-activates this portal if necessaryThe activated time must match to make sure to skip de-activation requests except for the one cancelling the newest portal activation.
- Parameters:
activatedTime-The time this portal was activated
-
deactivate
public void deactivate()Description copied from interface:RealPortalDeactivate this portal- Specified by:
deactivatein interfaceRealPortal
-
setMetadata
Description copied from interface:MetadataHolderSet metadata for this portal. This sets all metadata for this entity, it's advised to useMetadataHolder.setMetadata(JsonElement, String)- Specified by:
setMetadatain interfaceMetadataHolder- Parameters:
data-The meta data to set
-
getMetadata
Description copied from interface:MetadataHolderGet metadata for this portal. This gets all metadata for this entity, it's advised to use theMetadataHolder.getMetadata(String)method- Specified by:
getMetadatain interfaceMetadataHolder- Returns:
The meta data of this portal
-
getStorageType
Description copied from interface:PortalGets how the portal is stored- Specified by:
getStorageTypein interfacePortal- Returns:
The storage type of the portal
-
setName
Description copied from interface:PortalChanges the name of the portal. UseNetworkManager.rename(Portal, String)instead, as this does not save to database, nor update its name to the portal network. -
getExitFacing
public org.bukkit.block.BlockFace getExitFacing()Description copied from interface:RealPortalGet the facing entities exit from this portal.- Specified by:
getExitFacingin interfaceRealPortal- Returns:
The facing entities exit from this portal.
-
setSavedToStorage
public void setSavedToStorage() -
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfacePortal- Returns:
True if this portal has been destroyed
-
getBehavior
- Specified by:
getBehaviorin interfaceRealPortal- Returns:
The behavior which defines this portal destination selection and sign text
-
setBehavior
Description copied from interface:RealPortalModify the behavior this portal uses- Specified by:
setBehaviorin interfaceRealPortal- Parameters:
portalBehavior-New behavior this portal should follow
-
redrawSigns
public void redrawSigns()Description copied from interface:RealPortalRedraw all signs in this portal- Specified by:
redrawSignsin interfaceRealPortal
-