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

CatalogType parser not working with all catalog types #1254

Closed
dualspiral opened this issue May 25, 2016 · 1 comment
Closed

CatalogType parser not working with all catalog types #1254

dualspiral opened this issue May 25, 2016 · 1 comment

Comments

@dualspiral
Copy link
Contributor

Currently, the CatalogedTypeCommandElement tries to make a match with the ID of the catalogued type (using .getId()) as seen here in getChoices(CommandSource) in the GenericArguments class.

In the case of

GenericArguments.onlyOne(GenericArguments.catalogedElement(Text.of(difficulty), CatalogTypes.DIFFICULTY))

rather than expecting the names "EASY", "PEACEFUL" etc., it at first seems like it's actually expecting options.difficulty.easy, options.difficulty.peaceful, etc.

However, when control then passes to getValue(String), here we find that Sponge.getGame().getRegistry().getType(this.catalogType, choice); fails to find anything, because choice here is not expecting options.difficulty.easy, but EASY, so no match can ever be made.

Using the latest SpongeVanilla, where the last argument of the command is the difficulty, I find this happens, first for normal, then for options.difficulty.normal:

[18:12:30 INFO] [nucleus]: Server ran the command: /world create test overworld flat survival normal
[18:12:30 INFO]: No values matching pattern 'normal' present for difficulty!
create test overworld flat survival normal
                                    ^
[18:12:30 INFO]: Usage: /world setdifficulty|teleport|setgamemode|list|delete|setspawn|spawn|load|create
> world create test overworld flat survival options.difficulty.normal
[18:12:32 INFO] [nucleus]: Server ran the command: /world create test overworld flat survival options.difficulty.normal
[18:12:32 INFO]: Error occurred while executing command: Invalid input options.difficulty.normal was found
[18:12:32 ERROR] [Sponge]: Error occurred while executing command 'world create test overworld flat survival options.difficulty.normal' for source DedicatedServer: Invalid input options.difficulty.normal was found
java.lang.IllegalArgumentException: Invalid input options.difficulty.normal was found
        at org.spongepowered.api.command.args.GenericArguments$CatalogedTypeCommandElement.getValue(GenericArguments.java:1340) ~[GenericArguments$CatalogedTypeCommandElement.class:1.8.9-4.1.0-BETA-314]
        at org.spongepowered.api.command.args.PatternMatchingCommandElement.parseValue(PatternMatchingCommandElement.java:59) ~[PatternMatchingCommandElement.class:1.8.9-4.1.0-BETA-314]
        at org.spongepowered.api.command.args.CommandElement.parse(CommandElement.java:83) ~[CommandElement.class:1.8.9-4.1.0-BETA-314]
@ST-DDT
Copy link
Member

ST-DDT commented May 25, 2016

Related: Broken CatalogTypes @ SpongeCommon #739

Excerpt from test plugin's error log (line 307f):

[ERROR]: Failed to obtain instance for Difficulty with id options.difficulty.normal
[ERROR]: Failed to obtain instance for Difficulty with id options.difficulty.hard
[ERROR]: Failed to obtain instance for Difficulty with id options.difficulty.easy
[ERROR]: Failed to obtain instance for Difficulty with id options.difficulty.peaceful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants