Archiviert
13
0

Rename ObjectCloner to ObjectWriter.

It's more accurately thought off as a way of writing the content of
object A to object B, than a generic cloning method.
Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-12-25 15:46:33 +01:00
Ursprung 655fbf4799
Commit fdbd3d6495
4 geänderte Dateien mit 8 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -13,7 +13,7 @@ import com.comphenix.protocol.injector.BukkitUnwrapper;
import com.comphenix.protocol.reflect.FieldUtils; import com.comphenix.protocol.reflect.FieldUtils;
import com.comphenix.protocol.reflect.FuzzyReflection; import com.comphenix.protocol.reflect.FuzzyReflection;
import com.comphenix.protocol.reflect.MethodUtils; import com.comphenix.protocol.reflect.MethodUtils;
import com.comphenix.protocol.reflect.ObjectCloner; import com.comphenix.protocol.reflect.ObjectWriter;
import com.comphenix.protocol.reflect.compiler.BackgroundCompiler; import com.comphenix.protocol.reflect.compiler.BackgroundCompiler;
import com.comphenix.protocol.reflect.compiler.StructureCompiler; import com.comphenix.protocol.reflect.compiler.StructureCompiler;
import com.comphenix.protocol.reflect.instances.CollectionGenerator; import com.comphenix.protocol.reflect.instances.CollectionGenerator;
@ -48,7 +48,7 @@ class CleanupStaticMembers {
BukkitUnwrapper.class, DefaultInstances.class, CollectionGenerator.class, BukkitUnwrapper.class, DefaultInstances.class, CollectionGenerator.class,
PrimitiveGenerator.class, FuzzyReflection.class, MethodUtils.class, PrimitiveGenerator.class, FuzzyReflection.class, MethodUtils.class,
BackgroundCompiler.class, StructureCompiler.class, BackgroundCompiler.class, StructureCompiler.class,
ObjectCloner.class, Packets.Server.class, Packets.Client.class, ObjectWriter.class, Packets.Server.class, Packets.Client.class,
ChunkPosition.class, WrappedDataWatcher.class, WrappedWatchableObject.class ChunkPosition.class, WrappedDataWatcher.class, WrappedWatchableObject.class
}; };

Datei anzeigen

@ -29,7 +29,7 @@ import org.bukkit.Server;
import com.comphenix.protocol.error.ErrorReporter; import com.comphenix.protocol.error.ErrorReporter;
import com.comphenix.protocol.reflect.FieldUtils; import com.comphenix.protocol.reflect.FieldUtils;
import com.comphenix.protocol.reflect.FuzzyReflection; import com.comphenix.protocol.reflect.FuzzyReflection;
import com.comphenix.protocol.reflect.ObjectCloner; import com.comphenix.protocol.reflect.ObjectWriter;
import com.comphenix.protocol.reflect.VolatileField; import com.comphenix.protocol.reflect.VolatileField;
import com.comphenix.protocol.utility.MinecraftReflection; import com.comphenix.protocol.utility.MinecraftReflection;
@ -219,7 +219,7 @@ class InjectedServerConnection {
if (!(inserting instanceof Factory)) { if (!(inserting instanceof Factory)) {
// If so, copy the content of the old element to the new // If so, copy the content of the old element to the new
try { try {
ObjectCloner.copyTo(inserting, replacement, inserting.getClass()); ObjectWriter.copyTo(inserting, replacement, inserting.getClass());
} catch (Throwable e) { } catch (Throwable e) {
reporter.reportDetailed(InjectedServerConnection.this, "Cannot copy old " + inserting + reporter.reportDetailed(InjectedServerConnection.this, "Cannot copy old " + inserting +
" to new.", e, inserting, replacement); " to new.", e, inserting, replacement);

Datei anzeigen

@ -38,7 +38,7 @@ import com.comphenix.protocol.injector.ListenerInvoker;
import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks; import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks;
import com.comphenix.protocol.reflect.FieldUtils; import com.comphenix.protocol.reflect.FieldUtils;
import com.comphenix.protocol.reflect.FuzzyReflection; import com.comphenix.protocol.reflect.FuzzyReflection;
import com.comphenix.protocol.reflect.ObjectCloner; import com.comphenix.protocol.reflect.ObjectWriter;
import com.comphenix.protocol.reflect.VolatileField; import com.comphenix.protocol.reflect.VolatileField;
import com.comphenix.protocol.reflect.instances.DefaultInstances; import com.comphenix.protocol.reflect.instances.DefaultInstances;
import com.comphenix.protocol.reflect.instances.ExistingGenerator; import com.comphenix.protocol.reflect.instances.ExistingGenerator;
@ -248,7 +248,7 @@ public class NetworkServerInjector extends PlayerInjector {
@Override @Override
protected void cleanHook() { protected void cleanHook() {
if (serverHandlerRef != null && serverHandlerRef.isCurrentSet()) { if (serverHandlerRef != null && serverHandlerRef.isCurrentSet()) {
ObjectCloner.copyTo(serverHandlerRef.getValue(), serverHandlerRef.getOldValue(), serverHandler.getClass()); ObjectWriter.copyTo(serverHandlerRef.getValue(), serverHandlerRef.getOldValue(), serverHandler.getClass());
serverHandlerRef.revertValue(); serverHandlerRef.revertValue();
try { try {

Datei anzeigen

@ -20,13 +20,12 @@ package com.comphenix.protocol.reflect;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
/** /**
* Can copy an object field by field. * Can copy an object field by field.
* *
* @author Kristian * @author Kristian
*/ */
public class ObjectCloner { public class ObjectWriter {
// Cache structure modifiers // Cache structure modifiers
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@ -34,7 +33,7 @@ public class ObjectCloner {
new ConcurrentHashMap<Class, StructureModifier<Object>>(); new ConcurrentHashMap<Class, StructureModifier<Object>>();
/** /**
* Copy every field in object A to object B. * Copy every field in object A to object B. Each value is copied directly, and is not cloned.
* <p> * <p>
* The two objects must have the same number of fields of the same type. * The two objects must have the same number of fields of the same type.
* @param source - fields to copy. * @param source - fields to copy.