001 package org.bukkit.event.player; 002 003 import org.bukkit.entity.Player; 004 import org.bukkit.event.Cancellable; 005 import org.bukkit.event.HandlerList; 006 007 /** 008 * Called when a player toggles their sneaking state 009 */ 010 public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable { 011 private static final HandlerList handlers = new HandlerList(); 012 private final boolean isSneaking; 013 private boolean cancel = false; 014 015 public PlayerToggleSneakEvent(final Player player, final boolean isSneaking) { 016 super(player); 017 this.isSneaking = isSneaking; 018 } 019 020 /** 021 * Returns whether the player is now sneaking or not. 022 * 023 * @return sneaking state 024 */ 025 public boolean isSneaking() { 026 return isSneaking; 027 } 028 029 public boolean isCancelled() { 030 return cancel; 031 } 032 033 public void setCancelled(boolean cancel) { 034 this.cancel = cancel; 035 } 036 037 @Override 038 public HandlerList getHandlers() { 039 return handlers; 040 } 041 042 public static HandlerList getHandlerList() { 043 return handlers; 044 } 045 }