Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-1124

Changed To-Location on Teleport event ignored

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • None

      On some PlayerTeleportEvent events, when changing the "to-location" via the setTo(Location) method, the player will not be teleportet to the new location but the one initially returned by the event. This happens for example when leaving a vehicle.
      It seems to be a new bug in 1.8.8 - the 1.8.7 versions work as they should.

      I did some tracing and the problem appears to be in the PlayerConnection#a(double, double, double, float, float, Set<EnumPlayerTeleportFlags>) method, if the decompiled source is correct:

          // line 496 ff
          Location to = new Location(getPlayer().getWorld(), x, y, z, yaw, pitch);
          PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
          this.server.getPluginManager().callEvent(event);
      
          // line 500
          if ((event.isCancelled()) || (to.equals(event.getTo()))) {
            set.clear();
            to = event.isCancelled() ? event.getFrom() : event.getTo();
            d0 = to.getX();
            d1 = to.getY();
            d2 = to.getZ();
            f = to.getYaw();
            f1 = to.getPitch();
          }
      
          internalTeleport(d0, d1, d2, f, f1, set);
      

      From my understanding, the second condition of the if statement in line 500 should be inverted, as the target location should be updated when the to location has changed, and not if it is still the same:

          // line 500
          if ((event.isCancelled()) || (!to.equals(event.getTo()))) {
      

      Regards, minoneer

            Unassigned Unassigned
            minoneer minoneer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: