From fdbd3d64955ba364f87bfc51d6dd3602ccd73743 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Tue, 25 Dec 2012 15:46:33 +0100 Subject: [PATCH] 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. --- .../java/com/comphenix/protocol/CleanupStaticMembers.java | 4 ++-- .../protocol/injector/player/InjectedServerConnection.java | 4 ++-- .../protocol/injector/player/NetworkServerInjector.java | 4 ++-- .../reflect/{ObjectCloner.java => ObjectWriter.java} | 5 ++--- 4 files changed, 8 insertions(+), 9 deletions(-) rename ProtocolLib/src/main/java/com/comphenix/protocol/reflect/{ObjectCloner.java => ObjectWriter.java} (95%) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/CleanupStaticMembers.java b/ProtocolLib/src/main/java/com/comphenix/protocol/CleanupStaticMembers.java index f04aebdc..69d82099 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/CleanupStaticMembers.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/CleanupStaticMembers.java @@ -13,7 +13,7 @@ import com.comphenix.protocol.injector.BukkitUnwrapper; import com.comphenix.protocol.reflect.FieldUtils; import com.comphenix.protocol.reflect.FuzzyReflection; 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.StructureCompiler; import com.comphenix.protocol.reflect.instances.CollectionGenerator; @@ -48,7 +48,7 @@ class CleanupStaticMembers { BukkitUnwrapper.class, DefaultInstances.class, CollectionGenerator.class, PrimitiveGenerator.class, FuzzyReflection.class, MethodUtils.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 }; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedServerConnection.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedServerConnection.java index 1886cac9..307e8b24 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedServerConnection.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedServerConnection.java @@ -29,7 +29,7 @@ import org.bukkit.Server; import com.comphenix.protocol.error.ErrorReporter; import com.comphenix.protocol.reflect.FieldUtils; 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.utility.MinecraftReflection; @@ -219,7 +219,7 @@ class InjectedServerConnection { if (!(inserting instanceof Factory)) { // If so, copy the content of the old element to the new try { - ObjectCloner.copyTo(inserting, replacement, inserting.getClass()); + ObjectWriter.copyTo(inserting, replacement, inserting.getClass()); } catch (Throwable e) { reporter.reportDetailed(InjectedServerConnection.this, "Cannot copy old " + inserting + " to new.", e, inserting, replacement); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkServerInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkServerInjector.java index eacc83de..f13b261c 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkServerInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkServerInjector.java @@ -38,7 +38,7 @@ import com.comphenix.protocol.injector.ListenerInvoker; import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks; import com.comphenix.protocol.reflect.FieldUtils; 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.instances.DefaultInstances; import com.comphenix.protocol.reflect.instances.ExistingGenerator; @@ -248,7 +248,7 @@ public class NetworkServerInjector extends PlayerInjector { @Override protected void cleanHook() { if (serverHandlerRef != null && serverHandlerRef.isCurrentSet()) { - ObjectCloner.copyTo(serverHandlerRef.getValue(), serverHandlerRef.getOldValue(), serverHandler.getClass()); + ObjectWriter.copyTo(serverHandlerRef.getValue(), serverHandlerRef.getOldValue(), serverHandler.getClass()); serverHandlerRef.revertValue(); try { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectCloner.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectWriter.java similarity index 95% rename from ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectCloner.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectWriter.java index 5475e60d..8e7e1d1f 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectCloner.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectWriter.java @@ -20,13 +20,12 @@ package com.comphenix.protocol.reflect; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; - /** * Can copy an object field by field. * * @author Kristian */ -public class ObjectCloner { +public class ObjectWriter { // Cache structure modifiers @SuppressWarnings("rawtypes") @@ -34,7 +33,7 @@ public class ObjectCloner { new ConcurrentHashMap>(); /** - * 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. *

* The two objects must have the same number of fields of the same type. * @param source - fields to copy.