Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command works, Unexpected Error Appeared #503

Open
ImNotStable opened this issue Oct 30, 2023 · 3 comments · May be fixed by #501
Open

Command works, Unexpected Error Appeared #503

ImNotStable opened this issue Oct 30, 2023 · 3 comments · May be fixed by #501
Assignees
Labels
bug Something isn't working

Comments

@ImNotStable
Copy link

CommandAPI version

9.20

Minecraft version

1.20.1

Are you shading the CommandAPI?

Yes

What I did

  • I added all the prerequisites for CommandAPI & everything is working besides receiving an unexpected error.
  • I joined, then ran the command.
  • An error appeared, but the command worked.

What actually happened

The command worked as it should. All that happened was an error appeared in the console.

What should have happened

No error

Server logs and CommandAPI config

[22:07:01 ERROR]: Caught previously unhandled exception :
[22:07:01 ERROR]: Caught previously unhandled exception :
[22:07:01 ERROR]: Paper Async Command Builder Thread Pool - 1
java.util.ConcurrentModificationException: null
        at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1486) ~[?:?]
        at java.util.TreeMap$ValueIterator.next(TreeMap.java:1531) ~[?:?]
        at net.minecraft.commands.Commands.fillUsableCommands(Commands.java:483) ~[?:?]
        at net.minecraft.commands.Commands.sendAsync(Commands.java:443) ~[?:?]
        at net.minecraft.commands.Commands.lambda$sendCommands$5(Commands.java:422) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
[22:07:01 ERROR]: Paper Async Command Builder Thread Pool - 0
java.util.ConcurrentModificationException: null
        at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1486) ~[?:?]
        at java.util.TreeMap$ValueIterator.next(TreeMap.java:1531) ~[?:?]
        at net.minecraft.commands.Commands.fillUsableCommands(Commands.java:483) ~[?:?]
        at net.minecraft.commands.Commands.sendAsync(Commands.java:443) ~[?:?]
        at net.minecraft.commands.Commands.lambda$sendCommands$5(Commands.java:422) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
[22:07:01 ERROR]: Caught previously unhandled exception :
[22:07:01 ERROR]: Paper Async Command Builder Thread Pool - 2
java.util.ConcurrentModificationException: null
        at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1486) ~[?:?]
        at java.util.TreeMap$ValueIterator.next(TreeMap.java:1531) ~[?:?]
        at net.minecraft.commands.Commands.fillUsableCommands(Commands.java:483) ~[?:?]
        at net.minecraft.commands.Commands.sendAsync(Commands.java:443) ~[?:?]
        at net.minecraft.commands.Commands.lambda$sendCommands$5(Commands.java:422) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
[22:07:01 ERROR]: Caught previously unhandled exception :
[22:07:01 ERROR]: Paper Async Command Builder Thread Pool - 3
java.util.ConcurrentModificationException: null
        at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1486) ~[?:?]
        at java.util.TreeMap$ValueIterator.next(TreeMap.java:1531) ~[?:?]
        at net.minecraft.commands.Commands.fillUsableCommands(Commands.java:483) ~[?:?]
        at net.minecraft.commands.Commands.sendAsync(Commands.java:443) ~[?:?]
        at net.minecraft.commands.Commands.lambda$sendCommands$5(Commands.java:422) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
[22:07:01 ERROR]: Caught previously unhandled exception :
[22:07:01 ERROR]: Paper Async Command Builder Thread Pool - 4
java.util.ConcurrentModificationException: null
        at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1486) ~[?:?]
        at java.util.TreeMap$ValueIterator.next(TreeMap.java:1531) ~[?:?]
        at net.minecraft.commands.Commands.fillUsableCommands(Commands.java:483) ~[?:?]
        at net.minecraft.commands.Commands.sendAsync(Commands.java:443) ~[?:?]
        at net.minecraft.commands.Commands.lambda$sendCommands$5(Commands.java:422) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]

Other

    new CommandTree("qualityeconomy")
      .withAliases("qe")
      .withPermission("qualityeconomy.admin")
      .then(new LiteralArgument("reload")
        .executes((sender, args) -> {
          reload();
          sender.sendMessage(Component.text("Reloading QualityEconomy...", NamedTextColor.GRAY));
        })
        .then(new LiteralArgument("messages")
          .executes((sender, args) -> {
            Messages.loadMessages();
            sender.sendMessage(Component.text("Reloading QualityEconomy messages.yml...", NamedTextColor.GRAY));
          }))
        .then(new LiteralArgument("configuration")
          .executes((sender, args) -> {
            Configuration.loadConfiguration();
            sender.sendMessage(Component.text("Reloading QualityEconomy config.yml...", NamedTextColor.GRAY));
          })))
      .then(new LiteralArgument("database")
        .then(new LiteralArgument("import")
          .then(new GreedyStringArgument("fileName")
            .includeSuggestions(ArgumentSuggestions.strings(getImportableFiles()))
            .executes((sender, args) -> {
              sender.sendMessage(Component.text("Importing Database...", NamedTextColor.GRAY));
              StorageManager.importDatabase(args.get("fileName").toString());
              sender.sendMessage(Component.text("Imported Database", NamedTextColor.GREEN));
            })))
        .then(new LiteralArgument("export")
          .executes((sender, args) -> {
            sender.sendMessage(Component.text("Exporting Database...", NamedTextColor.GRAY));
            StorageManager.exportDatabase("plugins/QualityEconomy/");
            sender.sendMessage(Component.text("Exported Database", NamedTextColor.GREEN));
          }))
        .then(new LiteralArgument("createFakeEntries")
          .withRequirement(sender -> TestToolkit.DEBUG_MODE)
          .then(new IntegerArgument("entries", 1, 9999)
            .executes((sender, args) -> {
              try {
                int entries = (int) args.get("entries");
                AccountManager.createFakeAccounts(entries != 0 ? entries : 10);
              } catch (NumberFormatException ignored) {
                sender.sendMessage(Component.text("Invalid amount.", NamedTextColor.RED));
              }
            }))))
      .register();
@ImNotStable ImNotStable added the bug Something isn't working label Oct 30, 2023
@ImNotStable
Copy link
Author

I'm using 1.20.2, but the option wasn't there by the way.

@willkroboth
Copy link
Collaborator

This looks similar to #494. There is currently PR #501 that tries to fix #494. If you're able to, you could try using the CommandAPI branch for #501 and see if that resolves this problem. Unfortunately, #501 isn't ready for release yet since it does not resolve the issue on older versions of Paper, but I have tried it with 1.20.2 and it seems to help there.

@ImNotStable
Copy link
Author

Alright, thank you!

willkroboth added a commit that referenced this issue Dec 19, 2023
Use some sneaky reflection to intercept `net.minecraft.server.CommandDispatcher`'s task scheduling and enforce our own read-write access

Updates #501
Fixes #494 and #503
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants