Solved "Unhandled exception executing command"

Discussion in 'Plugin Development' started by AlfieJay, Feb 29, 2020.

Thread Status:
Not open for further replies.
  1. So I'm fairly new to coding and have been poking around with ArrayLists which was going fine until this function decided not to work properly
        public void delarenaCommand(Player p, String pluginTag, String[] args) {
            if (p.hasPermission("pvpt.delarena")) {
                if (args.length == 2) {
                    checkBOO = false;
                    for (String x : arenaLST) {
                        if (args[1].equalsIgnoreCase(x)) {
                            checkBOO = true;
                            p.sendMessage(pluginTag + "Arena '" + x + "' succefully deleted!");
                    if (checkBOO == false) {
                        p.sendMessage(pluginTag + "Sorry, the arena '" + args[1] + "' doesn't exist");
                } else {p.sendMessage(pluginTag + "Invalid format! Please use the format '/pvpt delarena [name]'");}
            } else {p.sendMessage(pluginTag + "Sorry, you don't have permission for this command!");}
    The weird thing is, it does successfully delete commands but also gives the error afterwards. I've tried emitting the arena-doesn't-exit error but that didn't change it. Also if args[1] isn't present in the ArrayList then you get the custom error message I made with no error. Here's what pops up in the console when it fails:

    [12:38:23 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'pvpt' in plugin PvPT v1.0
        at org.bukkit.command.PluginCommand.execute( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at org.bukkit.command.SimpleCommandMap.dispatch( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PlayerConnection.a( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PacketPlayInChat.a( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PacketPlayInChat.a( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at java.util.concurrent.Executors$ ~[?:?]
        at ~[?:?]
        at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at [?:?]
    Caused by: java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification( ~[?:?]
        at java.util.ArrayList$ ~[?:?]
        at jay.plugin.pvpt.main.delarenaCommand( ~[?:?]
        at jay.plugin.pvpt.main.onCommand( ~[?:?]
        at org.bukkit.command.PluginCommand.execute( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        ... 15 more
    Any and as much help as possible would be appreciated, thanks :D
  2. Offline

    timtower Administrator Administrator Moderator

    @AlfieJay You can't loop over an arraylist and remove an item from it at the same time.
  3. Oooh, I thought it might be something simple I was overlooking. Thanks for your help :D
Thread Status:
Not open for further replies.

Share This Page