Solved NoSuchElementException

Discussion in 'Plugin Development' started by Axe2760, Sep 19, 2013.

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

    Axe2760

    I can't seem to figure this out.
    Code:text
    1.  
    2. ConfigurationSection cs;
    3. Iterator<Entry<String,Integer>> it = points.entrySet().iterator();
    4.  
    5. while (it.hasNext()){
    6. Entry<String,Integer> next = it.next();
    7. if (yaml.get(next.getKey()) == null){
    8. cs = yaml.createSection(next.getKey());
    9. }
    10. cs = yaml.getConfigurationSection(next.getKey());
    11.  
    12. cs.set("points", it.next().getValue());
    13. it.remove();
    14. }
    15.  


    This is returning the error:
    Code:
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:413)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:481)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:239)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:592)
    19.09 19:34:22 [Server] INFO at org.spigotmc.netty.NettyServerConnection.b(NettyServerConnection.java:125)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java:118)
    19.09 19:34:22 [Server] INFO at org.spigotmc.netty.NettyNetworkManager.b(NettyNetworkManager.java:235)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.Packet3Chat.handle(SourceFile:49)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java:839)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.PlayerConnection.chat(PlayerConnection.java:892)
    19.09 19:34:22 [Server] INFO at net.minecraft.server.v1_6_R2.PlayerConnection.handleCommand(PlayerConnection.java:981)
    19.09 19:34:22 [Server] INFO at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServer.java:527)
    19.09 19:34:22 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:190)
    19.09 19:34:22 [Server] INFO at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:24)
    19.09 19:34:22 [Server] INFO at org.bukkit.Bukkit.reload(Bukkit.java:275)
    19.09 19:34:22 [Server] INFO at org.bukkit.craftbukkit.v1_6_R2.CraftServer.reload(CraftServer.java:581)
    19.09 19:34:22 [Server] INFO at org.bukkit.plugin.SimplePluginManager.clearPlugins(SimplePluginManager.java:435)
    19.09 19:34:22 [Server] INFO at org.bukkit.plugin.SimplePluginManager.disablePlugins(SimplePluginManager.java:394)
    19.09 19:34:22 [Server] INFO at org.bukkit.plugin.SimplePluginManager.disablePlugin(SimplePluginManager.java:401)
    19.09 19:34:22 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.disablePlugin(JavaPluginLoader.java:481)
    19.09 19:34:22 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:219)
    19.09 19:34:22 [Server] INFO at us.axe2760.questrpg.QuestRPG.onDisable(QuestRPG.java:69)
    19.09 19:34:22 [Server] INFO at us.axe2760.questrpg.players.PlayerSession.saveQuests(PlayerSession.java:180)
    19.09 19:34:22 [Server] INFO at java.util.HashMap$EntryIterator.next(Unknown Source)
    19.09 19:34:22 [Server] INFO at java.util.HashMap$EntryIterator.next(Unknown Source)
    19.09 19:34:22 [Server] INFO at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
    19.09 19:34:22 [Server] INFO java.util.NoSuchElementException
    Halp? =P
     
  2. Offline

    Barnyard_Owl

    Axe2760
    Code:
    19.09 19:34:22 [Server] INFO at us.axe2760.questrpg.players.PlayerSession.saveQuests(PlayerSession.java:180)
    So can you tell us which line is line 180 in PlayerSession.java?
     
  3. Offline

    Axe2760

    Didn't think you would need that, the code above contains that line. To know just the line would not be of much help, when juxtaposed with giving the block of code.
    Barnyard_Owl

    Edit: ah, looks like I forgot to replace it.next().getValue() with next.getValue(). Will try that now.
     
  4. Offline

    tommycake50

    Use it.hasNext() before you call it.next().
     
  5. Offline

    Barnyard_Owl

    tommycake50
    "while (it.hasNext()){" The OP included it.
     
  6. Offline

    tommycake50

    Ignore me... I didn't see that.
     
  7. Offline

    Axe2760

    Yep, again I am a derp! I meant to change it.next() to next, but I was doing this about 10 times and I missed it! :p Thanks for wasting your time to read this. :p

    Solved.
     
Thread Status:
Not open for further replies.

Share This Page