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
Dieser Commit ist enthalten in:
Ursprung
c40d9c1e6c
Commit
bd28035024
@ -146,7 +146,9 @@ public final class StructureCompiler {
|
|||||||
private static String SUPER_CLASS = "com/comphenix/protocol/reflect/StructureModifier";
|
private static String SUPER_CLASS = "com/comphenix/protocol/reflect/StructureModifier";
|
||||||
private static String COMPILED_CLASS = PACKAGE_NAME + "/CompiledStructureModifier";
|
private static String COMPILED_CLASS = PACKAGE_NAME + "/CompiledStructureModifier";
|
||||||
private static String FIELD_EXCEPTION_CLASS = "com/comphenix/protocol/reflect/FieldAccessException";
|
private static String FIELD_EXCEPTION_CLASS = "com/comphenix/protocol/reflect/FieldAccessException";
|
||||||
|
|
||||||
|
public static boolean attemptClassLoad = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a structure compiler.
|
* Construct a structure compiler.
|
||||||
* @param loader - main class loader.
|
* @param loader - main class loader.
|
||||||
@ -163,18 +165,24 @@ public final class StructureCompiler {
|
|||||||
*/
|
*/
|
||||||
public <TField> boolean lookupClassLoader(StructureModifier<TField> source) {
|
public <TField> boolean lookupClassLoader(StructureModifier<TField> source) {
|
||||||
StructureKey key = new StructureKey(source);
|
StructureKey key = new StructureKey(source);
|
||||||
|
|
||||||
// See if there's a need to lookup the class name
|
// See if there's a need to lookup the class name
|
||||||
if (compiledCache.containsKey(key)) {
|
if (compiledCache.containsKey(key)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! attemptClassLoad) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This causes a ton of lag and doesn't seem to work
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String className = getCompiledName(source);
|
String className = getCompiledName(source);
|
||||||
|
|
||||||
// This class might have been generated before. Try to load it.
|
// This class might have been generated before. Try to load it.
|
||||||
Class<?> before = loader.loadClass(PACKAGE_NAME.replace('/', '.') + "." + className);
|
Class<?> before = loader.loadClass(PACKAGE_NAME.replace('/', '.') + "." + className);
|
||||||
|
|
||||||
if (before != null) {
|
if (before != null) {
|
||||||
compiledCache.put(key, before);
|
compiledCache.put(key, before);
|
||||||
return true;
|
return true;
|
||||||
@ -182,7 +190,7 @@ public final class StructureCompiler {
|
|||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
// That's ok.
|
// That's ok.
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to compile the class
|
// We need to compile the class
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren