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

fix: autocomplete strings come up with error. #426

Conversation

TreemanKing
Copy link
Contributor

So the list that is being filtered is immutable, hence doesn't work with in conjunction with removeIf.

There are two solutions, either

  • stream it (which I've done in this PR since I believe it to be more efficient)
    OR
  • create a new ArrayList each time for filtering since that is mutable
org.bukkit.command.CommandException: Unhandled exception during tab completion for command '/advancedportals create name:test3 command:"d' in plugin AdvancedPortals v1.0.0
	at org.bukkit.command.PluginCommand.tabComplete(PluginCommand.java:150) ~[PaperCrane-API-1.20.1-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.Command.tabComplete(Command.java:93) ~[PaperCrane-API-1.20.1-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.SimpleCommandMap.tabComplete(SimpleCommandMap.java:240) ~[PaperCrane-API-1.20.1-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_20_R1.CraftServer.tabCompleteCommand(CraftServer.java:2420) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at org.bukkit.craftbukkit.v1_20_R1.CraftServer.tabComplete(CraftServer.java:2392) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at org.bukkit.craftbukkit.v1_20_R1.command.BukkitCommandWrapper.getSuggestions(BukkitCommandWrapper.java:74) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at com.mojang.brigadier.tree.ArgumentCommandNode.listSuggestions(ArgumentCommandNode.java:71) ~[brigadier-1.1.8.jar:git-Paper-"c09094b"]
	at com.mojang.brigadier.CommandDispatcher.getCompletionSuggestions(CommandDispatcher.java:602) ~[papercrane-1.20.1.jar:?]
	at com.mojang.brigadier.CommandDispatcher.getCompletionSuggestions(CommandDispatcher.java:582) ~[papercrane-1.20.1.jar:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleCustomCommandSuggestions$6(ServerGamePacketListenerImpl.java:922) ~[?:?]
	at net.minecraft.server.TickTask.run(TickTask.java:18) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1337) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
	at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1314) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1307) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
	at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1285) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[papercrane-1.20.1.jar:git-Paper-"c09094b"]
	at java.lang.Thread.run(Thread.java:840) ~[?:?]```

So the list that is being filtered is immutable, hence doesn't work with in conjunction with removeIf.

There are two solutions, either
- stream it (which I've done in this PR)
OR
- create a new ArrayList each time for filtering since that is mutable
@sekwah41 sekwah41 merged commit 503955f into sekwah41:re-recode Jun 2, 2024
1 check passed
@TreemanKing TreemanKing deleted the fix-string-immutable-list-in-command branch June 2, 2024 04:52
sekwah41 pushed a commit that referenced this pull request Nov 18, 2024
So the list that is being filtered is immutable, hence doesn't work with in conjunction with removeIf.

There are two solutions, either
- stream it (which I've done in this PR)
OR
- create a new ArrayList each time for filtering since that is mutable
sekwah41 pushed a commit that referenced this pull request Nov 18, 2024
So the list that is being filtered is immutable, hence doesn't work with in conjunction with removeIf.

There are two solutions, either
- stream it (which I've done in this PR)
OR
- create a new ArrayList each time for filtering since that is mutable
This was referenced Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants