Solved Issues saving location before world change

Discussion in 'Spigot Plugin Development' started by LeOllie, May 15, 2017.

  1. Hi,

    I have a server where it is based around MultiVerse. So each player gets teleported to the "Hub" on join. I am trying to find a way to keep players location in the "Survival" world when they logout/change world.

    I did some code and realized it was saving the location from the world they just changed to. How would you guys suggest I save the location before they leave the world?

    **If you know a plugin that already does this that would be useful. I would've figured multiverse would have an option to stop players being forced to the world spawn. but I cannot see it anywhere.

    Thank you in advance,

    LeOllie.
     
  2. WAS

    WAS

    I believe it would be the same as teleporting from any world. Use the PlayerTeleportEvent#getFrom() and save their location accordingly.

    Check if the world which they are teleporting from is your Survival world, or whatever, and if so, log that location to a map, or some other means.
     
  3. Code (Text):
    @EventHandler
        public void onPlayerQuit(PlayerQuitEvent e) {
            Player p = (Player) e.getPlayer();
            UUID pID = p.getUniqueId();

            if (p.getWorld().getName().equalsIgnoreCase("survival")) {
                if (plugin.getPlayerLoc().getConfigurationSection(pID.toString()) == null) {
                   
                    Double pX = p.getLocation().getX();
                    Double pY = p.getLocation().getY();
                    Double pZ = p.getLocation().getZ();
                    float pPitch = (float) p.getLocation().getPitch();
                    float pYaw = (float) p.getLocation().getYaw();

                    plugin.getPlayerLoc().createSection(pID.toString());
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.world", "Survival");
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.x", pX);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.y", pY);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.z", pZ);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.pitch", pPitch);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.yaw", pYaw);
                    plugin.savePlayerLoc();
                }

                if (plugin.getPlayerLoc().getConfigurationSection(pID.toString()) != null) {
                   
                    Double pX = p.getLocation().getX();
                    Double pY = p.getLocation().getY();
                    Double pZ = p.getLocation().getZ();
                    float pPitch = (float) p.getLocation().getPitch();
                    float pYaw = (float) p.getLocation().getYaw();

                    plugin.getPlayerLoc().createSection(pID.toString());
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.world", "Survival");
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.x", pX);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.y", pY);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.z", pZ);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.pitch", pPitch);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.yaw", pYaw);
                    plugin.savePlayerLoc();
                }
            }
        }

        @EventHandler
        public void onWorldChange(PlayerChangedWorldEvent e) {
            Player p = (Player) e.getPlayer();
            UUID pID = p.getUniqueId();

            if (!(p.getWorld().getName().equalsIgnoreCase("survival"))) {
                if (e.getFrom().getName().equalsIgnoreCase("survival")) {
                    if (plugin.getPlayerLoc().getConfigurationSection(pID.toString()) == null) {
                       
                        Double pX = p.getLocation().getX();
                        Double pY = p.getLocation().getY();
                        Double pZ = p.getLocation().getZ();
                        float pPitch = (float) p.getLocation().getPitch();
                        float pYaw = (float) p.getLocation().getYaw();

                        plugin.getPlayerLoc().createSection(pID.toString());
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.world", "Survival");
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.x", pX);
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.y", pY);
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.z", pZ);
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.pitch", pPitch);
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.yaw", pYaw);
                        plugin.savePlayerLoc();
                    }

                    if (plugin.getPlayerLoc().getConfigurationSection(pID.toString()) != null) {
                        Double pX = p.getLocation().getX();
                        Double pY = p.getLocation().getY();
                        Double pZ = p.getLocation().getZ();
                        float pPitch = (float) p.getLocation().getPitch();
                        float pYaw = (float) p.getLocation().getYaw();

                        plugin.getPlayerLoc().createSection(pID.toString());
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.world", "Survival");
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.x", pX);
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.y", pY);
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.z", pZ);
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.pitch", pPitch);
                        plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.yaw", pYaw);
                        plugin.savePlayerLoc();
                    }
                }
            }

            if (!(e.getFrom().getName().equalsIgnoreCase("survival"))) {
                if (p.getWorld().getName().equalsIgnoreCase("survival")) {
                    World locWorld = Bukkit.getWorld("Survival");
                    double spawnX = this.plugin.getPlayerLoc().getDouble("logout.x");
                    double spawnY = this.plugin.getPlayerLoc().getDouble("logout.y");
                    double spawnZ = this.plugin.getPlayerLoc().getDouble("logout.z");
                    float spawnPitch = (float) this.plugin.getPlayerLoc().getDouble("logout.pitch");
                    float spawnYaw = (float) this.plugin.getPlayerLoc().getDouble("logout.yaw");

                    e.getPlayer().teleport(new Location(locWorld, spawnX, spawnY, spawnZ, spawnYaw, spawnPitch));
                }
            }
        }

    This is what I had, but realized it was saving it to the world they teleported to after. I'll test the teleport event :) Thank you
     
  4. Update:

    It saves and works using the PlayerTeleportEvent but one issue. It spams with a log of errors on the use of /mvtp Survival. The error spams so much the whole server crashes.

    Snippet of error:

    Code (Text):
    [01:00:43] [Server thread/ERROR]: Could not pass event PlayerTeleportEvent to SquirrelMCSurvival v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer.teleport(CraftPlayer.java:479) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity.teleport(CraftEntity.java:250) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at me.java.leollie.events.PlayersLocations.onWorldChange(PlayersLocations.java:122) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer.teleport(CraftPlayer.java:479) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity.teleport(CraftEntity.java:250) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at me.java.leollie.events.PlayersLocations.onWorldChange(PlayersLocations.java:122) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer.teleport(CraftPlayer.java:479) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity.teleport(CraftEntity.java:250) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at me.java.leollie.events.PlayersLocations.onWorldChange(PlayersLocations.java:122) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
     
  5. WAS

    WAS

    What is at this line?
     
  6. e.getPlayer().teleport(new Location(locWorld, spawnX, spawnY, spawnZ, spawnYaw, spawnPitch));
     
  7. I am still encountering this issue, here is my current code:

    Code (Text):
    @EventHandler
        public void onWorldChange(PlayerTeleportEvent e) {
            Player p = (Player) e.getPlayer();
            UUID pID = p.getUniqueId();

            if (e.getFrom().getWorld().getName().equalsIgnoreCase("survival")) {
                if (plugin.getPlayerLoc().getConfigurationSection(pID.toString()) == null) {

                    Double pX = p.getLocation().getX();
                    Double pY = p.getLocation().getY();
                    Double pZ = p.getLocation().getZ();
                    float pPitch = (float) p.getLocation().getPitch();
                    float pYaw = (float) p.getLocation().getYaw();

                    plugin.getPlayerLoc().createSection(pID.toString());
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.world", "Survival");
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.x", pX);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.y", pY);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.z", pZ);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.pitch", pPitch);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.yaw", pYaw);
                    plugin.savePlayerLoc();
                }

                if (plugin.getPlayerLoc().getConfigurationSection(pID.toString()) != null) {
                    Double pX = p.getLocation().getX();
                    Double pY = p.getLocation().getY();
                    Double pZ = p.getLocation().getZ();
                    float pPitch = (float) p.getLocation().getPitch();
                    float pYaw = (float) p.getLocation().getYaw();

                    plugin.getPlayerLoc().createSection(pID.toString());
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.world", "Survival");
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.x", pX);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.y", pY);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.z", pZ);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.pitch", pPitch);
                    plugin.getPlayerLoc().getConfigurationSection(pID.toString()).set("logout.yaw", pYaw);
                    plugin.savePlayerLoc();
                }
            }

            if (e.getTo().getWorld().getName().equalsIgnoreCase("survival")) {

                if (plugin.getPlayerLoc().getConfigurationSection(pID.toString()) == null) {
                    return;
                }
                World locWorld = Bukkit
                        .getWorld(plugin.getPlayerLoc().getConfigurationSection(pID.toString()).getString("logout.world"));
                double spawnX = this.plugin.getPlayerLoc().getConfigurationSection(pID.toString()).getDouble("logout.x");
                double spawnY = this.plugin.getPlayerLoc().getConfigurationSection(pID.toString()).getDouble("logout.y");
                double spawnZ = this.plugin.getPlayerLoc().getConfigurationSection(pID.toString()).getDouble("logout.z");
                float spawnPitch = (float) this.plugin.getPlayerLoc().getConfigurationSection(pID.toString())
                        .getDouble("logout.pitch");
                float spawnYaw = (float) this.plugin.getPlayerLoc().getConfigurationSection(pID.toString())
                        .getDouble("logout.yaw");

                e.getPlayer().teleport(new Location(locWorld, spawnX, spawnY, spawnZ, spawnYaw, spawnPitch));
            }
        }

    The error it was giving me is for this line:

    Code (Text):
    e.getPlayer().teleport(new Location(locWorld, spawnX, spawnY, spawnZ, spawnYaw, spawnPitch));
    Here is the error:

    Code (Text):
    [Server thread/ERROR]: Could not pass event PlayerTeleportEvent to SquirrelMCSurvival v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer.teleport(CraftPlayer.java:479) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity.teleport(CraftEntity.java:250) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at me.java.leollie.events.PlayersLocations.onWorldChange(PlayersLocations.java:122) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer.teleport(CraftPlayer.java:479) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity.teleport(CraftEntity.java:250) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at me.java.leollie.events.PlayersLocations.onWorldChange(PlayersLocations.java:122) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer.teleport(CraftPlayer.java:479) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity.teleport(CraftEntity.java:250) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at me.java.leollie.events.PlayersLocations.onWorldChange(PlayersLocations.java:122) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer.teleport(CraftPlayer.java:479) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity.teleport(CraftEntity.java:250) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at me.java.leollie.events.PlayersLocations.onWorldChange(PlayersLocations.java:122) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer.teleport(CraftPlayer.java:479) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity.teleport(CraftEntity.java:250) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at me.java.leollie.events.PlayersLocations.onWorldChange(PlayersLocations.java:122) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer.teleport(CraftPlayer.java:479) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity.teleport(CraftEntity.java:250) ~[spigot.jar:git-Spigot-b32c8f8-4d3bf20]
        at me.java.leollie.events.PlayersLocations.onWorldChange(PlayersLocations.java:122) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigo

    This error spams until the server and my client crash.

    If anyone has an explanation/fix to this that would be greatly appreciated!

    Thank you in advance
     
  8. electronicboy

    IRC Staff

    You're teleporting the player in the PlayerTeleportEvent, which causes another teleport event to be fired, in which you're teleporting the player in the PlayerTeleportEvent, which causes another event to be fired....

    You need to filter out your code, so that when you teleport them to what you want to teleport them to, you don't attempt to teleport them again
     
  9. Ahh, I'm trying to make it so they go back to their last location in the Survival world, so they don't lose it when logging out/going to say creative
     
  10. Solved. Changed the line to this:
    Code (Text):
    e.setTo(new Location(locWorld, spawnX, spawnY, spawnZ, spawnYaw, spawnPitch));
    Thank you for those that helped. I should've clocked onto the issue much sooner! >.<