Add support for 1.3.2
Dieser Commit ist enthalten in:
Ursprung
4307cb9104
Commit
f372b247f9
@ -9,6 +9,10 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Represents an API for accessing the Minecraft protocol.
|
||||
* @author Kristian
|
||||
*/
|
||||
public interface ProtocolManager {
|
||||
|
||||
/**
|
||||
|
@ -94,12 +94,14 @@ class PlayerInjector {
|
||||
Object serverHandler = FieldUtils.readField(serverHandlerField, notchEntity);
|
||||
|
||||
// Next, get the network manager
|
||||
if (networkManagerField == null) {
|
||||
if (networkManagerField == null)
|
||||
networkManagerField = FuzzyReflection.fromObject(serverHandler).getFieldByType(".*NetworkManager");
|
||||
networkModifier = new StructureModifier<Object>(networkManagerField.getType(), null);
|
||||
}
|
||||
networkManager = FieldUtils.readField(networkManagerField, serverHandler);
|
||||
|
||||
// Create the network manager modifier from the actual object type
|
||||
if (networkManager != null && networkModifier == null)
|
||||
networkModifier = new StructureModifier<Object>(networkManager.getClass(), null, false);
|
||||
|
||||
// And the queue method
|
||||
if (queueMethod == null)
|
||||
queueMethod = FuzzyReflection.fromClass(networkManagerField.getType()).
|
||||
@ -207,7 +209,7 @@ class PlayerInjector {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
StructureModifier<List> list = networkModifier.withType(List.class);
|
||||
|
||||
|
||||
// Subclass both send queues
|
||||
for (Field field : list.getFields()) {
|
||||
VolatileField overwriter = new VolatileField(field, networkManager, true);
|
||||
|
@ -37,7 +37,9 @@ public class StructureCache {
|
||||
|
||||
// Use the vanilla class definition
|
||||
if (result == null) {
|
||||
result = new StructureModifier<Object>(MinecraftRegistry.getPacketClassFromID(id, true), Packet.class);
|
||||
result = new StructureModifier<Object>(
|
||||
MinecraftRegistry.getPacketClassFromID(id, true), Packet.class, true);
|
||||
|
||||
structureModifiers.put(id, result);
|
||||
}
|
||||
|
||||
|
@ -35,12 +35,17 @@ public class StructureModifier<TField> {
|
||||
// Cache of previous types
|
||||
private Map<Class, StructureModifier> subtypeCache;
|
||||
|
||||
public StructureModifier(Class targetType, Class superclassExclude) {
|
||||
/**
|
||||
* Creates a structure modifier.
|
||||
* @param targetType - the structure to modify.
|
||||
* @param superclassExclude - a superclass to exclude.
|
||||
* @param requireDefault - whether or not we will be using writeDefaults().
|
||||
*/
|
||||
public StructureModifier(Class targetType, Class superclassExclude, boolean requireDefault) {
|
||||
List<Field> fields = getFields(targetType, superclassExclude);
|
||||
Set<Field> defaults = requireDefault ? generateDefaultFields(fields) : new HashSet<Field>();
|
||||
|
||||
initialize(targetType, Object.class,
|
||||
fields, generateDefaultFields(fields), null,
|
||||
new HashMap<Class, StructureModifier>());
|
||||
initialize(targetType, Object.class, fields, defaults, null, new HashMap<Class, StructureModifier>());
|
||||
}
|
||||
|
||||
private StructureModifier(StructureModifier<TField> other, Object target) {
|
||||
|
@ -15,7 +15,8 @@ public class StructureModifierTest {
|
||||
public void test() throws IllegalAccessException {
|
||||
|
||||
Packet103SetSlot move = new Packet103SetSlot();
|
||||
StructureModifier<Object> modifier = new StructureModifier<Object>(Packet103SetSlot.class, Packet.class);
|
||||
StructureModifier<Object> modifier = new StructureModifier<Object>(
|
||||
Packet103SetSlot.class, Packet.class, true);
|
||||
|
||||
move.a = 1;
|
||||
int value = (Integer) modifier.withTarget(move).withType(int.class).read(0);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren