Solved How to make frost walker with lava the best way?

Discussion in 'Plugin Development' started by Panda_Crafter, Jul 27, 2016.

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

    Panda_Crafter

    Hello I tried this but then I got this error, anyone has the best solution for my idea?

    I could put this in a try to remove the errors but thats kinda nooby
    Error:
    Code:
    [19:08:34 WARN]: [NonsenseCraft] Task #2803 for NonsenseCraft v1.0 generated an
    exception
    java.util.ConcurrentModificationException
            at java.util.ArrayList$Itr.checkForComodification(Unknown Source) ~[?:1.
    8.0_66]
            at java.util.ArrayList$Itr.next(Unknown Source) ~[?:1.8.0_66]
            at me.pandacrafter1.nonsensecraft.events.player.PlayerMove$1.run(PlayerM
    ove.java:77) ~[?:?]
            at org.bukkit.craftbukkit.v1_10_R1.scheduler.CraftTask.run(CraftTask.jav
    a:71) ~[spigot.jar:git-Spigot-9797151-301db84]
            at org.bukkit.craftbukkit.v1_10_R1.scheduler.CraftScheduler.mainThreadHe
    artbeat(CraftScheduler.java:350) [spigot.jar:git-Spigot-9797151-301db84]
            at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:
    728) [spigot.jar:git-Spigot-9797151-301db84]
            at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:
    399) [spigot.jar:git-Spigot-9797151-301db84]
            at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:
    673) [spigot.jar:git-Spigot-9797151-301db84]
            at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.jav
    a:572) [spigot.jar:git-Spigot-9797151-301db84]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_66]
    
    And this is my code:

    Code:
    
            Location l = new Location(player.getLocation().getWorld(), player.getLocation().getX(), player.getLocation().getY()-1, player.getLocation().getZ()); 
            Block b = (Block) player.getWorld().getBlockAt(l);
           
            if (b.getType() == Material.LAVA || b.getType() == Material.STATIONARY_LAVA){
                blocks.add(b);
                b.setType(Material.OBSIDIAN);
            }
           
            if(b.getRelative(BlockFace.NORTH).getType() == Material.LAVA || b.getRelative(BlockFace.NORTH).getType() == Material.STATIONARY_LAVA){
                blocks.add(b.getRelative(BlockFace.NORTH));
                b.getRelative(BlockFace.NORTH).setType(Material.OBSIDIAN);
            }
           
            if(b.getRelative(BlockFace.WEST).getType() == Material.LAVA || b.getRelative(BlockFace.WEST).getType() == Material.STATIONARY_LAVA){
                blocks.add(b.getRelative(BlockFace.WEST));
                b.getRelative(BlockFace.WEST).setType(Material.OBSIDIAN);
            }
           
            if(b.getRelative(BlockFace.SOUTH).getType() == Material.LAVA || b.getRelative(BlockFace.NORTH).get
     
  2. You edit the list you are currently iterating through (probably with a enhanced for loop)

    This will throw a ConcurrentModificationException:
    Code:
    for (String str : list) {
        if (...) list.add("new value");
    }
    This won't:
    Code:
    for (int i = 0; i < list.size(); i++) {
        String str = list.get(i);
        if (...) list.add("new value");
    }
     
    Panda_Crafter likes this.
  3. Offline

    Panda_Crafter

    Thanks it worked
     
  4. Offline

    ArsenArsen

    Mark the thread as solved, if your problem is solved.
     
    Panda_Crafter likes this.
Thread Status:
Not open for further replies.

Share This Page