Finding the Nether Portal's Location

Discussion in 'Plugin Development' started by elaboradi, Dec 17, 2024.

  1. Offline

    elaboradi

    To manage several worlds, I made my own unique plugin that resembles a multiverse. One issue I had to deal with was how to make a player teleport to the nether from one world rather than the level world, which appears to happen automatically.

    I accomplish this by using PlayerChangedWorldEvent. But that event doesn't save the player's teleportation location (i.e., the nether portal); it only saves the World from which they came. Therefore, the best I can do is teleport the player back to the original world's spawn location—not the nether portal—when they return from the nether.

    Does anyone know how I can find out where the player is before teleporting to a different world?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @elaboradi Isn't that event accompanied by a teleport event?
     
    KarimAKL likes this.
  3. Offline

    Smeary_Subset

    I made a plugin similar to multiverse and to accomplish this problem I used PlayerTeleportEvent and checked for TeleportCause.NETHER_PORTAL and TeleportCause.END_PORTAL, and just in case double checked with event.getFrom().getWorld() != event.getTo().getWorld()

    Source: https://bukkit.org/threads/getting-location-of-nether-portal.504161/
     

Share This Page