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

@ -168,13 +168,42 @@ public class FuzzyReflection {
*/
public Method getMethod(AbstractFuzzyMatcher<MethodInfo> matcher) {
List<Method> result = getMethodList(matcher);
if (result.size() > 0)
if (result.size() > 0) {
return result.get(0);
else
} else {
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.
* <p>

Datei anzeigen

@ -56,7 +56,7 @@ public class WrappedBlockData extends AbstractWrapper {
.parameterExactArray(IBLOCK_DATA)
.returnTypeExact(int.class)
.build();
TO_LEGACY_DATA = Accessors.getMethodAccessor(fuzzy.getMethod(contract));
TO_LEGACY_DATA = Accessors.getMethodAccessor(fuzzy.getMethod(contract, "toLegacyData"));
fuzzy = FuzzyReflection.fromClass(MAGIC_NUMBERS);
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.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.BukkitConverters;
import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory;
import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
@ -475,6 +476,22 @@ public class PacketContainerTest {
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(
PacketType.Play.Client.CUSTOM_PAYLOAD, PacketType.Play.Server.CUSTOM_PAYLOAD,
PacketType.Play.Server.SET_COOLDOWN
@ -528,7 +545,7 @@ public class PacketContainerTest {
testEquality(firstMod.read(i), secondMod.read(i));
}
}
} catch (IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
if (!registered) {
// Let the test pass
System.err.println("The packet ID " + type + " is not registered.");

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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