Lamp icon indicating copy to clipboard operation
Lamp copied to clipboard

When only one player is allowed, the provided entity selector allows more than one.

Open HyperSkys opened this issue 1 year ago • 5 comments

For example, if I have a command like /bounty <target> <amount> with the code similar to this:

    @Command("bounty")
    public void onBountyCommand(Player sender, Player target, double amount) {
    }

It still suggests @a, @e, @n, @p, @r and upon for example trying to even type in /bounty @e it sends this error in console:

[17:55:18 ERROR]: Thread Async Tab Complete Thread - #0 failed main thread check: Chunk getEntities call
java.lang.Throwable: null
        at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.server.level.ServerLevel.getEntities(ServerLevel.java:2384) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.server.level.ServerLevel.getEntities(ServerLevel.java:1413) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.commands.arguments.selector.EntitySelector.addEntities(EntitySelector.java:174) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.commands.arguments.selector.EntitySelector.findEntities(EntitySelector.java:158) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at org.bukkit.craftbukkit.CraftServer.selectEntities(CraftServer.java:2927) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at org.bukkit.Bukkit.selectEntities(Bukkit.java:2558) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.bukkit.parameters.PlayerParameterType.fromSelector(PlayerParameterType.java:60) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.bukkit.parameters.PlayerParameterType.parse(PlayerParameterType.java:81) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.bukkit.parameters.PlayerParameterType.parse(PlayerParameterType.java:50) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.node.parser.ParameterNodeImpl.parse(ParameterNodeImpl.java:122) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.autocomplete.StandardAutoCompleter.complete(StandardAutoCompleter.java:147) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.autocomplete.StandardAutoCompleter.complete(StandardAutoCompleter.java:100) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.bukkit.listener.AsyncPaperTabListener.onAsyncTabComplete(AsyncPaperTabListener.java:62) ~[DufjiSMP-1.0.0-REL.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor8.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:1.21.1-89-1ed64f8]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:131) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.event.Event.callEvent(Event.java:45) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCustomCommandSuggestions0(ServerGamePacketListenerImpl.java:822) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleCustomCommandSuggestions$1(ServerGamePacketListenerImpl.java:811) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
[17:55:19 ERROR]: Thread Async Tab Complete Thread - #1 failed main thread check: Chunk getEntities call
java.lang.Throwable: null
        at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.server.level.ServerLevel.getEntities(ServerLevel.java:2384) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.server.level.ServerLevel.getEntities(ServerLevel.java:1413) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.commands.arguments.selector.EntitySelector.addEntities(EntitySelector.java:174) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.commands.arguments.selector.EntitySelector.findEntities(EntitySelector.java:158) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at org.bukkit.craftbukkit.CraftServer.selectEntities(CraftServer.java:2927) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at org.bukkit.Bukkit.selectEntities(Bukkit.java:2558) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.bukkit.parameters.PlayerParameterType.fromSelector(PlayerParameterType.java:60) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.bukkit.parameters.PlayerParameterType.parse(PlayerParameterType.java:81) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.bukkit.parameters.PlayerParameterType.parse(PlayerParameterType.java:50) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.node.parser.ParameterNodeImpl.parse(ParameterNodeImpl.java:122) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.autocomplete.StandardAutoCompleter.complete(StandardAutoCompleter.java:147) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.autocomplete.StandardAutoCompleter.complete(StandardAutoCompleter.java:100) ~[DufjiSMP-1.0.0-REL.jar:?]
        at DufjiSMP-1.0.0-REL.jar/revxrsal.commands.bukkit.listener.AsyncPaperTabListener.onAsyncTabComplete(AsyncPaperTabListener.java:62) ~[DufjiSMP-1.0.0-REL.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor8.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:1.21.1-89-1ed64f8]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:131) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.event.Event.callEvent(Event.java:45) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCustomCommandSuggestions0(ServerGamePacketListenerImpl.java:822) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleCustomCommandSuggestions$1(ServerGamePacketListenerImpl.java:811) ~[paper-1.21.1.jar:1.21.1-89-1ed64f8]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]

Then when sending the command, it sends out this error:

Only one player is allowed, but the provided selector allows more than one

Any idea on how to resolve this, or is this just a bug with Lamp?

HyperSkys avatar Oct 08 '24 22:10 HyperSkys

I see. Sounds like a problem with asynchronous tab completion. You could disable it as following:

BukkitLampConfig config = BukkitLampConfig.builder(plugin).disableAsyncCompletion().build();
Lamp<BukkitCommandActor> lamp = BukkitLamp.builder(config).build();

Can you try it and let me know if it persists?

Revxrsal avatar Oct 09 '24 13:10 Revxrsal

That does resolve the console error, but does not resolve the issue where it's suggesting using @a, @e, @n, @p, @r for a single player selector.

HyperSkys avatar Oct 10 '24 02:10 HyperSkys

This is Brigadier's default behavior. @a and @e can be minimized using further selectors (i.e. limit=1 or d=2) to reduce to one player, and the client will display the input in red if it does not.

Do you want to remove them altogether? Either disable Brigadier through the BukkitLampConfig, or register a SuggestionProvider for the Player class. That will automatically remove the @a, @e, etc.

Revxrsal avatar Oct 10 '24 10:10 Revxrsal

This is Brigadier's default behavior. @a and @e can be minimized using further selectors (i.e. limit=1 or d=2) to reduce to one player, and the client will display the input in red if it does not.

Do you want to remove them altogether? Either disable Brigadier through the BukkitLampConfig, or register a SuggestionProvider for the Player class. That will automatically remove the @a, @e, etc.

I'll do that and I'll share the code I make here, I think it's silly to suggest args that the user cannot use, but thanks for the help.

HyperSkys avatar Oct 10 '24 13:10 HyperSkys

This is Brigadier's default behavior. @a and @e can be minimized using further selectors (i.e. limit=1 or d=2) to reduce to one player, and the client will display the input in red if it does not. Do you want to remove them altogether? Either disable Brigadier through the BukkitLampConfig, or register a SuggestionProvider for the Player class. That will automatically remove the @a, @e, etc.

I'll do that and I'll share the code I make here, I think it's silly to suggest args that the user cannot use, but thanks for the help.

When you do this for your code, I would recommend adding a parameter that allows enabling/disabling them individually to make it more configurable. Maybe like an annotation @AllowA, @AllowE.

creatorfromhell avatar Oct 11 '24 20:10 creatorfromhell

Will close this as it is Brigadier's default behavior to allow this. It will show red and give an error if the selector does not reduce to a single entity/player.

Revxrsal avatar Dec 29 '24 20:12 Revxrsal