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

OptionalArg don't support collections types #378

Open
creatorfromhell opened this issue Feb 18, 2024 · 4 comments
Open

OptionalArg don't support collections types #378

creatorfromhell opened this issue Feb 18, 2024 · 4 comments
Labels
bug Something isn't working problem

Comments

@creatorfromhell
Copy link

This is a suggestion to change what class file LiteCommands looks for when it comes to collections. I think instead of checking for a suggestion on List.class, it should instead check the class of the objects the List contains. Example List should look for completion based on GameMode.class not List.class.

@Rollczi
Copy link
Owner

Rollczi commented Feb 18, 2024

This is how it currently works only indirectly to be able to better manage suggestions. LiteCommands -> List suggester -> GameMode suggester

@creatorfromhell
Copy link
Author

creatorfromhell commented Feb 18, 2024

This is how it currently works only indirectly to be able to better manage suggestions. LiteCommands -> List suggester -> GameMode suggester

Currently, when providing for the class type of the object in the collection, and not providing for the collection class results in an error. As an example, I changed to using ArgumentKey as suggested in #377 and it errors out when it gets to the List argument.

java.lang.IllegalArgumentException: No parser found for argument List
	at phantomworlds.libs.lc.litecommands.argument.parser.ParserSet.getValidParserOrThrow(ParserSet.java:17) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.input.raw.RawInputAnalyzer.isNextOptional(RawInputAnalyzer.java:63) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.argument.suggester.input.SuggestionInputRawImpl$Matcher.isNextOptional(SuggestionInputRawImpl.java:71) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggestArgument(SuggestionService.java:109) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggestExecutor(SuggestionService.java:87) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggest0(SuggestionService.java:55) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggest(SuggestionService.java:34) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.command.CommandManager$PlatformListener.suggest(CommandManager.java:71) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.BukkitCommand.suggest(BukkitCommand.java:82) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.TabComplete.callListener(TabComplete.java:65) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.TabCompletePaperAsync.executeListener(TabCompletePaperAsync.java:25) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.TabCompletePaperAsync.lambda$new$0(TabCompletePaperAsync.java:20) ~[PhantomWorlds-2.0.5.jar:?]
	at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:77) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:git-Purpur-2092]
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[purpur-1.20.2.jar:git-Purpur-2092]
	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[purpur-1.20.2.jar:git-Purpur-2092]
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:617) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.event.Event.callEvent(Event.java:45) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleCustomCommandSuggestions$7(ServerGamePacketListenerImpl.java:822) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
	at java.lang.Thread.run(Thread.java:1623) ~[?:?]

Code to register argument parser:

.argument(String.class, ArgumentKey.of("world-setting"), new SettingParameterRedux())

@Rollczi
Copy link
Owner

Rollczi commented Feb 18, 2024

This is how it currently works only indirectly to be able to better manage suggestions. LiteCommands -> List suggester -> GameMode suggester

Currently, when providing for the class type of the object in the collection, and not providing for the collection class results in an error. As an example, I changed to using ArgumentKey as suggested in #377 and it errors out when it gets to the List argument.

java.lang.IllegalArgumentException: No parser found for argument List
	at phantomworlds.libs.lc.litecommands.argument.parser.ParserSet.getValidParserOrThrow(ParserSet.java:17) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.input.raw.RawInputAnalyzer.isNextOptional(RawInputAnalyzer.java:63) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.argument.suggester.input.SuggestionInputRawImpl$Matcher.isNextOptional(SuggestionInputRawImpl.java:71) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggestArgument(SuggestionService.java:109) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggestExecutor(SuggestionService.java:87) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggest0(SuggestionService.java:55) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggest(SuggestionService.java:34) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.command.CommandManager$PlatformListener.suggest(CommandManager.java:71) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.BukkitCommand.suggest(BukkitCommand.java:82) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.TabComplete.callListener(TabComplete.java:65) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.TabCompletePaperAsync.executeListener(TabCompletePaperAsync.java:25) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.TabCompletePaperAsync.lambda$new$0(TabCompletePaperAsync.java:20) ~[PhantomWorlds-2.0.5.jar:?]
	at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:77) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:git-Purpur-2092]
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[purpur-1.20.2.jar:git-Purpur-2092]
	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[purpur-1.20.2.jar:git-Purpur-2092]
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:617) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.event.Event.callEvent(Event.java:45) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleCustomCommandSuggestions$7(ServerGamePacketListenerImpl.java:822) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
	at java.lang.Thread.run(Thread.java:1623) ~[?:?]

Code to register argument parser:

.argument(String.class, ArgumentKey.of("world-setting"), new SettingParameterRedux())

I cannot reproduce this issue. You can see how use List<T> arguments in the following example
When I use list arguments, everything works normally. Maybe this is a problem with the use of @OptionalArg ? Try use @Arg (a collection can be empty)

@creatorfromhell
Copy link
Author

This is how it currently works only indirectly to be able to better manage suggestions. LiteCommands -> List suggester -> GameMode suggester

Currently, when providing for the class type of the object in the collection, and not providing for the collection class results in an error. As an example, I changed to using ArgumentKey as suggested in #377 and it errors out when it gets to the List argument.

java.lang.IllegalArgumentException: No parser found for argument List
	at phantomworlds.libs.lc.litecommands.argument.parser.ParserSet.getValidParserOrThrow(ParserSet.java:17) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.input.raw.RawInputAnalyzer.isNextOptional(RawInputAnalyzer.java:63) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.argument.suggester.input.SuggestionInputRawImpl$Matcher.isNextOptional(SuggestionInputRawImpl.java:71) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggestArgument(SuggestionService.java:109) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggestExecutor(SuggestionService.java:87) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggest0(SuggestionService.java:55) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.suggestion.SuggestionService.suggest(SuggestionService.java:34) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.command.CommandManager$PlatformListener.suggest(CommandManager.java:71) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.BukkitCommand.suggest(BukkitCommand.java:82) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.TabComplete.callListener(TabComplete.java:65) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.TabCompletePaperAsync.executeListener(TabCompletePaperAsync.java:25) ~[PhantomWorlds-2.0.5.jar:?]
	at phantomworlds.libs.lc.litecommands.bukkit.TabCompletePaperAsync.lambda$new$0(TabCompletePaperAsync.java:20) ~[PhantomWorlds-2.0.5.jar:?]
	at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:77) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:git-Purpur-2092]
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[purpur-1.20.2.jar:git-Purpur-2092]
	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[purpur-1.20.2.jar:git-Purpur-2092]
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:617) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.event.Event.callEvent(Event.java:45) ~[purpur-api-1.20.2-R0.1-SNAPSHOT.jar:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleCustomCommandSuggestions$7(ServerGamePacketListenerImpl.java:822) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
	at java.lang.Thread.run(Thread.java:1623) ~[?:?]

Code to register argument parser:

.argument(String.class, ArgumentKey.of("world-setting"), new SettingParameterRedux())

I cannot reproduce this issue. You can see how use List<T> arguments in the following example When I use list arguments, everything works normally. Maybe this is a problem with the use of @OptionalArg ? Try use @Arg (a collection can be empty)

Seems to be the case with OptionalArg throwing the error.

Thank You,

@Rollczi Rollczi reopened this Feb 18, 2024
@Rollczi Rollczi changed the title Change Collection Suggestion OptionalArg don't support collections types Feb 18, 2024
@vLuckyyy vLuckyyy added bug Something isn't working problem labels Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working problem
Projects
Status: Todo
Development

No branches or pull requests

3 participants