Commit fb593da6c01bcbc429950704a61af1d0cb8a0190
1 parent
c4b01822
remove last vestiges of PacketTransformer handling and fix mod-supplied transformers
Showing
1 changed file
with
7 additions
and
33 deletions
java/common/com/mumfrey/liteloader/launch/ClassTransformerManager.java
... | ... | @@ -2,7 +2,6 @@ package com.mumfrey.liteloader.launch; |
2 | 2 | |
3 | 3 | import java.lang.reflect.Field; |
4 | 4 | import java.util.*; |
5 | -import java.util.Map.Entry; | |
6 | 5 | |
7 | 6 | import org.apache.logging.log4j.Logger; |
8 | 7 | import org.apache.logging.log4j.core.LogEvent; |
... | ... | @@ -12,7 +11,6 @@ import net.minecraft.launchwrapper.IClassTransformer; |
12 | 11 | import net.minecraft.launchwrapper.LaunchClassLoader; |
13 | 12 | import net.minecraft.launchwrapper.LogWrapper; |
14 | 13 | |
15 | -import com.mumfrey.liteloader.util.SortableValue; | |
16 | 14 | import com.mumfrey.liteloader.util.log.LiteLoaderLogger; |
17 | 15 | |
18 | 16 | /** |
... | ... | @@ -28,19 +26,9 @@ public class ClassTransformerManager |
28 | 26 | private boolean gameStarted; |
29 | 27 | |
30 | 28 | /** |
31 | - * Transformers to inject | |
32 | - */ | |
33 | - private Set<String> pendingTransformers = new HashSet<String>(); | |
34 | - | |
35 | - /** | |
36 | 29 | * Transformers to inject after preInit but before the game starts, necessary for anything that needs to be downstream of forge |
37 | 30 | */ |
38 | - private Set<String> downstreamTransformers = new HashSet<String>(); | |
39 | - | |
40 | - /** | |
41 | - * Packet transformers, seived from the injectedTransformers list | |
42 | - */ | |
43 | - private Map<String, TreeSet<SortableValue<String>>> packetTransformers = new HashMap<String, TreeSet<SortableValue<String>>>(); | |
31 | + private Set<String> downstreamTransformers = new LinkedHashSet<String>(); | |
44 | 32 | |
45 | 33 | /** |
46 | 34 | * Transformers passed into the constructor which are required and must be injected upstream |
... | ... | @@ -50,7 +38,7 @@ public class ClassTransformerManager |
50 | 38 | /** |
51 | 39 | * Transformers successfully injected by us |
52 | 40 | */ |
53 | - private final Set<String> injectedTransformers = new HashSet<String>(); | |
41 | + private final Set<String> injectedTransformers = new LinkedHashSet<String>(); | |
54 | 42 | |
55 | 43 | /** |
56 | 44 | * Catalogue of transformer startup failures |
... | ... | @@ -112,7 +100,7 @@ public class ClassTransformerManager |
112 | 100 | { |
113 | 101 | if (!this.gameStarted) |
114 | 102 | { |
115 | - this.pendingTransformers.add(transformerClass); | |
103 | + this.downstreamTransformers.add(transformerClass); | |
116 | 104 | return true; |
117 | 105 | } |
118 | 106 | |
... | ... | @@ -127,7 +115,7 @@ public class ClassTransformerManager |
127 | 115 | { |
128 | 116 | if (!this.gameStarted) |
129 | 117 | { |
130 | - this.pendingTransformers.addAll(transformerClasses); | |
118 | + this.downstreamTransformers.addAll(transformerClasses); | |
131 | 119 | return true; |
132 | 120 | } |
133 | 121 | |
... | ... | @@ -142,7 +130,7 @@ public class ClassTransformerManager |
142 | 130 | { |
143 | 131 | if (!this.gameStarted) |
144 | 132 | { |
145 | - this.pendingTransformers.addAll(Arrays.asList(transformerClasses)); | |
133 | + this.downstreamTransformers.addAll(Arrays.asList(transformerClasses)); | |
146 | 134 | return true; |
147 | 135 | } |
148 | 136 | |
... | ... | @@ -159,21 +147,6 @@ public class ClassTransformerManager |
159 | 147 | LiteLoaderLogger.info("Injecting required class transformer '%s'", requiredTransformerClassName); |
160 | 148 | this.injectTransformer(classLoader, requiredTransformerClassName); |
161 | 149 | } |
162 | - | |
163 | - for (Entry<String, TreeSet<SortableValue<String>>> packetClassTransformers : this.packetTransformers.entrySet()) | |
164 | - { | |
165 | - for (SortableValue<String> transformerInfo : packetClassTransformers.getValue()) | |
166 | - { | |
167 | - String packetClass = packetClassTransformers.getKey(); | |
168 | - String transformerClassName = transformerInfo.getValue(); | |
169 | - if (packetClass.lastIndexOf('.') != -1) packetClass = packetClass.substring(packetClass.lastIndexOf('.') + 1); | |
170 | - LiteLoaderLogger.info("Injecting packet class transformer '%s' for packet class '%s' with priority %d", transformerClassName, packetClass, transformerInfo.getPriority()); | |
171 | - this.injectTransformer(classLoader, transformerClassName); | |
172 | - } | |
173 | - } | |
174 | - | |
175 | - // inject any transformers received after this point directly into the downstreamTransformers set | |
176 | - this.pendingTransformers = this.downstreamTransformers; | |
177 | 150 | } |
178 | 151 | |
179 | 152 | /** |
... | ... | @@ -181,6 +154,8 @@ public class ClassTransformerManager |
181 | 154 | */ |
182 | 155 | void injectDownstreamTransformers(LaunchClassLoader classLoader) |
183 | 156 | { |
157 | + this.gameStarted = true; | |
158 | + | |
184 | 159 | if (this.downstreamTransformers.size() > 0) |
185 | 160 | LiteLoaderLogger.info("Injecting downstream transformers"); |
186 | 161 | |
... | ... | @@ -191,7 +166,6 @@ public class ClassTransformerManager |
191 | 166 | } |
192 | 167 | |
193 | 168 | this.downstreamTransformers.clear(); |
194 | - this.gameStarted = true; | |
195 | 169 | } |
196 | 170 | |
197 | 171 | private synchronized void injectTransformer(LaunchClassLoader classLoader, String transformerClassName) | ... | ... |