[Saving/Loading Custom Configs] What is wrong with this code?

Discussion in 'Plugin Development' started by Orcem12, May 8, 2012.

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

    Orcem12

    Code:java
    1.  
    2. public FileConfiguration LoadPConfig(Player p){
    3. File saveFile = new File(plugin.getDataFolder()+File.separator+"Players", p.getName() + ".yml");
    4. YamlConfiguration config = YamlConfiguration.loadConfiguration(saveFile);
    5. return config;
    6. }
    7. public void SavePConfig(Player p){
    8. File saveFile = new File(plugin.getDataFolder()+File.separator+"Players", p.getName() + ".yml");
    9. FileConfiguration config = YamlConfiguration.loadConfiguration(saveFile);
    10. try {
    11. config.save(saveFile);
    12. } catch (IOException e) {
    13. e.printStackTrace();
    14. }
    15. }
    16.  


    Error:
    Code:
    17:52:36 [SEVERE] Could not pass event PlayerChatEvent to SeaModsterPlenty
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:303)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:459)
            at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:786)
     
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:764)
            at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:34)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:229)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113)
            at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:7
    8)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:551)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:449)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.NullPointerException
            at Orcem.Handlers.ConfigCore.LoadPConfig(ConfigCore.java:90)
            at Orcem.Listener.PlayerListener.PlayerChat(PlayerListener.ja
    va:23)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:301)
            ... 11 more
    [][][] Line 90 [][][]

    Code:Java
    1.  
    2. File saveFile = new File(plugin.getDataFolder() + File.separator + "Players" + File.separator, p.getName() + ".yml");
    3.  


    Thanks for any wisdom, I'm new to mass configuration management. :)

    Still looking for assistance. Did I provide all the information needed?

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

    Sagacious_Zed Bukkit Docs

    my guess is that plugin is null, but without the full source file and line numbers that match the stack trace hard to be sure.

    Orcem12 line numbers don't match

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

    Orcem12

    @Sagacious_Zed
    Sorry I just updated it, my clipboard was off, haha.
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    Orcem12 PlayerListener.java is missing

    reasonably certain that plugin is not null, so the other option is the player being passed in is null. My advise is to check if the values passed in a valid before trying to operate on them.
     
  5. Offline

    Orcem12

    Alright I'll check my listener. I was trying to save the players location upon joining but I'm just using e.getPlayer().getLocation() so that might be the issue.
     
Thread Status:
Not open for further replies.

Share This Page