Solved Cancel leaving "player" vehicle

Discussion in 'Plugin Development' started by andre111, Apr 18, 2014.

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

    andre111

    I'm stacking multiple Players using setPassenger and now I want to disable leaving the stack using the shift key. But the VehicleExitEvent doesn't even seem to get triggered, is there another one?
     
  2. Offline

    keizermark

    Code:
    @EventHandler
          public void onVehicleExit(VehicleExitEvent event) {
           
                  if (event.getVehicle() instanceof Minecart) {
                      event.setcanceled(true)
                   
                  }
              }
        }
    A vehicleExitEvent and the cancel it?
     
  3. Offline

    andre111

    I allready tried that but it doesn't seem to get called when a player stops "riding" another player(not sure for other entities)
     
  4. Offline

    Wolfey

    andre111 Are you registering your events?
     
  5. Offline

    Konkz

    It's broken. You have to add player to an ArrayList for example when they enter and make a check to see if they are in. If not get them back in there - to get them out just remove them from that List when you want.
     
  6. Offline

    Shevchik

    The vehicle exit event is not called in this case because CraftPlayer is not implementing Vehicle.
    You will need to listen for the packet and cancel it using protocollib.
     
  7. Offline

    andre111

    Thanks, as I am allready using protocollib or many things I will most likely go that rute
     
  8. Offline

    MojoJojo1804

    If you found any solution for this, please explain it here.
     
  9. Offline

    RingOfStorms

    Using protocol lib you set the steer vehicle unmount boolean to false.

    Code:
    getProtocolManager().addPacketListener(new PacketAdapter(RCadeAPI.getRCade(), PacketType.Play.Client.STEER_VEHICLE) {
        @Override
        public void onPacketReceiving (com.comphenix.protocol.events.PacketEvent e) {
            if(e.getPacketType() == PacketType.Play.Client.STEER_VEHICLE) {
                if(e.getPacket().getHandle() instanceof PacketPlayInSteerVehicle) {
                    Field f = null;
                    try {
                        f = PacketPlayInSteerVehicle.class.getDeclaredField("d");
                        f.setAccessible(true);
                        f.set(e.getPacket().getHandle(), false);
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
     
        @Override
        public void onPacketSending (com.comphenix.protocol.events.PacketEvent e) {}
    });
    
     
    MojoJojo1804 likes this.
  10. Offline

    _Filip

    April 18th, dude.
     
Thread Status:
Not open for further replies.

Share This Page