Teleporting Player who also has passengers

Discussion in 'Plugin Development' started by Chr0mosom3, Dec 1, 2021.

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

    Chr0mosom3

    Hallo,

    I am trying to teleport a player who has passengers riding him, a silverfish, a armorstand, another silverfish, and another armor stand. When I try to teleport the player it doesn't work. When I /kill the armorstand and silverfish the teleport suddenly works. Anyone know the problem?

    My code, but probably useless
    Code:
    if (!EndLock.isEndLocked() && !EndLock.isEndPvpEnabled()) {
           player.teleport(EndLock.getEndLocation());
           player.sendMessage(ChatColor.GRAY + "Teleported to the end");
         } else {
           player.sendMessage(ChatColor.RED + "ERROR: End teleport is disabled");
         }
    
    I know for sure the code runs because I when I added debugging messages they displayed. Another thing I should point out is that PlayerPortalEvent (going into the end portal) is not called when the entities are riding the player also.
     
  2. Offline

    KarimAKL

    @Chr0mosom3 I don't think you can teleport entities when someone is riding them. However, you can remove them as passengers, then teleport the entity and add them back as passengers.
     
    Chr0mosom3 likes this.
  3. Offline

    Chr0mosom3

    @KarimAKL

    That's wierd. I have another question, can I detect when any plugin is trying to teleport a player and remove the passengers and add them again. Is there something I can listen to?

    Another thing, if the playerportalevent isn't recognized when the player has passengers, how am I supposed to detect when the player enters the nether/end?
     
    Last edited: Dec 1, 2021
  4. Offline

    KarimAKL

    Unfortunately, no. Unless the other plugin is calling the teleport event, you cannot listen for it.

    Did you test it?
     
  5. Offline

    Chr0mosom3

    I did test it. It doesn't work and now I'm depressed. I'm trying to find a workaround by checking the player's location every tick and seeing if he's standing in a end_portal object and calling the teleport event. Do you know a better method to do this?
     
Thread Status:
Not open for further replies.

Share This Page