Class ClaimCreateEvent

java.lang.Object
org.bukkit.event.Event
net.mathias2246.buildmc.api.event.CustomEvent
net.mathias2246.buildmc.api.event.claims.ClaimCreateEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public class ClaimCreateEvent extends CustomEvent implements org.bukkit.event.Cancellable
Called when one or more claims are created.

This event is fired synchronously on the main server thread, before the claims are persisted to the database. Because the claims have not yet been persisted, Claim.getId() will always return null for every claim in this event — the ID is assigned by the database layer once the claim is actually saved.

If the event is cancelled, none of the claims will be created.

Once the claims have been successfully persisted, ClaimRegisteredEvent is fired with the fully persisted claims (i.e. Claim.getId() populated).

See Also:
  • Constructor Details

    • ClaimCreateEvent

      public ClaimCreateEvent(@NotNull @NotNull List<@NotNull Claim> claims)
      Constructs a new ClaimCreateEvent for multiple claims.
      Parameters:
      claims - the claims that are about to be created. Note that Claim.getId() will be null for each of these, as they have not yet been persisted. Once persisted, ClaimRegisteredEvent will be fired with the fully populated claims.
    • ClaimCreateEvent

      public ClaimCreateEvent(@NotNull @NotNull Claim claim)
      Constructs a new ClaimCreateEvent for a claim.
      Parameters:
      claim - the claim that is about to be created. Note that Claim.getId() will be null, as it has not yet been persisted. Once persisted, ClaimRegisteredEvent will be fired with the fully populated claim.
  • Method Details

    • getClaims

      @NotNull public @NotNull com.google.common.collect.ImmutableList<@NotNull Claim> getClaims()
      Gets an immutable list of claims being created.

      As these claims have not yet been persisted to the database, Claim.getId() will always return null for each of them. See ClaimRegisteredEvent for an equivalent event fired after persistence, where the IDs are populated.

      Returns:
      all claims included in this creation operation
    • getClaim

      @NotNull public @NotNull Claim getClaim()
      Convenience method for single-claim operations.

      If multiple claims are present, this returns the first one. Plugins that care about bulk operations (BulkMC-Core xD) should use getClaims().

      As with getClaims(), the returned claim has not yet been persisted, so Claim.getId() will return null. See ClaimRegisteredEvent.getClaim() for the persisted equivalent.

      Returns:
      the first claim in the list
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
    • setCancelled

      public void setCancelled(boolean cancel)
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Description copied from class: CustomEvent
      Returns the HandlerList for this event type.

      Bukkit requires each concrete event class to define its own static HandlerList instance and to return it from this method. This is necessary for Bukkit’s event registration and dispatch system.

      Specified by:
      getHandlers in class CustomEvent
      Returns:
      the handler list for this event (never null)
    • getHandlerList

      @NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()
      Required by the Bukkit event system for registration.
      Returns:
      the static handler list