Archiviert
13
0

Restore disabled tests, fix block data

Dieser Commit ist enthalten in:
Dan Mulloy 2016-03-20 13:35:59 -04:00
Ursprung f561057311
Commit 19c57b0e5e
6 geänderte Dateien mit 64 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -169,11 +169,40 @@ public class FuzzyReflection {
public Method getMethod(AbstractFuzzyMatcher<MethodInfo> matcher) { public Method getMethod(AbstractFuzzyMatcher<MethodInfo> matcher) {
List<Method> result = getMethodList(matcher); List<Method> result = getMethodList(matcher);
if (result.size() > 0) if (result.size() > 0) {
return result.get(0); return result.get(0);
else } else {
throw new IllegalArgumentException("Unable to find a method that matches " + matcher); throw new IllegalArgumentException("Unable to find a method that matches " + matcher);
} }
}
/**
* Retrieve a method that matches. If there are multiple methods that match, the first one with the preferred
* name is selected.
* <p>
* ForceAccess must be TRUE in order for this method to access private, protected and package level method.
* @param matcher - the matcher to use.
* @param preferred - the preferred name.
* @return The first method that satisfies the given matcher.
* @throws IllegalArgumentException If the method cannot be found.
*/
public Method getMethod(AbstractFuzzyMatcher<MethodInfo> matcher, String preferred) {
List<Method> result = getMethodList(matcher);
if (result.size() > 1) {
for (Method method : result) {
if (method.getName().equals(preferred)) {
return method;
}
}
}
if (result.size() > 0) {
return result.get(0);
} else {
throw new IllegalArgumentException("Unable to find a method that matches " + matcher);
}
}
/** /**
* Retrieve a list of every method that matches the given matcher. * Retrieve a list of every method that matches the given matcher.

Datei anzeigen

@ -56,7 +56,7 @@ public class WrappedBlockData extends AbstractWrapper {
.parameterExactArray(IBLOCK_DATA) .parameterExactArray(IBLOCK_DATA)
.returnTypeExact(int.class) .returnTypeExact(int.class)
.build(); .build();
TO_LEGACY_DATA = Accessors.getMethodAccessor(fuzzy.getMethod(contract)); TO_LEGACY_DATA = Accessors.getMethodAccessor(fuzzy.getMethod(contract, "toLegacyData"));
fuzzy = FuzzyReflection.fromClass(MAGIC_NUMBERS); fuzzy = FuzzyReflection.fromClass(MAGIC_NUMBERS);
GET_NMS_BLOCK = Accessors.getMethodAccessor(fuzzy.getMethodByParameters("getBlock", BLOCK, GET_NMS_BLOCK = Accessors.getMethodAccessor(fuzzy.getMethodByParameters("getBlock", BLOCK,

Datei anzeigen

@ -62,6 +62,7 @@ import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.utility.Util; import com.comphenix.protocol.utility.Util;
import com.comphenix.protocol.wrappers.BlockPosition; import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.BukkitConverters; import com.comphenix.protocol.wrappers.BukkitConverters;
import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory;
import com.comphenix.protocol.wrappers.WrappedBlockData; import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.comphenix.protocol.wrappers.WrappedDataWatcher;
@ -475,6 +476,22 @@ public class PacketContainerTest {
assertEquals(e, (byte) packet.getBytes().read(2)); assertEquals(e, (byte) packet.getBytes().read(2));
} }
@Test
public void testMobEffectList() {
PacketContainer container = new PacketContainer(PacketType.Play.Server.REMOVE_ENTITY_EFFECT);
container.getEffectTypes().write(0, PotionEffectType.GLOWING);
assertEquals(container.getEffectTypes().read(0), PotionEffectType.GLOWING);
}
@Test
public void testSoundCategory() {
PacketContainer container = new PacketContainer(PacketType.Play.Server.NAMED_SOUND_EFFECT);
container.getSoundCategories().write(0, SoundCategory.PLAYERS);
assertEquals(container.getSoundCategories().read(0), SoundCategory.PLAYERS);
}
private static final List<PacketType> BLACKLISTED = Util.asList( private static final List<PacketType> BLACKLISTED = Util.asList(
PacketType.Play.Client.CUSTOM_PAYLOAD, PacketType.Play.Server.CUSTOM_PAYLOAD, PacketType.Play.Client.CUSTOM_PAYLOAD, PacketType.Play.Server.CUSTOM_PAYLOAD,
PacketType.Play.Server.SET_COOLDOWN PacketType.Play.Server.SET_COOLDOWN

Datei anzeigen

@ -6,6 +6,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import net.minecraft.server.v1_9_R1.ChatComponentText; import net.minecraft.server.v1_9_R1.ChatComponentText;
import net.minecraft.server.v1_9_R1.ChunkCoordIntPair; import net.minecraft.server.v1_9_R1.ChunkCoordIntPair;
import net.minecraft.server.v1_9_R1.DataWatcher;
import net.minecraft.server.v1_9_R1.IBlockData; import net.minecraft.server.v1_9_R1.IBlockData;
import net.minecraft.server.v1_9_R1.IChatBaseComponent; import net.minecraft.server.v1_9_R1.IChatBaseComponent;
import net.minecraft.server.v1_9_R1.IChatBaseComponent.ChatSerializer; import net.minecraft.server.v1_9_R1.IChatBaseComponent.ChatSerializer;
@ -124,11 +125,10 @@ public class MinecraftReflectionTest {
assertEquals(NBTCompressedStreamTools.class, MinecraftReflection.getNbtCompressedStreamToolsClass()); assertEquals(NBTCompressedStreamTools.class, MinecraftReflection.getNbtCompressedStreamToolsClass());
} }
// TODO Fix this @Test
/*@Test public void testDataWatcherItem() {
public void testWatchableObject() { assertEquals(DataWatcher.Item.class, MinecraftReflection.getDataWatcherItemClass());
assertEquals(WatchableObject.class, MinecraftReflection.getWatchableObjectClass()); }
}*/
@Test @Test
public void testItemStacks() { public void testItemStacks() {

Datei anzeigen

@ -42,7 +42,7 @@ public class StreamSerializerTest {
@Test @Test
public void testStrings() throws IOException { public void testStrings() throws IOException {
StreamSerializer serializer = new StreamSerializer(); StreamSerializer serializer = new StreamSerializer();
String initial = "Hello - this is a <EFBFBD><EFBFBD><EFBFBD> test."; String initial = "Hello - this is a test.";
// Buffer // Buffer
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();

Datei anzeigen

@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.junit.BeforeClass;
import org.junit.Test;
import com.comphenix.protocol.BukkitInitialization; import com.comphenix.protocol.BukkitInitialization;
import com.comphenix.protocol.utility.MinecraftReflection; import com.comphenix.protocol.utility.MinecraftReflection;
@ -30,12 +32,12 @@ import com.comphenix.protocol.utility.MinecraftReflection;
public class WrappedBlockDataTest { public class WrappedBlockDataTest {
//@BeforeClass @BeforeClass
public static void initializeBukkit() { public static void initializeBukkit() throws IllegalAccessException {
BukkitInitialization.initializePackage(); BukkitInitialization.initializeItemMeta();
} }
//@Test @Test
public void test() { public void test() {
Material type = Material.WOOL; Material type = Material.WOOL;
int data = DyeColor.BLUE.getWoolData(); int data = DyeColor.BLUE.getWoolData();