Disabling Sneaking

Discussion in 'Plugin Development' started by hunajameloni, Mar 29, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    hunajameloni

    Is there way to disable sneaking in Minecraft with plugins?
    Can someone lead me way to solution or share piece of code?

    (Posted this on Bukkit Help, but realized it was wrong place to post this)
     
  2. Offline

    Freack100

    Code:java
    1. @EventHandler
    2. public void onPlayerMove(PlayerMoveEvent evt){
    3. Player p = evt.getPlayer();
    4. if(p.isSneaking()){
    5. p.setSneaking(false);
    6. }
    7. }


    Everytime a player is moving and sneaking, he loses his sneaking. I don't know a way to prevent them from sneaking while they're not moving without a scheduler (which would lag I think).
     
  3. Offline

    hunajameloni

    Thanks! I will try it!

    Freack100
    It's not working :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Sharkfang17


    Code:
    @EventHandler
        public void p(PlayerToggleSneakEvent e) {
            Player p = e.getPlayer();
            //permission here?
                e.setCancelled(true);
            }
        }
    Players will still be able to gain the benefits of sneaking (like not being able to fall off blocks), and they will see themselves sneaking, but other players will not see them sneaking.
     
  5. Offline

    RawCode

    wont work as you want.

    sneaking state is client sided and there is no way to force it on client's side.
     
  6. Offline

    hunajameloni

    Sharkfang17 RawCode
    Okay
    And nvm I found out to do that plugin without disabling sbeaking :)
     
Thread Status:
Not open for further replies.

Share This Page