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

Some fixes for commands #3262

Merged
merged 10 commits into from Jan 29, 2021
Merged

Some fixes for commands #3262

merged 10 commits into from Jan 29, 2021

Conversation

zml2008
Copy link
Member

@zml2008 zml2008 commented Jan 22, 2021

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:

  • Dispatcher lifecycle
    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.
  • The possibility of passing through an ArgumentReader to Raw commands rather than just a plain String
    This 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 think CommandContext takes in too much detail specific to parameterized/Brigadier commands for it to be exposed to raw commands without major design changes. I think the ArgumentReader can also expose enough low-level parsing to easily cover converting everything that is a ClientCompletionType

Copy link
Contributor

@dualspiral dualspiral left a 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?
Copy link
Contributor

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);
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

@zml2008 zml2008 merged commit 5c7d58e into api-8 Jan 29, 2021
@zml2008 zml2008 deleted the feature/commands-tweaks branch January 29, 2021 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants