EngineHub / Piston

A generic command system, with tie-ins to many Minecraft platforms such as Bukkit, Forge, and Sponge.
GNU General Public License v3.0
17 stars 3 forks source link

Exception thrown when parsing mid-command optionals #9

Closed wizjany closed 5 years ago

wizjany commented 5 years ago

Since this isn't actually a parsing exception, this will trigger both during suggestion parsing and execute parsing. (Normally, the suggester catches parse exceptions to provide suggestions).

Can be reproduced right now in worldedit with commands such as //replace ^quartz_stairs stone_brick_stairs Note that //replace ^quartz_stairs is a valid command (parsing as a pattern), but as soon as //replace ^quartz_stairs s... is typed, ^quartz_stairs needs to be bound to a mask instead (which it is not) and thus the exception:

Caused by: java.lang.ClassCastException: org.enginehub.piston.converter.SuccessfulConversion cannot be cast to org.enginehub.piston.converter.FailedConversion
    at org.enginehub.piston.impl.CommandParser.conversionFailedException(CommandParser.java:173) ~[core-7.0.0-SNAPSHOT.jar:?]
    at org.enginehub.piston.impl.CommandParser.parse(CommandParser.java:314) ~[core-7.0.0-SNAPSHOT.jar:?]
    at org.enginehub.piston.impl.CommandManagerImpl.parse(CommandManagerImpl.java:228) ~[core-7.0.0-SNAPSHOT.jar:?]
    at org.enginehub.piston.impl.CommandManagerImpl.getSuggestions(CommandManagerImpl.java:179) ~[core-7.0.0-SNAPSHOT.jar:?]
    at com.sk89q.worldedit.extension.platform.PlatformCommandManager.handleCommandSuggestion(PlatformCommandManager.java:570) ~[classes/:?]
    at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source) ~[?:?]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
    at com.sk89q.worldedit.util.eventbus.MethodEventHandler.dispatch(MethodEventHandler.java:58) ~[classes/:?]
    at com.sk89q.worldedit.util.eventbus.EventHandler.handleEvent(EventHandler.java:73) ~[classes/:?]
    ... 26 more
wizjany commented 5 years ago

btw possibly related - might be a separate issue though? https://gfycat.com/DistortedPertinentBobolink the radius/density or 5 and 5 are optional, but specifying them throws off the parser and it seems to lose track of where it is.