Solved Stop Player to leave horse

Discussion in 'Plugin Development' started by RFUDEO9EH, Apr 1, 2020.

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

    RFUDEO9EH

    @EventHandler
    public void onQUIt(PlayerToggleSneakEvent e) {
    Player p = e.getPlayer();
    p.sendMessage("gg1");
    if(p.isInsideVehicle()) {
    p.sendMessage("gg2");
    }
    }

    I try this but it's doesn't work, I want to cancel the event that when player shift for leave a horse. Can't you help me ?? the code above don't work
     
  2. Offline

    NukerFall

    use LeaveVehicle event
     
  3. Offline

    wand555

    Didn't test, but cancel VehicleExitEvent when it's a player on a horse?
     
  4. Offline

    RFUDEO9EH

    work with pig, horse and minecart but someone know another way for other entity (non rideable like this one) for exemple witch, zombie...
     
  5. Offline

    wand555

    A horse is a sub-interface from Vehicle so I think it should work.
    Don't know what you mean with 'non rideable' as you cannot block a player from leaving something he cannot enter in the first place.
     
  6. Offline

    RFUDEO9EH

    it works great for horse but i just want to know for 'non rideable' (.setPassenger(p) on a entity that is normaly non rideable) how we can do that.
     
  7. Offline

    wand555

    I assume you can't. Only way I can imagine, would be to have an invisible rideable entity teleport to the non-rideable entity constantly.
     
  8. Offline

    RFUDEO9EH

    Solved : best way for horse, pig, minecart is VehicleExitEvent, for other entity, use a timer task.
     
Thread Status:
Not open for further replies.

Share This Page