Hashmap always returning null, please help

Discussion in 'Plugin Development' started by william9518, Jan 6, 2013.

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

    william9518

    ok in the stacktrace it says this returns null:
    Code:
     if (plugin.boughtsoldier.get(targetPlayer.getName()) == true)
    but clearly i put this in playerjoinevent:
    Code:
     if (!plugin.defaultConfig.contains(name + "boughtsoldier")) {
          plugin.defaultConfig.set(name + "boughtsoldier", (true));
          plugin.boughtsoldier.put(name, (plugin.defaultConfig.getBoolean(name + "boughtsoldier")));
          plugin.saveConfig();
        } else {
          plugin.boughtsoldier.put(name, (plugin.defaultConfig.getBoolean(name + "boughtsoldier")));
          plugin.saveConfig();
        }
    and if youre wondering what defaultConfig is,
    Code:
    String mainDir = getDataFolder().getPath();
        File defaultfConfig = new File(mainDir + "/defaultConfig.yml");
      Configuration  defaultConfig = YamlConfiguration.loadConfiguration(defaultfConfig);
    and yes i registered the event
    There is error at the playerjoin event as well:
    Code:
    06.01 20:17:57 [Server] INFO at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:701)
    06.01 20:17:57 [Server] INFO at org.bukkit.configuration.MemorySection.get(MemorySection.java:194)
    06.01 20:17:57 [Server] INFO at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:701)
    06.01 20:17:57 [Server] INFO at org.bukkit.configuration.MemorySection.get(MemorySection.java:194)
    06.01 20:17:57 [Server] INFO at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:701)
    06.01 20:17:57 [Server] INFO at org.bukkit.configuration.MemorySection.get(MemorySection.java:194)
    06.01 20:17:57 [Server] INFO at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:701)
    06.01 20:17:57 [Server] INFO at org.bukkit.configuration.MemorySection.createPath(MemorySection.java:757)
    06.01 20:17:57 [Server] INFO at org.bukkit.configuration.MemorySection.createPath(MemorySection.java:794)
    06.01 20:17:57 [Server] INFO at java.lang.StringBuilder.append(StringBuilder.java:132)
    06.01 20:17:57 [Server] INFO Caused by: java.lang.StackOverflowError
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:427)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.MinecraftServer.q(MinecraftServer.java:494)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.DedicatedServer.r(DedicatedServer.java:224)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.MinecraftServer.r(MinecraftServer.java:598)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.DedicatedServerConnection.b(SourceFile:29)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.DedicatedServerConnectionThread.a(DedicatedServerConnectionThread.java:44)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.PendingConnection.c(PendingConnection.java:45)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.PendingConnection.d(PendingConnection.java:130)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.PlayerList.a(PlayerList.java:95)
    06.01 20:17:57 [Server] INFO at net.minecraft.server.v1_4_6.PlayerList.c(PlayerList.java:156)
    06.01 20:17:57 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
    06.01 20:17:57 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
    06.01 20:17:57 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    06.01 20:17:57 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427)
    06.01 20:17:57 [Server] INFO org.bukkit.event.EventException
    06.01 20:17:57 [Server] SEVERE Could not pass event PlayerJoinEvent to OMGPvP v1.0
     
  2. Offline

    MCForger

    Could be that boughtsoldier is returning null. Do you have a loading method for it?
     
  3. Offline

    fireblast709

    You are somehow creating a StackOverflow. Can you post the full stacktrace/log
     
  4. Offline

    william9518

    that is the full stacktrace
     
  5. Offline

    fireblast709

    ok a raw interpretation from the stacktrace:
    • you try to get a value from the default config
    • it does not exist, so it tries to get it from the default config
    • it does not exist, so it tries to get it from the default config
    • etc
    Are you sure you have not set something like "someConfig.setDefaults(someConfig)"
     
  6. Offline

    william9518

    I did
    defaultConfig.setDefaults(defaultConfig);
     
  7. Offline

    fireblast709

    Do you smell that? It smells like infinite recursion ;3
     
  8. Offline

    william9518

    im removing it, trying
     
Thread Status:
Not open for further replies.

Share This Page