Help with HashMap

Discussion in 'Plugin Development' started by Lusberd, Apr 20, 2017.

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

    Lusberd

    Hello guys, I have code a plugin for antiafk, it work but the run give me a error:

    [ControlFeature] Task #8753 for ControlFeature v0.1 generated an exception
    java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.remove(HashMap.java:1451) ~[?:1.8.0_121]
    at me.phond.control.Main$2.run(Main.java:224) ~[?:?]
    at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot.jar:git-PaperSpigot-1f7d532]
    at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot.jar:git-PaperSpigot-1f7d532]
    at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:701) [spigot.jar:git-PaperSpigot-1f7d532]
    at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:307) [spigot.jar:git-PaperSpigot-1f7d532]
    at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:643) [spigot.jar:git-PaperSpigot-1f7d532]
    at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:549) [spigot.jar:git-PaperSpigot-1f7d532]
    at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-PaperSpigot-1f7d532]

    This is the source:
    https://pastebin.com/yU9JKPRF

    Help me plis guys
     
  2. I'm unable to help you. I don't know on which line the error appears, you only gave a little piece of your code.
    Please mark line 224 in your main class.
     
  3. Offline

    MCMastery

    You can't remove elements from a collection while looping over it.
    Loop over a cloned version of the collection

    To clone do new HashMap<>(yourHashmap)
     
  4. Offline

    Caderape2

    @Lusberd Use iterator for remove while looping
     
Thread Status:
Not open for further replies.

Share This Page