Archiviert
13
0

Fixed incorrect detection of "custom" net handlers.

This should ensure that users on MCPC no longer recieves the 
REPORT_DETECTED_CUSTOM_SERVER_HANDLER warning just for using MCPC.
Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-05-31 22:57:00 +02:00
Ursprung bbe766cf23
Commit 77346f8438
2 geänderte Dateien mit 683 neuen und 666 gelöschten Zeilen

Datei anzeigen

@ -11,12 +11,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>net.sourceforge.metrics.builder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>net.sourceforge.metrics.builder</name>
<arguments>
</arguments>
</buildCommand>

Datei anzeigen

@ -358,13 +358,16 @@ public abstract class PlayerInjector implements SocketInjector {
private Field getProxyField(Object notchEntity, Field serverField) {
try {
Object handler = FieldUtils.readField(serverHandlerField, notchEntity, true);
Object currentHandler = FieldUtils.readField(serverHandlerField, notchEntity, true);
// Is this a Minecraft hook?
if (handler != null && !MinecraftReflection.isMinecraftObject(handler)) {
// This is bad
if (currentHandler == null)
throw new IllegalAccessError("Unable to fetch server handler: was NUll.");
// See if this isn't a standard net handler class
if (!isStandardMinecraftNetHandler(currentHandler)) {
// This is our proxy object
if (handler instanceof Factory)
if (currentHandler instanceof Factory)
return null;
hasProxyType = true;
@ -372,7 +375,7 @@ public abstract class PlayerInjector implements SocketInjector {
// No? Is it a Proxy type?
try {
FuzzyReflection reflection = FuzzyReflection.fromObject(handler, true);
FuzzyReflection reflection = FuzzyReflection.fromObject(currentHandler, true);
// It might be
return reflection.getFieldByType("NetServerHandler", MinecraftReflection.getNetServerHandlerClass());
@ -390,6 +393,20 @@ public abstract class PlayerInjector implements SocketInjector {
return null;
}
/**
* Determine if a given object is a standard Minecraft net handler.
* @param obj the object to test.
* @return TRUE if it is, FALSE otherwise.
*/
private boolean isStandardMinecraftNetHandler(Object obj) {
if (obj == null)
return false;
Class<?> clazz = obj.getClass();
return MinecraftReflection.getNetLoginHandlerClass().equals(clazz) ||
MinecraftReflection.getNetServerHandlerClass().equals(clazz);
}
/**
* Retrieves the current net handler for this player.
* @return Current net handler.