Skip to content

Commit bd28035

Browse files
committed
Don't load classes when we're checking for them
This causes a ton of lag and doesn't seem to ever work Addresses #124
1 parent c40d9c1 commit bd28035

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ public boolean equals(Object obj) {
146146
private static String SUPER_CLASS = "com/comphenix/protocol/reflect/StructureModifier";
147147
private static String COMPILED_CLASS = PACKAGE_NAME + "/CompiledStructureModifier";
148148
private static String FIELD_EXCEPTION_CLASS = "com/comphenix/protocol/reflect/FieldAccessException";
149-
149+
150+
public static boolean attemptClassLoad = false;
151+
150152
/**
151153
* Construct a structure compiler.
152154
* @param loader - main class loader.
@@ -163,26 +165,32 @@ public boolean equals(Object obj) {
163165
*/
164166
public <TField> boolean lookupClassLoader(StructureModifier<TField> source) {
165167
StructureKey key = new StructureKey(source);
166-
168+
167169
// See if there's a need to lookup the class name
168170
if (compiledCache.containsKey(key)) {
169171
return true;
170172
}
171-
173+
174+
if (! attemptClassLoad) {
175+
return false;
176+
}
177+
178+
// This causes a ton of lag and doesn't seem to work
179+
172180
try {
173181
String className = getCompiledName(source);
174-
182+
175183
// This class might have been generated before. Try to load it.
176184
Class<?> before = loader.loadClass(PACKAGE_NAME.replace('/', '.') + "." + className);
177-
185+
178186
if (before != null) {
179187
compiledCache.put(key, before);
180188
return true;
181189
}
182190
} catch (ClassNotFoundException e) {
183191
// That's ok.
184192
}
185-
193+
186194
// We need to compile the class
187195
return false;
188196
}

0 commit comments

Comments
 (0)