Location in config error

Discussion in 'Plugin Development' started by Onzonekid101, Sep 19, 2014.

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

    Onzonekid101

    Hia everyone. I'm working on a plugin that saves player locations on one command, then telelports them there on the other. But if I use this command from a World named "world" I get a bunch of errors in console. I tracked to the errors pointing to a problem on line 90 where i load the location from a file can anyone help me?
    Saving method
    Code:java
    1. public void save(Player p) {
    2. File file = new File(Bukkit.getServer().getPluginManager().getPlugin("AstroHomes").getDataFolder(), "Stats/" + p.getName() + ".yml");
    3. YamlConfiguration c = YamlConfiguration.loadConfiguration(file);
    4. c.set("world", p.getWorld().getName());
    5. c.set("X",p.getLocation().getBlockX());
    6. c.set("Y",p.getLocation().getBlockY());
    7. c.set("Z",p.getLocation().getBlockZ());
    8. c.save(file);
    9. }


    Loading method
    Code:java
    1. public void load(Player p) {
    2. File file = new File(Bukkit.getServer().getPluginManager().getPlugin("AstroHomes").getDataFolder(), "Stats/" + p.getName() + ".yml");
    3. YamlConfiguration c = YamlConfiguration.loadConfiguration(file);
    4. Location loc = new Location(Bukkit.getWorld(c.getString("world")),c.getInt("X"),c.getInt("Y"),c.getInt("Z"))
    5. p.teleport(loc);


    the player.yml file looks fine as well what could the problem be thanks all for the replies! :D
    Oh ya btw if you see syntax errors sorry i was writing this on my phone xD
     
  2. Offline

    Skionz

    Onzonekid101 post the error
    EDIT: You forgot the semicolon :p
     
  3. Offline

    Onzonekid101

    Skionz it kind of spams my console so this is the best i got
    Code:
    [17:25:23] [Server thread/ERROR]: Could not pass event PlayerTeleportEvent to AstroHomes v1
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer.teleport(CraftPlayer.java:471) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity.teleport(CraftEntity.java:200) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at me.Nicolas.AstroHomes.PlayerStats.loadPlayerStats(PlayerStats.java:99) ~[?:?]
        at me.Nicolas.AstroHomes.PlayerStats.onSwitch(PlayerStats.java:151) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer.teleport(CraftPlayer.java:471) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity.teleport(CraftEntity.java:200) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at me.Nicolas.AstroHomes.PlayerStats.loadPlayerStats(PlayerStats.java:99) ~[?:?]
        at me.Nicolas.AstroHomes.PlayerStats.onSwitch(PlayerStats.java:151) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_65]
        at 
     
  4. Offline

    Skionz

    Onzonekid101
    You forgot the semicolon here
    Code:java
    1. Location loc = new Location(Bukkit.getWorld(c.getString("world")),c.getInt("X"),c.getInt("Y"),c.getInt("Z"))
     
  5. Offline

    Onzonekid101

    Again Skionz I told you syntax errors dont matter becuase i wrote this on my phone. What kind of error did i get?
     
  6. Offline

    Skionz

    Onzonekid101 Ahh sorry didn't read that part but can you post the rest of the error? I need a tad bit more
     
  7. Offline

    Onzonekid101

    ok Skionz but im warning you this might get VERY messed up
    Code:
    org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer.teleport(CraftPlayer.java:471) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity.teleport(CraftEntity.java:200) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at me.Nicolas.AstroHomes.PlayerStats.loadPlayerStats(PlayerStats.java:99) ~[?:?]
        at me.Nicolas.AstroHomes.PlayerStats.onSwitch(PlayerStats.java:151) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_65]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_65]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
    Caused by: java.lang.StackOverflowError
        at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.7.0_65]
        at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.7.0_65]
        at java.security.SecureClassLoader.defineClass(Unknown Source) ~[?:1.7.0_65]
        at java.net.URLClassLoader.defineClass(Unknown Source) ~[?:1.7.0_65]
        at java.net.URLClassLoader.access$100(Unknown Source) ~[?:1.7.0_65]
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_65]
        at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_65]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_65]
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.7.0_65]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_65]
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[?:1.7.0_65]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_65]
        at org.apache.logging.log4j.core.impl.ThrowableProxy.resolvePackageData(ThrowableProxy.java:373) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.apache.logging.log4j.core.impl.ThrowableProxy.<init>(ThrowableProxy.java:97) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.apache.logging.log4j.core.impl.Log4jLogEvent.<init>(Log4jLogEvent.java:114) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.apache.logging.log4j.core.impl.Log4jLogEvent.<init>(Log4jLogEvent.java:90) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.apache.logging.log4j.core.impl.DefaultLogEventFactory.createEvent(DefaultLogEventFactory.java:49) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:365) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.apache.logging.log4j.core.Logger.log(Logger.java:110) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:609) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.craftbukkit.v1_7_R3.util.ForwardLogHandler.publish(ForwardLogHandler.java:33) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at java.util.logging.Logger.log(Unknown Source) ~[?:1.7.0_65]
        at java.util.logging.Logger.doLog(Unknown Source) ~[?:1.7.0_65]
        at java.util.logging.Logger.log(Unknown Source) ~[?:1.7.0_65]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:516) ~[cbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        ... 999 more
    [17:25:27]
    it just keeps repeating itself xD

    Skionz UPDATE: I think its because im calling this event on playerTeleportEvent. If i teleport a player on player teleport event will it throw an illigal arg ex?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  8. Offline

    Totom3

    Onzonekid101 The error is pointing to line 99 of PlayerStats.java, in the method loadPlayerStats(). Which line is it specifically ?
     
  9. Offline

    Onzonekid101

  10. Offline

    Skionz

    Onzonekid101 Try having the method return a location instead
     
  11. Offline

    Onzonekid101

    why would i return make any difference Skionz
     
  12. Offline

    mythbusterma

    Onzonekid101

    StackOverflowError is 9 times out of 10 caused by a method that calls itself, creating an infinite loop, which overflows the call stack, post the entire class if you can't figure it out.
     
  13. Offline

    Onzonekid101

    mythbusterma if on PlayerTPEvent i do event.setTo() would that be ok?

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  14. Offline

    Dudemister1999

    Onzonekid101 I highly recommend using UUID's instead of usernames, because if that player changes his username, his home is lost.

    *EDIT: I also recommend not bumping for at least 12 hours (Regulations of Bukkit)
     
  15. Offline

    Onzonekid101

    Thanks Dudemister1999 now can you answer this
     
  16. Offline

    Dudemister1999

    Onzonekid101 That should be okay, but I cannot guarantee it. I can take a look in a while, when I have access to my device.
     
  17. Offline

    Onzonekid101

    Dudemister1999 calling a Player.telelport() method in a PlayerTPEvent event will create a loop forever which is why i want to know if e.setTo() would work. Just giving you some info to keep things simpler
     
  18. Offline

    Dudemister1999

    Onzonekid101 I know, I read the thread. If you change the values in an event, it does not call the event again.
     
  19. Offline

    Onzonekid101

Thread Status:
Not open for further replies.

Share This Page