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

Command enum type does not show up #623

Open
AndreasHGK opened this issue Aug 1, 2022 · 4 comments
Open

Command enum type does not show up #623

AndreasHGK opened this issue Aug 1, 2022 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@AndreasHGK
Copy link
Contributor

I am trying to implement a /give command, and I want to have the suffix of the itemType be 'item' so it would look like <itemType: Item>
However, no matter what I do it always seems to be string.
image

My command looks like this

type Give struct {
	Player []cmd.Target
	Item   Item `cmd:"itemType,Item"`
	Count  cmd.Optional[uint]
	Data   cmd.Optional[int16]
}

and the Item enum type like this

type Item string

func (i Item) Type() string {
	return "Item"
}

func (i Item) Options(source cmd.Source) []string {
	return []string{"apple"}
}

Neither the suffix in the struct field tag nor the one returned in Type() seem to have any effect.

@Sandertv
Copy link
Member

Sandertv commented Aug 1, 2022

Just to clarify, the suffix doesn't change the parameter type. It allows something like this:
/xp <level: int>L, where L is the suffix. That said, this suffix doesn't seem to be showing up, so this is still an issue.

@Sandertv
Copy link
Member

Sandertv commented Aug 1, 2022

And, as you mentioned, the type from Type() not showing up is also an issue.

@Sandertv Sandertv added the bug Something isn't working label Aug 1, 2022
@Sandertv Sandertv added this to the v0.8.0 milestone Aug 1, 2022
@Sandertv
Copy link
Member

Sandertv commented Aug 2, 2022

After some investigating:

  1. It seems the issue of the enum type showing up as string is because we use soft enums for all enums (these can be changed at runtime). Commands in vanilla that use soft enums also have enums that show up as string. Not sure if and how we can resolve this, given we can't make any assurances the options returned by an enum implementations won't change at runtime.
  2. Parameter suffixes I have not been able to get working either. It seems under some circumstances the client even crashes with a suffix. Maybe the constant we have for this is not correct (anymore)?
  3. Enum collapsing doesn't seem to be working at all anymore. The builtin enum dragonfly has for bool does not get collapsed anymore and instead now shows up as <true|false|1|0>. This enum is not a soft enum, so that cannot be the reason here. Maybe the constant we have for this is not correct anymore?

@Sandertv Sandertv modified the milestones: v0.8.0, v0.9.0 Aug 4, 2022
@DaPigGuy DaPigGuy modified the milestones: v0.9.0, v0.10.0 Dec 22, 2022
@Sandertv
Copy link
Member

I think a solution to this would be to make all enums normal enums by default, and only mark them as a dynamic enum if a change was detected. In this case, we could send an AvailableCommands packet to replace the commands in question and change the normal enum to a dynamic enum client-side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants