Class PlayerJoinAttemptEvent

java.lang.Object
org.bukkit.event.Event
dev.despical.whackme.api.event.WhackMeEvent
dev.despical.whackme.api.event.player.PlayerEvent
dev.despical.whackme.api.event.player.PlayerJoinAttemptEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public final class PlayerJoinAttemptEvent extends PlayerEvent implements org.bukkit.event.Cancellable
Called after built-in arena checks pass but before a player is added to a Whack Me game.

Cancelling the event prevents the join without modifying the target Game. This is the extension point for custom permissions, queues, maintenance rules, or third-party cooldowns.

@EventHandler
public void onJoinAttempt(PlayerJoinAttemptEvent event) {
    if (maintenanceArenas.contains(event.getGame().getArena().getId())) {
        event.setCancelled(true);
        event.getPlayer().sendMessage("This arena is under maintenance.");
    }
}

API Note: Cancellation does not send a message automatically. A listener cancelling the attempt should explain the reason to the player when useful.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    PlayerJoinAttemptEvent(org.bukkit.entity.Player player, Game game)
    Creates a join attempt event.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the game the player is attempting to join.
    static org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.event.HandlerList
    boolean
    Returns whether a listener has denied this join attempt.
    void
    setCancelled(boolean cancel)
    Sets whether the player should be prevented from joining.

    Methods inherited from class PlayerEvent

    getPlayer, getUser, toString

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PlayerJoinAttemptEvent

      public PlayerJoinAttemptEvent(org.bukkit.entity.Player player, Game game)
      Creates a join attempt event.
      Parameters:
      player - player attempting to join
      game - target game
  • Method Details

    • getGame

      public Game getGame()
      Returns the game the player is attempting to join.
      Returns:
      target game
    • isCancelled

      public boolean isCancelled()
      Returns whether a listener has denied this join attempt.
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
      Returns:
      true when the join is cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Sets whether the player should be prevented from joining.
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
      Parameters:
      cancel - true to deny the join attempt
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Specified by:
      getHandlers in class org.bukkit.event.Event
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()