Class Gate
- All Implemented Interfaces:
GateAPI
- Author:
- Thorin
-
Constructor Summary
ConstructorDescriptionGate
(@NotNull GateFormatAPI format, @NotNull org.bukkit.Location signLocation, org.bukkit.block.BlockFace signFace, boolean alwaysOn, @NotNull RegistryAPI registry) Instantiates a new gateGate
(GateData gateData, @NotNull RegistryAPI registry) Instantiates a gate from already predetermined parameters, no checking is done to see if format matches -
Method Summary
Modifier and TypeMethodDescriptionaddPortalPosition
(org.bukkit.Location location, PositionType type, String pluginName) Add a position specific for this GateaddPortalPosition
(org.bukkit.util.BlockVector relativeBlockVector, PositionType type, String pluginName) Add a position specific for this Gatevoid
addPortalPosition
(PortalPosition portalPosition) Add a position specific to this Gatevoid
addPortalPositions
(List<PortalPosition> portalPositions) Add portal positions specific for this Gatevoid
assignPortal
(@NotNull RealPortal realPortal) Assign a real portal to this gatevoid
calculatePortalPositions
(boolean alwaysOn) Calculates all portal positions for this gatevoid
close()
Closes this gatevoid
drawControlMechanisms
(LineData[] lines) Set button and draw signvoid
Modify the world such that the gate follows its gateformatorg.bukkit.Location
getExit()
Gets the exit location of this gateorg.bukkit.block.BlockFace
Gets the block face defining this gate's directionboolean
getFlipZ()
Gets whether this gate has been flipped on the z-axis@NotNull GateFormatAPI
Gets the gate format used by this gateorg.bukkit.Location
getLocation
(@NotNull org.bukkit.util.Vector vector) Gets a location from a relative vectorgetLocations
(GateStructureType structureType) Gets all locations of this gate containing the given structure typeGet the portal assigned to this portal positionGets a copy of this gate's portal positionsorg.bukkit.util.Vector
getRelativeVector
(org.bukkit.Location location) Gets a vector relative to this gate's top-left location using the given locationorg.bukkit.Location
Gets this gate's top-left locationboolean
isOpen()
Gets whether this gate is currently openboolean
isValid()
Check if this gate with the current settings is validboolean
matchesFormat
(@NotNull org.bukkit.Location location, boolean alwaysOn) Checks if the built stargate matches this gate's formatvoid
open()
Opens this gatevoid
redrawPosition
(PortalPosition portalPosition, @Nullable LineData[] lines) Update the state on the portal position according to its type@Nullable PortalPosition
removePortalPosition
(org.bukkit.Location location) Remove portal position at specified locationvoid
removePortalPosition
(PortalPosition portalPosition) Remove a portal position from this gate.
-
Constructor Details
-
Gate
public Gate(@NotNull @NotNull GateFormatAPI format, @NotNull @NotNull org.bukkit.Location signLocation, org.bukkit.block.BlockFace signFace, boolean alwaysOn, @NotNull @NotNull RegistryAPI registry) throws InvalidStructureException, GateConflictException Instantiates a new gate- Parameters:
format
-The gate format used by this gate
signLocation
-The location of this gate's sign
signFace
-The direction this gate's sign is facing
alwaysOn
-Whether this gate has been set as always-on
- Throws:
InvalidStructureException
-If the physical stargate at the given location does not match the given format
GateConflictException
-If this gate is in conflict with an existing one
-
Gate
public Gate(GateData gateData, @NotNull @NotNull RegistryAPI registry) throws InvalidStructureException Instantiates a gate from already predetermined parameters, no checking is done to see if format matches- Parameters:
gateData
-Data of the gate
- Throws:
InvalidStructureException
-If the facing is invalid or if no format could be found
-
-
Method Details
-
drawControlMechanisms
Description copied from interface:GateAPI
Set button and draw sign- Specified by:
drawControlMechanisms
in interfaceGateAPI
-
redrawPosition
Description copied from interface:GateAPI
Update the state on the portal position according to its type- Specified by:
redrawPosition
in interfaceGateAPI
- Parameters:
portalPosition
-The portal position to update
-
getPortalPositions
Description copied from interface:GateAPI
Gets a copy of this gate's portal positions- Specified by:
getPortalPositions
in interfaceGateAPI
- Returns:
A copy of this gate's portal positions
-
getLocations
Description copied from interface:GateAPI
Gets all locations of this gate containing the given structure type- Specified by:
getLocations
in interfaceGateAPI
- Parameters:
structureType
-The structure type to get locations of
- Returns:
All locations containing the given structure type
-
open
public void open()Description copied from interface:GateAPI
Opens this gate -
close
public void close()Description copied from interface:GateAPI
Closes this gate -
getExit
public org.bukkit.Location getExit()Description copied from interface:GateAPI
Gets the exit location of this gate -
isOpen
public boolean isOpen()Description copied from interface:GateAPI
Gets whether this gate is currently open -
getFormat
Description copied from interface:GateAPI
Gets the gate format used by this gate -
getFacing
public org.bukkit.block.BlockFace getFacing()Description copied from interface:GateAPI
Gets the block face defining this gate's direction -
getFlipZ
public boolean getFlipZ()Description copied from interface:GateAPI
Gets whether this gate has been flipped on the z-axis -
getRelativeVector
public org.bukkit.util.Vector getRelativeVector(org.bukkit.Location location) Description copied from interface:GateAPI
Gets a vector relative to this gate's top-left location using the given location- Specified by:
getRelativeVector
in interfaceGateAPI
- Parameters:
location
-The location to turn into a relative location
- Returns:
A location relative to this gate's top-left location
-
getLocation
public org.bukkit.Location getLocation(@NotNull @NotNull org.bukkit.util.Vector vector) Description copied from interface:GateAPI
Gets a location from a relative vector- Specified by:
getLocation
in interfaceGateAPI
- Parameters:
vector
-The vector defining a location
- Returns:
The location corresponding to the given vector
-
matchesFormat
public boolean matchesFormat(@NotNull @NotNull org.bukkit.Location location, boolean alwaysOn) throws GateConflictException Checks if the built stargate matches this gate's formatThis will try to match the format regardless of which control block the sign was placed on TODO: symmetric formats will be checked twice, make a way to determine if a format is symmetric to avoid this
- Parameters:
location
-The location of a control-block
alwaysOn
-Whether the new portal is set as always-on
- Returns:
True if the built stargate matches this format
- Throws:
GateConflictException
-If the built stargate conflicts with another gate
-
isValid
Description copied from interface:GateAPI
Check if this gate with the current settings is valid- Specified by:
isValid
in interfaceGateAPI
- Returns:
True if this gate is valid
- Throws:
GateConflictException
-If this gate conflicts with another gate
-
calculatePortalPositions
Description copied from interface:GateAPI
Calculates all portal positions for this gate- Specified by:
calculatePortalPositions
in interfaceGateAPI
- Parameters:
alwaysOn
-Whether this gate is always on
- Throws:
InvalidStructureException
-
getTopLeft
public org.bukkit.Location getTopLeft()Description copied from interface:GateAPI
Gets this gate's top-left location- Specified by:
getTopLeft
in interfaceGateAPI
- Returns:
This gate's top-left location
-
addPortalPosition
public PortalPosition addPortalPosition(org.bukkit.Location location, PositionType type, String pluginName) Description copied from interface:GateAPI
Add a position specific for this Gate- Specified by:
addPortalPosition
in interfaceGateAPI
- Parameters:
location
-The location of the position
type
-The type of position
- Returns:
The added portal position
-
addPortalPosition
Description copied from interface:GateAPI
Add a position specific to this Gate- Specified by:
addPortalPosition
in interfaceGateAPI
- Parameters:
portalPosition
-The portal position
-
removePortalPosition
Description copied from interface:GateAPI
Remove portal position at specified location- Specified by:
removePortalPosition
in interfaceGateAPI
- Parameters:
location
- The location of the portal position to be removed- Returns:
The removed portal position
-
removePortalPosition
Description copied from interface:GateAPI
Remove a portal position from this gate. Does not remove the portal position in the registry or database. Please useRegistryAPI.removePortalPosition(Location)
with conjunction toStorageAPI.removePortalPosition(RealPortal, StorageType, PortalPosition)
- Specified by:
removePortalPosition
in interfaceGateAPI
- Parameters:
portalPosition
-The portal position to remove
-
forceGenerateStructure
public void forceGenerateStructure()Description copied from interface:GateAPI
Modify the world such that the gate follows its gateformat- Specified by:
forceGenerateStructure
in interfaceGateAPI
-
addPortalPosition
public PortalPosition addPortalPosition(org.bukkit.util.BlockVector relativeBlockVector, PositionType type, String pluginName) Add a position specific for this Gate- Parameters:
relativeBlockVector
-The relative position in format space
type
-The type of position
-
addPortalPositions
Add portal positions specific for this Gate- Parameters:
portalPositions
-A list of portalPositions
-
assignPortal
Description copied from interface:GateAPI
Assign a real portal to this gate- Specified by:
assignPortal
in interfaceGateAPI
- Parameters:
realPortal
-The portal to assign to this gate
-
getPortal
Description copied from interface:GateAPI
Get the portal assigned to this portal position
-