1st teleport always result on player moved wrongly

Discussion in 'Plugin Development' started by lecreep, Nov 30, 2019.

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

    lecreep

    Code:
    public void onPlayerInteract(PlayerInteractEvent  event) {
       Player player=event.getPlayer();
       Location location=new Location(player.getWorld(),-2461,43,326);
       player.teleport(location,TeleportCause.PLUGIN);
    }
    With this code if I put a presure plate and walk over it at the first ¿Tick? get a warning "Player moved wrongly!" al the second ¿Tick? over the plate the teleport works well.

    Exist a cooldown to avoid bounce infinitely, currently the procces is... put over plate, got warning, wait cooldown while recieve "cooldown messages" on each tick of plate and teleport at the first tick where cooldown is ended, but if right click the pressure plate the event is fired twice and the teleport is instantly. Im not searching right click works like over plate but dont undertand why can teleport without pass cooldown and why first teleport never works

    What am I missing?
     
  2. Do you cancel the event? If not check what happens if you do
     
  3. Offline

    lecreep

    Code:
    public void onPlayerInteract(PlayerInteractEvent  event) {
       event.setCancelled(true);
       Player player=event.getPlayer();
       Location location=new Location(player.getWorld(),-2461,43,326);
       Boolean tpReturnedValue=player.teleport(location,TeleportCause.PLUGIN);
    }
    I cant put over the plate, at the first moment the plate is activated got the "Player mover wrongly" and some that seems a mini teleport happens, continuously, feels like a hidden wall over the plate

    tpReturnedValue is true
     
    Last edited: Dec 1, 2019
Thread Status:
Not open for further replies.

Share This Page