Class StargatePortal
- All Implemented Interfaces:
MetadataHolder
,Portal
,RealPortal
- Author:
- Thorin
-
Field Summary
Modifier and TypeFieldDescriptionprotected long
protected UUID
static final Set
<PortalFlag> Used for bStats metrics, this is every flag that has been used by all portalsprotected boolean
protected final LanguageManager
protected String
protected Network
protected UUID
protected Portal
static int
Used in bStats metrics -
Constructor Summary
ConstructorDescriptionStargatePortal
(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 TypeMethodDescriptionvoid
activate
(@Nullable org.bukkit.entity.Player player) Activates this portal for the given player during internally specified timevoid
addFlag
(PortalFlag flag) Add a flag from this portal (does not do so to storage)void
close
(boolean forceClose) Closes this portalvoid
close
(long relatedOpenTime) Closes this portalvoid
Deactivate this portalprotected void
deactivate
(long activatedTime) De-activates this portal if necessaryvoid
destroy()
The method used when destroying a portalvoid
doTeleport
(@NotNull org.bukkit.entity.Entity target) Teleports the given entity to stored destinationvoid
doTeleport
(@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.Location
getExit()
Gets the exit location of this portalorg.bukkit.block.BlockFace
Get 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 storedboolean
hasFlag
(PortalFlag flag) Checks whether this portal has the given portal flag enabledboolean
isActive()
boolean
boolean
isOpen()
Checks whether this portal is currently openboolean
isOpenFor
(org.bukkit.entity.Entity target) Checks whether this portal is currently open and the given target is the one the portal opened forvoid
open
(org.bukkit.entity.Player actor) Opens this portal for the given playervoid
Open this portal without any checksvoid
overrideDestination
(Portal destination) Forces this portal to temporarily go to the given destination regardless of the normal destination(s)void
Redraw all signs in this portalvoid
removeFlag
(PortalFlag flag) Remove a flag from this portal (does not do so from storage)void
setBehavior
(PortalBehavior portalBehavior) Modify the behavior this portal usesvoid
setMetadata
(String data) Set metadata for this portal.void
Changes the name of the portal.void
setNetwork
(Network targetNetwork) Changes the network this portal belongs tovoid
Changes the player this portal belongs tovoid
void
setSignColor
(@Nullable org.bukkit.DyeColor changedColor, @NotNull PortalPosition portalPosition) Updates the color of this portal's signvoid
teleportHere
(org.bukkit.entity.Entity target, RealPortal origin) Teleports an entity to this portalvoid
Looks 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, wait
Methods 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:Portal
Gets the globally unique identifier for this portal- Specified by:
getGlobalId
in interfacePortal
- Returns:
The globally unique identifier for this portal
-
getPortalPosition
Description copied from interface:RealPortal
Gets the location of all positions of the specified portal position type- Specified by:
getPortalPosition
in interfaceRealPortal
- Parameters:
type
-The type of portalPosition
- Returns:
The location of this portal's signs
-
updateState
public void updateState()Description copied from interface:Portal
Looks into available portals to connect to, and updates appearance and behaviour accordingly- Specified by:
updateState
in interfacePortal
-
isOpen
public boolean isOpen()Description copied from interface:Portal
Checks 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:RealPortal
Open this portal without any checks- Specified by:
open
in 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:Portal
Opens this portal for the given player -
close
public void close(boolean forceClose) Description copied from interface:Portal
Closes this portal -
isOpenFor
public boolean isOpenFor(org.bukkit.entity.Entity target) Description copied from interface:Portal
Checks whether this portal is currently open and the given target is the one the portal opened for -
overrideDestination
Description copied from interface:Portal
Forces this portal to temporarily go to the given destination regardless of the normal destination(s)- Specified by:
overrideDestination
in interfacePortal
- Parameters:
destination
-The destination this portal should temporarily connect ot
-
getNetwork
Description copied from interface:Portal
Gets the network this portal belongs to- Specified by:
getNetwork
in interfacePortal
- Returns:
The network this portal belongs to
-
setNetwork
Description copied from interface:Portal
Changes the network this portal belongs to- Specified by:
setNetwork
in 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:Portal
Changes the player this portal belongs toDOES NOT SAVE TO DATABASE
-
teleportHere
Description copied from interface:Portal
Teleports an entity to this portal- Specified by:
teleportHere
in 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:RealPortal
Teleports the given entity to given destination- Specified by:
doTeleport
in interfaceRealPortal
- Parameters:
target
-The entity to teleport
-
doTeleport
public void doTeleport(@NotNull @NotNull org.bukkit.entity.Entity target) Description copied from interface:RealPortal
Teleports the given entity to stored destination- Specified by:
doTeleport
in interfaceRealPortal
- Parameters:
target
-The entity to teleport
-
getName
Description copied from interface:Portal
Gets the name of this portal -
hasFlag
Description copied from interface:Portal
Checks whether this portal has the given portal flag enabled -
addFlag
Description copied from interface:Portal
Add a flag from this portal (does not do so to storage)- Specified by:
addFlag
in interfacePortal
- Parameters:
flag
-Flag to add
- Throws:
UnsupportedOperationException
-
removeFlag
Description copied from interface:Portal
Remove a flag from this portal (does not do so from storage)- Specified by:
removeFlag
in interfacePortal
- Parameters:
flag
-Flag to remove
- Throws:
UnsupportedOperationException
-
getAllFlagsString
Description copied from interface:Portal
Gets 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:
getAllFlagsString
in interfacePortal
- Returns:
All of this portal's portal flags in the form of a string
-
getOwnerUUID
Description copied from interface:Portal
Gets the UUID of this portal's ownerA portal's owner is the player that created the portal.
- Specified by:
getOwnerUUID
in 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:RealPortal
Updates 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:
setSignColor
in interfaceRealPortal
- Parameters:
changedColor
-Color to change the sign text to. If null, then the default color will be used
-
getGate
Description copied from interface:RealPortal
Gets the gate belonging to this portal- Specified by:
getGate
in interfaceRealPortal
- Returns:
The gate belonging to this portal
-
destroy
public void destroy()Description copied from interface:Portal
The 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:RealPortal
Closes 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:
close
in interfaceRealPortal
- Parameters:
relatedOpenTime
-The time this portal was opened
-
getExit
public org.bukkit.Location getExit()Description copied from interface:RealPortal
Gets the exit location of this portal- Specified by:
getExit
in interfaceRealPortal
- Returns:
The exit location of this portal
-
getId
Description copied from interface:Portal
Gets the unique identifier for this portal -
activate
public void activate(@Nullable @Nullable org.bukkit.entity.Player player) Description copied from interface:RealPortal
Activates this portal for the given player during internally specified time- Specified by:
activate
in interfaceRealPortal
- Parameters:
player
-The player to activate this portal for
-
isActive
public boolean isActive()- Specified by:
isActive
in interfaceRealPortal
- Returns:
True if this portal is active
-
getActivatorUUID
- Specified by:
getActivatorUUID
in 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:RealPortal
Deactivate this portal- Specified by:
deactivate
in interfaceRealPortal
-
setMetadata
Description copied from interface:MetadataHolder
Set metadata for this portal. This sets all metadata for this entity, it's advised to useMetadataHolder.setMetadata(JsonElement, String)
- Specified by:
setMetadata
in interfaceMetadataHolder
- Parameters:
data
-The meta data to set
-
getMetadata
Description copied from interface:MetadataHolder
Get metadata for this portal. This gets all metadata for this entity, it's advised to use theMetadataHolder.getMetadata(String)
method- Specified by:
getMetadata
in interfaceMetadataHolder
- Returns:
The meta data of this portal
-
getStorageType
Description copied from interface:Portal
Gets how the portal is stored- Specified by:
getStorageType
in interfacePortal
- Returns:
The storage type of the portal
-
setName
Description copied from interface:Portal
Changes 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:RealPortal
Get the facing entities exit from this portal.- Specified by:
getExitFacing
in interfaceRealPortal
- Returns:
The facing entities exit from this portal.
-
setSavedToStorage
public void setSavedToStorage() -
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyed
in interfacePortal
- Returns:
True if this portal has been destroyed
-
getBehavior
- Specified by:
getBehavior
in interfaceRealPortal
- Returns:
The behavior which defines this portal destination selection and sign text
-
setBehavior
Description copied from interface:RealPortal
Modify the behavior this portal uses- Specified by:
setBehavior
in interfaceRealPortal
- Parameters:
portalBehavior
-New behavior this portal should follow
-
redrawSigns
public void redrawSigns()Description copied from interface:RealPortal
Redraw all signs in this portal- Specified by:
redrawSigns
in interfaceRealPortal
-