mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-28 05:35:28 +01:00
Properly handle WrappedGameProfile during packet cloning.
This commit is contained in:
parent
90548f1092
commit
d70e9d28d4
@ -258,6 +258,6 @@ public class AggregateCloner implements Cloner {
|
||||
}
|
||||
|
||||
// Damn - failure
|
||||
throw new IllegalArgumentException("Cannot clone " + source + ": No cloner is sutable.");
|
||||
throw new IllegalArgumentException("Cannot clone " + source + ": No cloner is suitable.");
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import java.util.UUID;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.google.common.primitives.Primitives;
|
||||
|
||||
/**
|
||||
@ -79,6 +80,12 @@ public class ImmutableDetector implements Cloner {
|
||||
if (clazz.equals(type))
|
||||
return true;
|
||||
|
||||
// Check for known immutable classes in 1.7.2
|
||||
if (MinecraftReflection.isUsingNetty()) {
|
||||
if (type.equals(MinecraftReflection.getGameProfileClass())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Probably not
|
||||
return false;
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.comphenix.protocol.wrappers;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.comphenix.protocol.reflect.cloning.AggregateCloner;
|
||||
|
||||
public class CloningTest {
|
||||
@BeforeClass
|
||||
public static void initializeBukkit() throws IllegalAccessException {
|
||||
BukkitInitialization.initializePackage();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cloneGameProfile() {
|
||||
WrappedGameProfile profile = new WrappedGameProfile("id", "name");
|
||||
WrappedGameProfile copy = WrappedGameProfile.fromHandle(
|
||||
AggregateCloner.DEFAULT.clone(profile.getHandle())
|
||||
);
|
||||
|
||||
assertEquals(profile, copy);
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.comphenix.protocol.BukkitInitialization;
|
||||
import com.comphenix.protocol.Packets;
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.WrappedAttributeModifier.Operation;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -48,7 +48,7 @@ public class WrappedAttributeTest {
|
||||
attribute = WrappedAttribute.newBuilder().
|
||||
attributeKey("generic.attackDamage").
|
||||
baseValue(2).
|
||||
packet(new PacketContainer(Packets.Server.UPDATE_ATTRIBUTES)).
|
||||
packet(new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES)).
|
||||
modifiers(Lists.newArrayList(constantModifier, doubleModifier)).
|
||||
build();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user