Record Class SkyDropRequest

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.world.SkyDropRequest
Record Components:
anchor - the point to stay near; its world is the world the drop happens in
horizontalRadius - how far from the anchor a point may be chosen, in blocks; 0 keeps the drop directly above the anchor
altitude - how far above the ground the player should appear, in blocks
clearance - how many free blocks have to sit under the drop point, which is what stops a player being handed a glide with nowhere to glide
attempts - how many candidate points to try before giving up
requireInsideBorder - whether the point has to lie inside the world's current border

public record SkyDropRequest(@NotNull org.bukkit.Location anchor, double horizontalRadius, int altitude, int clearance, int attempts, boolean requireInsideBorder) extends Record
Where a player should be put back into the sky above a world.

A request describes an area rather than a point: an anchor to stay near, how far from it a point may be chosen, how high above the ground the player should appear, and how much free air has to be underneath them. SkyDropService turns that into an actual location, or into nothing at all when the area cannot offer one.

Instances are immutable and the anchor is copied on the way in and out, so a request can be held on to and reused across matches without a later teleport changing what it meant.

Since:
1.6.0
  • Constructor Details

    • SkyDropRequest

      public SkyDropRequest(@NotNull @NotNull org.bukkit.Location anchor, double horizontalRadius, int altitude, int clearance, int attempts, boolean requireInsideBorder)
      Creates an instance of a SkyDropRequest record class.
      Parameters:
      anchor - the value for the anchor record component
      horizontalRadius - the value for the horizontalRadius record component
      altitude - the value for the altitude record component
      clearance - the value for the clearance record component
      attempts - the value for the attempts record component
      requireInsideBorder - the value for the requireInsideBorder record component
  • Method Details

    • anchor

      public org.bukkit.Location anchor()
      Returns the value of the anchor record component.
      Returns:
      the value of the anchor record component
    • above

      @NotNull public static @NotNull SkyDropRequest above(@NotNull @NotNull org.bukkit.Location anchor)
      A drop directly above one point, high enough to glide from.

      The defaults suit a player re-entering a match from the air; narrow them with the with* methods rather than calling the canonical constructor.

    • withinRadius

      @NotNull public @NotNull SkyDropRequest withinRadius(double radius)
      How far from the anchor a point may be chosen.
    • atAltitude

      @NotNull public @NotNull SkyDropRequest atAltitude(int blocks)
      How far above the ground the player appears.
    • withClearance

      @NotNull public @NotNull SkyDropRequest withClearance(int blocks)
      How much free air the drop point needs beneath it.
    • withAttempts

      @NotNull public @NotNull SkyDropRequest withAttempts(int value)
      How many candidate points to try before giving up.
    • insideBorder

      @NotNull public @NotNull SkyDropRequest insideBorder(boolean require)
      Whether the point has to lie inside the world's current border.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • horizontalRadius

      public double horizontalRadius()
      Returns the value of the horizontalRadius record component.
      Returns:
      the value of the horizontalRadius record component
    • altitude

      public int altitude()
      Returns the value of the altitude record component.
      Returns:
      the value of the altitude record component
    • clearance

      public int clearance()
      Returns the value of the clearance record component.
      Returns:
      the value of the clearance record component
    • attempts

      public int attempts()
      Returns the value of the attempts record component.
      Returns:
      the value of the attempts record component
    • requireInsideBorder

      public boolean requireInsideBorder()
      Returns the value of the requireInsideBorder record component.
      Returns:
      the value of the requireInsideBorder record component