Archiviert
13
0

Add support for 1.3.2

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-09-13 11:34:47 +02:00
Ursprung 4307cb9104
Commit f372b247f9
5 geänderte Dateien mit 24 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -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 {
/**

Datei anzeigen

@ -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()).

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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);