Restore disabled tests, fix block data
Dieser Commit ist enthalten in:
Ursprung
f561057311
Commit
19c57b0e5e
@ -168,13 +168,42 @@ 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.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -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,
|
||||||
|
@ -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
|
||||||
@ -528,7 +545,7 @@ public class PacketContainerTest {
|
|||||||
testEquality(firstMod.read(i), secondMod.read(i));
|
testEquality(firstMod.read(i), secondMod.read(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
if (!registered) {
|
if (!registered) {
|
||||||
// Let the test pass
|
// Let the test pass
|
||||||
System.err.println("The packet ID " + type + " is not registered.");
|
System.err.println("The packet ID " + type + " is not registered.");
|
||||||
|
@ -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() {
|
||||||
|
@ -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();
|
||||||
|
@ -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();
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren