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
Some fixes for commands #3262
Some fixes for commands #3262
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this. I don't really see any issues with this beyond anything stylistic.
}); | ||
SpongeParameterizedCommandRegistrar.INSTANCE.register( | ||
|
||
// TODO: this used to be done after the event, do we care? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter. Callbacks in Sponge should be calling sponge:callback
anyway, so as long as that registers, it should be fine.
@@ -90,7 +90,7 @@ public SpongeParameterValueBuilder(@NonNull final Type token) { | |||
@Override | |||
public Parameter.Value.@NonNull Builder<T> setRequiredPermission(@Nullable final String permission) { | |||
if (permission == null) { | |||
return this.setUsage(null); | |||
return this.setRequirements(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...heh
public TypeToken<LiteralArgumentBuilder<CommandSource>> handledType() { | ||
return BrigadierCommandRegistrar.COMMAND_TYPE; | ||
public @NonNull CommandRegistrarType<LiteralArgumentBuilder<CommandSource>> type() { | ||
return TYPE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do a @Zidane - this should be BrigadierCommandRegistrar.TYPE
, fully qualifying all static access, even if in the same class.
public TypeToken<Command.Parameterized> handledType() { | ||
return SpongeParameterizedCommandRegistrar.COMMAND_TYPE; | ||
public @NonNull CommandRegistrarType<Command.Parameterized> type() { | ||
return TYPE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above
public TypeToken<Command.@NonNull Raw> handledType() { | ||
return SpongeRawCommandRegistrar.COMMAND_TYPE; | ||
public @NonNull CommandRegistrarType<Command.Raw> type() { | ||
return TYPE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above
153d6af
to
a8b5d2d
Compare
SpongeAPI | Sponge
This fixes some minor issues with commands, from things that came up in Discord and a few things that I noticed while reading through the implementation.
I'd still like to look at:
The function loading changes in 1.16 have meant that commands are initialized extremely early, and are re-initialized on every datapack reload. I'm thinking it'll probably make sense to convert the dispatcher registry into a dispatcher factory registry, and match the Mojang datapack lifecycle more closely with our registration sequence. Since Mojang's strategy is to fully register commands and load datapacks with the new set of commands before applying those commands to the active server, I think we'll want to just re-register commands on a whole new dispatcher, and remove all the singletons used.
ArgumentReader
toRaw
commands rather than just a plain StringThis seems like the closest we can get to allowing custom commands systems to match vanilla behaviour without binding them to constructing their own
Parameterized
commands. Unfortunately, I thinkCommandContext
takes in too much detail specific to parameterized/Brigadier commands for it to be exposed to raw commands without major design changes. I think theArgumentReader
can also expose enough low-level parsing to easily cover converting everything that is aClientCompletionType