Keeping Players In Minecarts

Discussion in 'Plugin Development' started by floop222, Feb 8, 2015.

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

    floop222

    Does anyone know how I would go about coding something to keep players in minecarts so they can't warp out or get out? I know there's a way todo it, but I don't know how I would go about doing it

    Thankyou :)
     
  2. Offline

    Sheepii

    Code:
    
    @EventHandler(priority = EventPriority.HIGHEST)
        public void playerLeave(VehicleExitEvent event){
            if(condition){
                event.setCancelled(true);
            }
        }
        @EventHandler(priority = EventPriority.HIGHEST)
        public void playerUseCommand(PlayerCommandPreprocessEvent event){
            if(event.getPlayer().isInsideVehicle()){
                event.setCancelled(true);
            }
        }
    
    This is the basic framework of what you would work with. Be sure to register your listeners, extend listener on the class, and fill in a condition.
     
  3. Offline

    RingOfStorms

    I'm fairly certain, although may be wrong, that the VehicleExitEvent has not worked for the past year or so. Instead you have to edit the inbound vehicle steer packet and replace the boolean with false if it is true for dismounting.

    And blocking commands seems kind of dumb to me, why would that prevent them from getting out of the cart? Anyone could TP them out, and now you've just disabled any command possible that may have intentions of working while on a minecart.

    Instead of disabling every single command you can simply listen the the PlayerTeleportEvent and cancel that.
     
Thread Status:
Not open for further replies.

Share This Page