Commit 10c0f19286400c63870ec6db86703bfcf588573b
1 parent
b24caff3
fix accessor injection for mods which declare accessors in events.json
Showing
3 changed files
with
28 additions
and
3 deletions
java/common/com/mumfrey/liteloader/transformers/event/json/JsonEvents.java
... | ... | @@ -115,7 +115,12 @@ public class JsonEvents implements Serializable, ObfProvider |
115 | 115 | throw new InvalidEventJsonException("An error occurred whilst parsing the event definition: " + ex.getClass().getSimpleName() + ": " + ex.getMessage(), ex); |
116 | 116 | } |
117 | 117 | } |
118 | - | |
118 | + | |
119 | + public boolean hasAccessors() | |
120 | + { | |
121 | + return this.accessorInterfaces.size() > 0; | |
122 | + } | |
123 | + | |
119 | 124 | /** |
120 | 125 | * Parse a token name, returns the token name as a string if the token is valid, or null if the token is not valid |
121 | 126 | * | ... | ... |
java/common/com/mumfrey/liteloader/transformers/event/json/ModEventInjectionTransformer.java
... | ... | @@ -37,8 +37,6 @@ public class ModEventInjectionTransformer extends EventInjectionTransformer |
37 | 37 | { |
38 | 38 | LiteLoaderLogger.info("Parsing events for mod with id %s", def.getIdentifier()); |
39 | 39 | events = JsonEvents.parse(def.getJson()); |
40 | - events.register(this); | |
41 | - def.onEventsInjected(); | |
42 | 40 | } |
43 | 41 | catch (InvalidEventJsonException ex) |
44 | 42 | { |
... | ... | @@ -58,8 +56,15 @@ public class ModEventInjectionTransformer extends EventInjectionTransformer |
58 | 56 | { |
59 | 57 | if (events != null) |
60 | 58 | { |
59 | + if (events.hasAccessors()) | |
60 | + { | |
61 | + LiteLoaderLogger.info("%s contains Accessor definitions, injecting into classpath...", def.getIdentifier()); | |
62 | + def.injectIntoClassPath(); | |
63 | + } | |
64 | + | |
61 | 65 | LiteLoaderLogger.info("Registering events for mod with id %s", def.getIdentifier()); |
62 | 66 | events.register(this); |
67 | + def.onEventsInjected(); | |
63 | 68 | } |
64 | 69 | } |
65 | 70 | catch (Throwable ex) | ... | ... |
java/common/com/mumfrey/liteloader/transformers/event/json/ModEvents.java
1 | 1 | package com.mumfrey.liteloader.transformers.event.json; |
2 | 2 | |
3 | 3 | import java.io.File; |
4 | +import java.net.MalformedURLException; | |
4 | 5 | import java.util.HashMap; |
5 | 6 | import java.util.Map; |
6 | 7 | |
8 | +import net.minecraft.launchwrapper.Launch; | |
9 | + | |
7 | 10 | import com.google.common.base.Charsets; |
8 | 11 | import com.mumfrey.liteloader.api.EnumerationObserver; |
9 | 12 | import com.mumfrey.liteloader.core.ModInfo; |
... | ... | @@ -45,6 +48,18 @@ public class ModEvents implements EnumerationObserver |
45 | 48 | { |
46 | 49 | this.file.onEventsInjected(); |
47 | 50 | } |
51 | + | |
52 | + public void injectIntoClassPath() | |
53 | + { | |
54 | + try | |
55 | + { | |
56 | + this.file.injectIntoClassPath(Launch.classLoader, true); | |
57 | + } | |
58 | + catch (MalformedURLException ex) | |
59 | + { | |
60 | + ex.printStackTrace(); | |
61 | + } | |
62 | + } | |
48 | 63 | } |
49 | 64 | |
50 | 65 | private static final String DEFINITION_FILENAME = "events.json"; | ... | ... |