Class Gate
- All Implemented Interfaces:
GateAPI
- Author:
- Thorin
-
Constructor Summary
ConstructorsConstructorDescriptionGate(@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 GatevoidaddPortalPosition(PortalPosition portalPosition) Add a position specific to this GatevoidaddPortalPositions(List<PortalPosition> portalPositions) Add portal positions specific for this GatevoidassignPortal(@NotNull RealPortal realPortal) Assign a real portal to this gatevoidcalculatePortalPositions(boolean alwaysOn) Calculates all portal positions for this gatevoidclose()Closes this gatevoiddrawControlMechanisms(LineData[] lines) Set button and draw signvoidModify the world such that the gate follows its gateformatorg.bukkit.LocationgetExit()Gets the exit location of this gateorg.bukkit.block.BlockFaceGets the block face defining this gate's directionbooleangetFlipZ()Gets whether this gate has been flipped on the z-axis@NotNull GateFormatAPIGets the gate format used by this gateorg.bukkit.LocationgetLocation(@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.VectorgetRelativeVector(org.bukkit.Location location) Gets a vector relative to this gate's top-left location using the given locationorg.bukkit.LocationGets this gate's top-left locationbooleanisOpen()Gets whether this gate is currently openbooleanisValid()Check if this gate with the current settings is validbooleanmatchesFormat(@NotNull org.bukkit.Location location, boolean alwaysOn) Checks if the built stargate matches this gate's formatvoidopen()Opens this gatevoidredrawPosition(PortalPosition portalPosition, @Nullable LineData[] lines) Update the state on the portal position according to its type@Nullable PortalPositionremovePortalPosition(org.bukkit.Location location) Remove portal position at specified locationvoidremovePortalPosition(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:GateAPISet button and draw sign- Specified by:
drawControlMechanismsin interfaceGateAPI
-
redrawPosition
Description copied from interface:GateAPIUpdate the state on the portal position according to its type- Specified by:
redrawPositionin interfaceGateAPI- Parameters:
portalPosition-The portal position to update
-
getPortalPositions
Description copied from interface:GateAPIGets a copy of this gate's portal positions- Specified by:
getPortalPositionsin interfaceGateAPI- Returns:
A copy of this gate's portal positions
-
getLocations
Description copied from interface:GateAPIGets all locations of this gate containing the given structure type- Specified by:
getLocationsin 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:GateAPIOpens this gate -
close
public void close()Description copied from interface:GateAPICloses this gate -
getExit
public org.bukkit.Location getExit()Description copied from interface:GateAPIGets the exit location of this gate -
isOpen
public boolean isOpen()Description copied from interface:GateAPIGets whether this gate is currently open -
getFormat
Description copied from interface:GateAPIGets the gate format used by this gate -
getFacing
public org.bukkit.block.BlockFace getFacing()Description copied from interface:GateAPIGets the block face defining this gate's direction -
getFlipZ
public boolean getFlipZ()Description copied from interface:GateAPIGets 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:GateAPIGets a vector relative to this gate's top-left location using the given location- Specified by:
getRelativeVectorin 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:GateAPIGets a location from a relative vector- Specified by:
getLocationin 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:GateAPICheck if this gate with the current settings is valid- Specified by:
isValidin interfaceGateAPI- Returns:
True if this gate is valid
- Throws:
GateConflictException-If this gate conflicts with another gate
-
calculatePortalPositions
Description copied from interface:GateAPICalculates all portal positions for this gate- Specified by:
calculatePortalPositionsin interfaceGateAPI- Parameters:
alwaysOn-Whether this gate is always on
- Throws:
InvalidStructureException
-
getTopLeft
public org.bukkit.Location getTopLeft()Description copied from interface:GateAPIGets this gate's top-left location- Specified by:
getTopLeftin interfaceGateAPI- Returns:
This gate's top-left location
-
addPortalPosition
public PortalPosition addPortalPosition(org.bukkit.Location location, PositionType type, String pluginName) Description copied from interface:GateAPIAdd a position specific for this Gate- Specified by:
addPortalPositionin interfaceGateAPI- Parameters:
location-The location of the position
type-The type of position
- Returns:
The added portal position
-
addPortalPosition
Description copied from interface:GateAPIAdd a position specific to this Gate- Specified by:
addPortalPositionin interfaceGateAPI- Parameters:
portalPosition-The portal position
-
removePortalPosition
Description copied from interface:GateAPIRemove portal position at specified location- Specified by:
removePortalPositionin interfaceGateAPI- Parameters:
location- The location of the portal position to be removed- Returns:
The removed portal position
-
removePortalPosition
Description copied from interface:GateAPIRemove 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:
removePortalPositionin interfaceGateAPI- Parameters:
portalPosition-The portal position to remove
-
forceGenerateStructure
public void forceGenerateStructure()Description copied from interface:GateAPIModify the world such that the gate follows its gateformat- Specified by:
forceGenerateStructurein 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:GateAPIAssign a real portal to this gate- Specified by:
assignPortalin interfaceGateAPI- Parameters:
realPortal-The portal to assign to this gate
-
getPortal
Description copied from interface:GateAPIGet the portal assigned to this portal position
-