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

Could not derive type for command choice #83

Closed
3 tasks done
axieum opened this issue Jun 10, 2023 · 0 comments · Fixed by #90 or #93
Closed
3 tasks done

Could not derive type for command choice #83

axieum opened this issue Jun 10, 2023 · 0 comments · Fixed by #90 or #93
Labels
bug Something isn't working minecord-cmds Improvements or additions to the commands module

Comments

@axieum
Copy link
Owner

axieum commented Jun 10, 2023

Expected behavior

For command choice types to be parsed correctly.

Observed/actual behavior

java.lang.IllegalArgumentException: Could not derive type for command choice: Reload
	at me.axieum.mcmod.minecord.impl.cmds.config.CommandConfig$BaseCommandSchema$OptionSchema.getOptionData(CommandConfig.java:292) ~[main/:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
	at me.axieum.mcmod.minecord.impl.cmds.command.discord.CustomCommand.<init>(CustomCommand.java:78) ~[main/:?]
	at me.axieum.mcmod.minecord.impl.cmds.MinecordCommandsImpl.initCommands(MinecordCommandsImpl.java:93) ~[main/:?]
	at me.axieum.mcmod.minecord.impl.cmds.MinecordCommandsImpl.onInitializeMinecord(MinecordCommandsImpl.java:52) ~[main/:?]

Steps/models to reproduce

Add a custom command with choices, e.g.

{
    /* A Minecraft command to execute
       Usages: ${<name>} for "<name>" option value
    */
    "command": "/whitelist ${option} ${username}",
    // A list of command options
    "options": [
        {
            /* The type of option
               Allowed values: ATTACHMENT, BOOLEAN, CHANNEL, INTEGER, MENTIONABLE, NUMBER, ROLE, STRING and USER
            */
            "type": "STRING",
            // The option name
            "name": "option",
            // A brief description of what the option does
            "description": "Whether to add or remove the player from the whitelist",
            // True if the option is required
            "required": true,
            // If non-empty, restricts the value to one of the allowed choices
            "choices": [
                {
                    // The choice name
                    "name": "add",
                    // The allowed value, which type matches that of the option
                    "value": "add"
                },
                {
                    // The choice name
                    "name": "remove",
                    // The allowed value, which type matches that of the option
                    "value": "remove"
                }
            ]
        },
        {
            /* The type of option
               Allowed values: ATTACHMENT, BOOLEAN, CHANNEL, INTEGER, MENTIONABLE, NUMBER, ROLE, STRING and USER
            */
            "type": "STRING",
            // The option name
            "name": "username",
            // A brief description of what the option does
            "description": "The username or UUID of the player to whitelist",
            // True if the option is required
            "required": true,
            // If non-empty, restricts the value to one of the allowed choices
            "choices": []
        }
    ],
    // True if the command should be available for use
    "enabled": true,
    // Trigger name for the command
    "name": "whitelist",
    // A brief description of what the command does
    "description": "Adds or removes a player from the server whitelist",
    // True if the command feedback is only visible to the executor
    "ephemeral": false,
    // True if anyone can use the command by default
    "allowByDefault": false,
    // The number of seconds a user must wait before using the command again
    "cooldown": 0,
    /* To whom the cooldown applies
       Allowed values: USER, CHANNEL, USER_CHANNEL, GUILD, USER_GUILD, SHARD, USER_SHARD and GLOBAL
    */
    "cooldownScope": "USER"
}

Version

v2.0.1+1.20

Agreements

  • I am running the latest version of the mod.
  • My version of Minecraft is supported.
  • I have searched for and ensured there isn't already an open issue regarding this.

Other

No response

@axieum axieum added bug Something isn't working minecord-cmds Improvements or additions to the commands module labels Jun 10, 2023
axieum added a commit that referenced this issue Jul 24, 2023
…83)

This was caused by it being deserialized as `JsonPrimitive`, and then this object being serialized back to disk.
axieum added a commit that referenced this issue Jul 28, 2023
…83)

This was caused by it being deserialized as `JsonPrimitive`, and then this object being serialized back to disk.
axieum added a commit that referenced this issue Jul 28, 2023
…83) (#90)

This was caused by it being deserialized as `JsonPrimitive`, and then this object being serialized back to disk.
axieum added a commit that referenced this issue Jul 28, 2023
…83) (#90)

This was caused by it being deserialized as `JsonPrimitive`, and then this object being serialized back to disk.

(cherry picked from commit 70574c4)
axieum added a commit that referenced this issue Oct 19, 2023
fix(chat): do not check player count during server start-up on Discord messages (fixes #84) (#91)
  (cherry picked from commit 8cddbeb)

refactor: defer config loading and reloading (#92)
  (cherry picked from commit e252ddb)

fix(cmds): option choices were incorrectly serializing to disk (fixes #83) (#90)
  This was caused by it being deserialized as JsonPrimitive, and then this object being serialized back to disk.
  (cherry picked from commit 70574c4)

chore(deps): update dependency JDA to v5.0.0-beta.15
chore(deps): update dependency fabric-api to v0.87.1+1.19.4
chore(deps): update dependency fabric-loader to v0.14.23
build(deps): update dependency checkstyle to v10.12.4
build(deps): update dependency fabric-loom to v1.4-SNAPSHOT
build(deps): upgrade gradle wrapper to v8.4
build(deps): update dependency junit to v5.10.0
build(deps): update dependency minotaur to v2.8.4
build(deps): update dependency shadow to v8.1.1
build(deps): update dependency yarn to v1.19.4+build.2

refactor: tidy up mixins
axieum added a commit that referenced this issue Oct 19, 2023
…83) (#90)

This was caused by it being deserialized as `JsonPrimitive`, and then this object being serialized back to disk.

(cherry picked from commit 70574c4)
axieum added a commit that referenced this issue Oct 19, 2023
…83) (#110)

This was caused by it being deserialized as `JsonPrimitive`, and then this object being serialized back to disk.

(cherry picked from commit 70574c4)
This was referenced Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working minecord-cmds Improvements or additions to the commands module
Projects
None yet
1 participant