soft-fail when using invalid entity type

Issue #84 resolved
mezzodrinker created an issue

When using a non-existent entity type (e. g. skeleton), Minecraft will kick the user back into the main menu due to the following exception:

java.lang.IllegalArgumentException: unknown entity type name: skeleton
  at net.mobtalker.mobtalker2.entity.EntityType.forName(EntityType.java:316) ~[EntityType.class:?]
  at net.mobtalker.mobtalker2.resources.scriptpack.ConfigurableScriptPack.loadInteractionEntry(ConfigurableScriptPack.java:51) ~[ConfigurableScriptPack.class:?]
  at net.mobtalker.mobtalker2.resources.scriptpack.ConfigurableScriptPack.<init>(ConfigurableScriptPack.java:41) ~[ConfigurableScriptPack.class:?]
  at net.mobtalker.mobtalker2.resources.scriptpack.FileScriptPack.<init>(FileScriptPack.java:48) ~[FileScriptPack.class:?]
  at net.mobtalker.mobtalker2.resources.scriptpack.FileScriptPack.from(FileScriptPack.java:37) ~[FileScriptPack.class:?]
  at net.mobtalker.mobtalker2.resources.scriptpack.ScriptPackDiscoverer.discover(ScriptPackDiscoverer.java:54) ~[ScriptPackDiscoverer.class:?]
  at net.mobtalker.mobtalker2.resources.scriptpack.ScriptPackRepository.load(ScriptPackRepository.java:70) ~[ScriptPackRepository.class:?]
  at net.mobtalker.mobtalker2.MobTalkerCommonProxy.onServerAboutToStart(MobTalkerCommonProxy.java:60) ~[MobTalkerCommonProxy.class:?]
  at net.mobtalker.mobtalker2.MobTalker2.onServerAboutToStart(MobTalker2.java:79) ~[MobTalker2.class:?]
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
  at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
  at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553) ~[forge-1.8-11.14.4.1577.jar:?]
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
  at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
  at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
  at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
  at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
  at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
  at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
  at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:?]
  at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:?]
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
  at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
  at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
  at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
  at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
  at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
  at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
  at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) ~[LoadController.class:?]
  at net.minecraftforge.fml.common.Loader.serverAboutToStart(Loader.java:851) [Loader.class:?]
  at net.minecraftforge.fml.common.FMLCommonHandler.handleServerAboutToStart(FMLCommonHandler.java:314) [FMLCommonHandler.class:?]
  at net.minecraft.server.integrated.IntegratedServer.func_71197_b(IntegratedServer.java:125) [cyk.class:?]
  at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:438) [MinecraftServer.class:?]

The expected behaviour would be to display an error message that the entity type could not be found (and, maybe, provide alternatives).

Comments (6)

  1. mezzodrinker reporter

    Implement soft-fail for entity types in Script Pack config

    Made ConfigurableScriptPack soft-fail on invalid entity type (fixes #84) Added suggestions for alternative entity types on error Modified EntityType to use Either and Option ScriptApiCheck.checkEntityType now provides more detailed error messages

    → <<cset c920ae645c3c>>

  2. Log in to comment