Archiviert
13
0

Don't assume the InputStream is an DataInputStream in Spigot's case.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-08-27 23:23:30 +02:00
Ursprung be9bbc924e
Commit 3f8a48732e
5 geänderte Dateien mit 11 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -19,6 +19,7 @@ package com.comphenix.protocol.injector.packet;
import java.io.DataInput; import java.io.DataInput;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.InputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Map; import java.util.Map;
@ -314,13 +315,13 @@ class ProxyPacketInjector implements PacketInjector {
} }
// Called from the ReadPacketModified monitor // Called from the ReadPacketModified monitor
public PacketEvent packetRecieved(PacketContainer packet, DataInputStream input, byte[] buffered) { public PacketEvent packetRecieved(PacketContainer packet, InputStream input, byte[] buffered) {
if (playerInjection.canRecievePackets()) { if (playerInjection.canRecievePackets()) {
return playerInjection.handlePacketRecieved(packet, input, buffered); return playerInjection.handlePacketRecieved(packet, input, buffered);
} }
try { try {
Player client = playerInjection.getPlayerByConnection(input); Player client = playerInjection.getPlayerByConnection((DataInputStream) input);
// Never invoke a event if we don't know where it's from // Never invoke a event if we don't know where it's from
if (client != null) { if (client != null) {

Datei anzeigen

@ -19,6 +19,7 @@ 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;
@ -102,7 +103,7 @@ class ReadPacketModifier implements MethodInterceptor {
Object returnValue = null; Object returnValue = null;
// We need this in order to get the correct player // We need this in order to get the correct player
DataInputStream input = isReadPacketDataMethod ? (DataInputStream) args[0] : null; InputStream input = isReadPacketDataMethod ? (InputStream) 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

Datei anzeigen

@ -1,6 +1,7 @@
package com.comphenix.protocol.injector.player; package com.comphenix.protocol.injector.player;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Set; import java.util.Set;
@ -173,7 +174,7 @@ public interface PlayerInjectionHandler {
* @param buffered - the buffered packet. * @param buffered - the buffered packet.
* @return The packet event. * @return The packet event.
*/ */
public abstract PacketEvent handlePacketRecieved(PacketContainer packet, DataInputStream input, byte[] buffered); public abstract PacketEvent handlePacketRecieved(PacketContainer packet, InputStream input, byte[] buffered);
/** /**
* Close any lingering proxy injections. * Close any lingering proxy injections.

Datei anzeigen

@ -18,6 +18,7 @@
package com.comphenix.protocol.injector.player; package com.comphenix.protocol.injector.player;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.InputStream;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -656,7 +657,7 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler {
} }
@Override @Override
public PacketEvent handlePacketRecieved(PacketContainer packet, DataInputStream input, byte[] buffered) { public PacketEvent handlePacketRecieved(PacketContainer packet, InputStream input, byte[] buffered) {
throw new UnsupportedOperationException("Proxy injection cannot handle recieved packets."); throw new UnsupportedOperationException("Proxy injection cannot handle recieved packets.");
} }

Datei anzeigen

@ -1,6 +1,7 @@
package com.comphenix.protocol.injector.spigot; package com.comphenix.protocol.injector.spigot;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Set; import java.util.Set;
@ -102,7 +103,7 @@ class DummyPlayerHandler implements PlayerInjectionHandler {
} }
@Override @Override
public PacketEvent handlePacketRecieved(PacketContainer packet, DataInputStream input, byte[] buffered) { public PacketEvent handlePacketRecieved(PacketContainer packet, InputStream input, byte[] buffered) {
// Associate this buffered data // Associate this buffered data
if (buffered != null) { if (buffered != null) {
injector.saveBuffered(packet.getHandle(), buffered); injector.saveBuffered(packet.getHandle(), buffered);