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.DataInputStream;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.Map;
@ -51,7 +50,7 @@ class ReadPacketModifier implements MethodInterceptor {
// Whether or not a packet has been cancelled
private static Map<Object, Object> override = new MapMaker().weakKeys().makeMap();
public ReadPacketModifier(int packetID, ProxyPacketInjector packetInjector, ErrorReporter reporter, boolean isReadPacketDataMethod) {
this.packetID = packetID;
this.packetInjector = packetInjector;
@ -91,15 +90,16 @@ class ReadPacketModifier implements MethodInterceptor {
Object overridenObject = override.get(thisObj);
Object returnValue = null;
// We need this in order to get the correct player
DataInputStream input = isReadPacketDataMethod ? (DataInputStream) args[0] : null;
ByteArrayOutputStream bufferStream = null;
// See if we need to buffer the read data
if (isReadPacketDataMethod && packetInjector.requireInputBuffers(packetID)) {
CaptureInputStream captured = new CaptureInputStream(
(InputStream) args[0],
bufferStream = new ByteArrayOutputStream());
input, bufferStream = new ByteArrayOutputStream());
// Stash it back
// Swap it with our custom stream
args[0] = new DataInputStream(captured);
}
@ -120,9 +120,10 @@ class ReadPacketModifier implements MethodInterceptor {
// Is this a readPacketData method?
if (isReadPacketDataMethod) {
// Swap back custom stream
args[0] = input;
try {
// We need this in order to get the correct player
DataInputStream input = (DataInputStream) args[0];
byte[] buffer = bufferStream != null ? bufferStream.toByteArray() : null;
// Let the people know