Testing if player sneaks

Discussion in 'Spigot Plugin Development' started by Creatos137, May 13, 2017.

  1. Hey,

    I was wondering if there is a way to test if a player sneaks. I know there is the PlayerToggleSneakEvent but that also runs when you stop holding your sneak button.

    Thank you for your time.
    - Creatos
     
  2. Use the event you posted and check also if player#isSneaking
     
  3. PlayerToggleSneakEvent has an isSneaking method. With that, you can check if the player started to sneak.
     
  4. Even if you don't use the is sneaking button (which you should) in that event you could create a hashmap with a string a a boolean (string being the name), and when they sneak, hashmap#put(string, !hashmap#get(string)