Class StructureSign
- Direct Known Subclasses:
CommandSign
,MobSign
,MythicMobSign
,NPCSign
You can access the arguments by using the get...Argument methods.
Check if an argument exists by using hasArgument(int)
. The argument numbers correspond to the lines on a sign.
So argument 0 is the second line of the sign. That means there will always be 3 arguments available at maximum.
You are allowed to have an argument on line 2 and line 4 (skipping line 3). That just means hasArgument(int)
will return false when you input 1 and true for 0 or 2.
[SignName]
Argument #0
Argument #1
Argument #2
Do not add a constructor to your implementation.
See MobSign
for an implementation example.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
calculateRangedIntArgument(int argNumber)
Get a random number from within a ranged integer argument.int
calculateRangedIntArgument(int argNumber, int defaultValue)
Get a random number from within a ranged integer argument, but with a default value.double
getDoubleArgument(int argNumber)
Get an argument as a Double.double
getDoubleArgument(int argNumber, double defaultValue)
Get an argument as a Double, but with a default value.int
getIntArgument(int argNumber)
Get an argument as an Integer.int
getIntArgument(int argNumber, int defaultValue)
Get an argument as an Integer, but with a default value.getRangedIntArgument(int argNumber)
Get an argument as a Lower and Upper bound integer range.getRangedIntArgument(int argNumber, int defaultLowerValue, int defaultUpperValue)
Get an argument as a Lower and Upper bound integer range, but with a default range.double
Get the rotation of the sign (in radians).getStringArgument(int argNumber)
Get an argument as a String.org.bukkit.Location
Get the maximum corner of the structure schematic.org.bukkit.Location
Get the minimum corner of the structure schematic.double
Get the rotation of the structure (in radians).int
getStylizedIntArgument(int argNumber)
Get a stylized integer from an argument.boolean
hasArgument(int argNumber)
Check if a certain argument exists.void
initialize(String[] arguments, double signRotation, double structureRotation, org.bukkit.Location structureMinimumLocation, org.bukkit.Location structureMaximumLocation)
Initializes the structure signs with the required arguments.abstract boolean
onStructureSpawn(@NotNull org.bukkit.Location location, @NotNull Structure structure)
The method that is called when a structure is spawned.
-
Constructor Details
-
StructureSign
public StructureSign()Do not overload this constructor.
-
-
Method Details
-
initialize
public final void initialize(String[] arguments, double signRotation, double structureRotation, org.bukkit.Location structureMinimumLocation, org.bukkit.Location structureMaximumLocation)Initializes the structure signs with the required arguments.Internal Use Only.
- Parameters:
arguments
- The string array of arguments.signRotation
- The rotation of the sign.structureRotation
- The rotation of the structure.structureMinimumLocation
- The minimum location of structure schematic.structureMaximumLocation
- The maximum location of the structure schematic.
-
onStructureSpawn
public abstract boolean onStructureSpawn(@NotNull @NotNull org.bukkit.Location location, @NotNull @NotNull Structure structure)The method that is called when a structure is spawned.This method should be implemented by your implementation. Use the get...Argument methods to grab the arguments on the signs.
- Parameters:
location
- The location of the sign.structure
- The structure that was spawned.- Returns:
- True if the sign should be removed, false if it should stay.
-
getSignRotation
public final double getSignRotation()Get the rotation of the sign (in radians).- Returns:
- The rotation of the sign in radians.
-
getStructureRotation
public final double getStructureRotation()Get the rotation of the structure (in radians).- Returns:
- The rotation of the structure in radians.
-
getStructureMinimumLocation
public final org.bukkit.Location getStructureMinimumLocation()Get the minimum corner of the structure schematic.- Returns:
- The minimum corner of the structure schematic.
-
getStructureMaximumLocation
public final org.bukkit.Location getStructureMaximumLocation()Get the maximum corner of the structure schematic.- Returns:
- The maximum corner of the structure schematic.
-
hasArgument
public final boolean hasArgument(int argNumber)Check if a certain argument exists.- Parameters:
argNumber
- The argument number. (0 - 2)- Returns:
- If the argument exists.
-
getStringArgument
Get an argument as a String.- Parameters:
argNumber
- The argument number. (0 - 2)- Returns:
- The argument as a String.
- Throws:
IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-
getIntArgument
public final int getIntArgument(int argNumber)Get an argument as an Integer.- Parameters:
argNumber
- The argument number. (0 - 2)- Returns:
- The argument as an Integer.
- Throws:
NumberFormatException
- If the argument is not a valid integer. (UsegetIntArgument(int, int)
to avoid this exception).IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-
getIntArgument
public final int getIntArgument(int argNumber, int defaultValue)Get an argument as an Integer, but with a default value.- Parameters:
argNumber
- The argument number. (0 - 2)defaultValue
- The default integer to be returned if the argument is not a valid integer.- Returns:
- The argument as an Integer.
- Throws:
IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-
getDoubleArgument
public final double getDoubleArgument(int argNumber)Get an argument as a Double.- Parameters:
argNumber
- The argument number. (0 - 2)- Returns:
- The argument as a Double.
- Throws:
NumberFormatException
- If the argument is not a valid Double. (UsegetDoubleArgument(int, double)
to avoid this exception).IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-
getDoubleArgument
public final double getDoubleArgument(int argNumber, double defaultValue)Get an argument as a Double, but with a default value.- Parameters:
argNumber
- The argument number. (0 - 2)defaultValue
- The default value to be returned if the argument is not a valid Double.- Returns:
- The argument as a Double.
- Throws:
IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-
getRangedIntArgument
Get an argument as a Lower and Upper bound integer range.Example:
[5;10]
- Parameters:
argNumber
- The argument number. (0 - 2).- Returns:
- The argument as a Lower and Upper bound integer range. (Left is lower, right is upper).
- Throws:
NumberFormatException
- If the argument is not formatted correctly. (UsegetRangedIntArgument(int, int, int)
to avoid this exception.)IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-
getRangedIntArgument
public final Pair<Integer,Integer> getRangedIntArgument(int argNumber, int defaultLowerValue, int defaultUpperValue)Get an argument as a Lower and Upper bound integer range, but with a default range.Example:
[5;10]
- Parameters:
argNumber
- The argument number. (0 - 2)defaultLowerValue
- The lower value of the default range.defaultUpperValue
- The upper value of the default range.- Returns:
- The argument as a Lower and Upper bound integer range.
- Throws:
IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-
calculateRangedIntArgument
public final int calculateRangedIntArgument(int argNumber)Get a random number from within a ranged integer argument.Example:
[5;10]
, might return 6.- Parameters:
argNumber
- The argument number. (0 - 2)- Returns:
- A random number from within a ranged integer argument.
- Throws:
NumberFormatException
- If the argument is not a valid integer range. (UsecalculateRangedIntArgument(int, int)
to avoid this exception.)IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-
calculateRangedIntArgument
public final int calculateRangedIntArgument(int argNumber, int defaultValue)Get a random number from within a ranged integer argument, but with a default value.Example:
[5;10]
, might return 6.[10;4]
will return the default value since it is not a valid range.- Parameters:
argNumber
- The argument number. (0 - 2)defaultValue
- The default value to be used when the range is not valid.- Returns:
- A random number from within a ranged integer argument.
- Throws:
IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-
getStylizedIntArgument
public final int getStylizedIntArgument(int argNumber)Get a stylized integer from an argument.This is the same as
calculateRangedIntArgument(int)
, but it also accepts a single integer on top of a range.Valid Inputs:
[5;10]
[-4;3]
20
-5
- Parameters:
argNumber
- The argument number. (0 - 2)- Returns:
- The number represented by the stylized integer. (Defaults to 1 if not a valid format).
- Throws:
IndexOutOfBoundsException
- If argNumber is not within the range of 0 to 2.
-