Solved Getting a player's last location in a specific world

Discussion in 'Plugin Development' started by Lightcaster5, Mar 13, 2020.

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

    Lightcaster5

    Title says it all... How can I get the last location of a player in a specific world in 1.12.2?
     
  2. Offline

    Machine Maker

    Well, I think you would need to keep track of a players last location when they go between worlds (there is a PlayerWorldChangeEvent or something). You would need to keep track and update the players last location when they changed worlds and then store that. There is no built-in way.
     
  3. Offline

    KarimAKL

    @Lightcaster5 Listen to PlayerTeleportEvent and then use event.getFrom().
     
  4. Offline

    Machine Maker

    Did I misunderstand the question? Cause I feel like we answered two different questions @KarimAKL
     
  5. Offline

    KarimAKL

    @Machine Maker If i remember correctly, changing worlds call both the PlayerChangedWorldEvent & the PlayerTeleportEvent, but you can only get the location from the PlayerTeleportEvent, since the PlayerChangedWorldEvent only has the previous world, not the location.
     
  6. Offline

    Machine Maker

    OH, ok, ya that might be right.
     
  7. Offline

    Lightcaster5

    I am looking more for something like, with a queue plugin, when a player leaves the queue, the player is teleported to the main world from the config but I don't know how to get their last location from that world
     
  8. Offline

    KarimAKL

    @Lightcaster5 Then do the following:
    1:
    2: Save the last location, and then load it when they join.
     
  9. Offline

    Lightcaster5

    Let's say a server, BukkitAnarchy.org (example), has been running for about 2 weeks but needs a queue plugin for their player base. They get my queue plugin and drop it into the plugins folder. What is it going to do when players have clearly been in places before but it resets their location? I know storing is a possibility but for the servers that haven't just started out because I feel more and more thing plugin is becoming VERY SPECIFIC on what the server owner must do to compensate for the plugin, not vice vera like things should be.
     
  10. Online

    timtower Administrator Administrator Moderator

    @Lightcaster5 You can't counter that. There is no record of any previous locations.
     
  11. Offline

    Lightcaster5

    Dang ok

    EDIT: Thread is unsolved, marked as solved to close thread.
     
  12. Offline

    KarimAKL

    @Lightcaster5 I'm not sure if this would work but after looking it up, i found this.

    You might be able to get the files from the "world/playerdata" folder, and then get the data from that file. (it's encrypted with NBT)
     
  13. Offline

    Lightcaster5

    This is something I can work with! Thanks for the suggestion, I will post any updates here.
     
Thread Status:
Not open for further replies.

Share This Page