Archiviert
13
0

Don't pass our CaptureInputStream to the "get player identity" function

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-07-17 23:02:16 +02:00
Ursprung a31dc6fdcb
Commit 7f69c41bf6

Datei anzeigen

@ -19,7 +19,6 @@ package com.comphenix.protocol.injector.packet;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.InputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Map; import java.util.Map;
@ -91,15 +90,16 @@ class ReadPacketModifier implements MethodInterceptor {
Object overridenObject = override.get(thisObj); Object overridenObject = override.get(thisObj);
Object returnValue = null; Object returnValue = null;
// We need this in order to get the correct player
DataInputStream input = isReadPacketDataMethod ? (DataInputStream) args[0] : null;
ByteArrayOutputStream bufferStream = null; ByteArrayOutputStream bufferStream = null;
// See if we need to buffer the read data // See if we need to buffer the read data
if (isReadPacketDataMethod && packetInjector.requireInputBuffers(packetID)) { if (isReadPacketDataMethod && packetInjector.requireInputBuffers(packetID)) {
CaptureInputStream captured = new CaptureInputStream( CaptureInputStream captured = new CaptureInputStream(
(InputStream) args[0], input, bufferStream = new ByteArrayOutputStream());
bufferStream = new ByteArrayOutputStream());
// Stash it back // Swap it with our custom stream
args[0] = new DataInputStream(captured); args[0] = new DataInputStream(captured);
} }
@ -120,9 +120,10 @@ class ReadPacketModifier implements MethodInterceptor {
// Is this a readPacketData method? // Is this a readPacketData method?
if (isReadPacketDataMethod) { if (isReadPacketDataMethod) {
// Swap back custom stream
args[0] = input;
try { try {
// We need this in order to get the correct player
DataInputStream input = (DataInputStream) args[0];
byte[] buffer = bufferStream != null ? bufferStream.toByteArray() : null; byte[] buffer = bufferStream != null ? bufferStream.toByteArray() : null;
// Let the people know // Let the people know