Use PacketType in PacketContainerTest.
Dieser Commit ist enthalten in:
Ursprung
8bd177daf5
Commit
ea7b550bda
@ -78,12 +78,12 @@ public class SimpleCraftBukkitITCase {
|
|||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
initializePlugin(FAKE_PLUGIN);
|
initializePlugin(FAKE_PLUGIN);
|
||||||
ProtocolLibrary.getConfiguration().setDebug(true);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}).get(TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
}).get(TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
// Plugins are now ready
|
// Plugins are now ready
|
||||||
|
ProtocolLibrary.getConfiguration().setDebug(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||||||
|
|
||||||
import com.comphenix.protocol.BukkitInitialization;
|
import com.comphenix.protocol.BukkitInitialization;
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.Packets;
|
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
import com.comphenix.protocol.PacketType.Sender;
|
||||||
import com.comphenix.protocol.injector.PacketConstructor;
|
import com.comphenix.protocol.injector.PacketConstructor;
|
||||||
import com.comphenix.protocol.reflect.EquivalentConverter;
|
import com.comphenix.protocol.reflect.EquivalentConverter;
|
||||||
@ -102,7 +101,7 @@ public class PacketContainerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetByteArrays() {
|
public void testGetByteArrays() {
|
||||||
// Contains a byte array we will test
|
// Contains a byte array we will test
|
||||||
PacketContainer customPayload = new PacketContainer(Packets.Server.CUSTOM_PAYLOAD);
|
PacketContainer customPayload = new PacketContainer(PacketType.Play.Server.CUSTOM_PAYLOAD);
|
||||||
StructureModifier<byte[]> bytes = customPayload.getByteArrays();
|
StructureModifier<byte[]> bytes = customPayload.getByteArrays();
|
||||||
byte[] testArray = new byte[] { 1, 2, 3 };
|
byte[] testArray = new byte[] { 1, 2, 3 };
|
||||||
|
|
||||||
@ -120,37 +119,37 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetBytes() {
|
public void testGetBytes() {
|
||||||
PacketContainer spawnMob = new PacketContainer(Packets.Server.MOB_SPAWN);
|
PacketContainer spawnMob = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
|
||||||
testPrimitive(spawnMob.getBytes(), 0, (byte)0, (byte)1);
|
testPrimitive(spawnMob.getBytes(), 0, (byte)0, (byte)1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetShorts() {
|
public void testGetShorts() {
|
||||||
PacketContainer itemData = new PacketContainer(Packets.Server.TRANSACTION);
|
PacketContainer itemData = new PacketContainer(PacketType.Play.Server.TRANSACTION);
|
||||||
testPrimitive(itemData.getShorts(), 0, (short)0, (short)1);
|
testPrimitive(itemData.getShorts(), 0, (short)0, (short)1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetIntegers() {
|
public void testGetIntegers() {
|
||||||
PacketContainer updateSign = new PacketContainer(Packets.Server.UPDATE_SIGN);
|
PacketContainer updateSign = new PacketContainer(PacketType.Play.Server.UPDATE_SIGN);
|
||||||
testPrimitive(updateSign.getIntegers(), 0, (int)0, (int)1);
|
testPrimitive(updateSign.getIntegers(), 0, (int)0, (int)1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetLongs() {
|
public void testGetLongs() {
|
||||||
PacketContainer updateTime = new PacketContainer(Packets.Server.UPDATE_TIME);
|
PacketContainer updateTime = new PacketContainer(PacketType.Play.Server.UPDATE_TIME);
|
||||||
testPrimitive(updateTime.getLongs(), 0, (long)0, (long)1);
|
testPrimitive(updateTime.getLongs(), 0, (long)0, (long)1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetFloat() {
|
public void testGetFloat() {
|
||||||
PacketContainer explosion = new PacketContainer(Packets.Server.EXPLOSION);
|
PacketContainer explosion = new PacketContainer(PacketType.Play.Server.EXPLOSION);
|
||||||
testPrimitive(explosion.getFloat(), 0, (float)0, (float)0.8);
|
testPrimitive(explosion.getFloat(), 0, (float)0, (float)0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDoubles() {
|
public void testGetDoubles() {
|
||||||
PacketContainer explosion = new PacketContainer(Packets.Server.EXPLOSION);
|
PacketContainer explosion = new PacketContainer(PacketType.Play.Server.EXPLOSION);
|
||||||
testPrimitive(explosion.getDoubles(), 0, (double)0, (double)0.8);
|
testPrimitive(explosion.getDoubles(), 0, (double)0, (double)0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,14 +161,14 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStringArrays() {
|
public void testGetStringArrays() {
|
||||||
PacketContainer explosion = new PacketContainer(Packets.Server.UPDATE_SIGN);
|
PacketContainer explosion = new PacketContainer(PacketType.Play.Server.UPDATE_SIGN);
|
||||||
testObjectArray(explosion.getStringArrays(), 0, new String[0], new String[] { "hello", "world" });
|
testObjectArray(explosion.getStringArrays(), 0, new String[0], new String[] { "hello", "world" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetIntegerArrays() {
|
public void testGetIntegerArrays() {
|
||||||
// Contains a byte array we will test
|
// Contains a byte array we will test
|
||||||
PacketContainer mapChunkBulk = new PacketContainer(Packets.Server.MAP_CHUNK_BULK);
|
PacketContainer mapChunkBulk = new PacketContainer(PacketType.Play.Server.MAP_CHUNK_BULK);
|
||||||
StructureModifier<int[]> integers = mapChunkBulk.getIntegerArrays();
|
StructureModifier<int[]> integers = mapChunkBulk.getIntegerArrays();
|
||||||
int[] testArray = new int[] { 1, 2, 3 };
|
int[] testArray = new int[] { 1, 2, 3 };
|
||||||
|
|
||||||
@ -184,7 +183,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetItemModifier() {
|
public void testGetItemModifier() {
|
||||||
PacketContainer windowClick = new PacketContainer(Packets.Client.WINDOW_CLICK);
|
PacketContainer windowClick = new PacketContainer(PacketType.Play.Client.WINDOW_CLICK);
|
||||||
|
|
||||||
StructureModifier<ItemStack> items = windowClick.getItemModifier();
|
StructureModifier<ItemStack> items = windowClick.getItemModifier();
|
||||||
ItemStack goldAxe = new ItemStack(Material.GOLD_AXE);
|
ItemStack goldAxe = new ItemStack(Material.GOLD_AXE);
|
||||||
@ -199,7 +198,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetItemArrayModifier() {
|
public void testGetItemArrayModifier() {
|
||||||
PacketContainer windowItems = new PacketContainer(Packets.Server.WINDOW_ITEMS);
|
PacketContainer windowItems = new PacketContainer(PacketType.Play.Server.WINDOW_ITEMS);
|
||||||
StructureModifier<ItemStack[]> itemAccess = windowItems.getItemArrayModifier();
|
StructureModifier<ItemStack[]> itemAccess = windowItems.getItemArrayModifier();
|
||||||
|
|
||||||
ItemStack[] itemArray = new ItemStack[] {
|
ItemStack[] itemArray = new ItemStack[] {
|
||||||
@ -239,7 +238,7 @@ public class PacketContainerTest {
|
|||||||
if (MinecraftReflection.isUsingNetty())
|
if (MinecraftReflection.isUsingNetty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PacketContainer loginPacket = new PacketContainer(Packets.Server.LOGIN);
|
PacketContainer loginPacket = new PacketContainer(PacketType.Play.Server.LOGIN);
|
||||||
StructureModifier<WorldType> worldAccess = loginPacket.getWorldTypeModifier();
|
StructureModifier<WorldType> worldAccess = loginPacket.getWorldTypeModifier();
|
||||||
|
|
||||||
WorldType testValue = WorldType.LARGE_BIOMES;
|
WorldType testValue = WorldType.LARGE_BIOMES;
|
||||||
@ -253,7 +252,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetNbtModifier() {
|
public void testGetNbtModifier() {
|
||||||
PacketContainer updateTileEntity = new PacketContainer(132);
|
PacketContainer updateTileEntity = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA);
|
||||||
|
|
||||||
NbtCompound compound = NbtFactory.ofCompound("test");
|
NbtCompound compound = NbtFactory.ofCompound("test");
|
||||||
compound.put("test", "name");
|
compound.put("test", "name");
|
||||||
@ -269,7 +268,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDataWatcherModifier() {
|
public void testGetDataWatcherModifier() {
|
||||||
PacketContainer mobSpawnPacket = new PacketContainer(Packets.Server.MOB_SPAWN);
|
PacketContainer mobSpawnPacket = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
|
||||||
StructureModifier<WrappedDataWatcher> watcherAccessor = mobSpawnPacket.getDataWatcherModifier();
|
StructureModifier<WrappedDataWatcher> watcherAccessor = mobSpawnPacket.getDataWatcherModifier();
|
||||||
|
|
||||||
WrappedDataWatcher dataWatcher = new WrappedDataWatcher();
|
WrappedDataWatcher dataWatcher = new WrappedDataWatcher();
|
||||||
@ -295,7 +294,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetPositionCollectionModifier() {
|
public void testGetPositionCollectionModifier() {
|
||||||
PacketContainer explosionPacket = new PacketContainer(Packets.Server.EXPLOSION);
|
PacketContainer explosionPacket = new PacketContainer(PacketType.Play.Server.EXPLOSION);
|
||||||
StructureModifier<List<ChunkPosition>> positionAccessor = explosionPacket.getPositionCollectionModifier();
|
StructureModifier<List<ChunkPosition>> positionAccessor = explosionPacket.getPositionCollectionModifier();
|
||||||
|
|
||||||
assertNull(positionAccessor.read(0));
|
assertNull(positionAccessor.read(0));
|
||||||
@ -313,7 +312,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetWatchableCollectionModifier() {
|
public void testGetWatchableCollectionModifier() {
|
||||||
PacketContainer entityMetadata = new PacketContainer(Packets.Server.ENTITY_METADATA);
|
PacketContainer entityMetadata = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
StructureModifier<List<WrappedWatchableObject>> watchableAccessor =
|
StructureModifier<List<WrappedWatchableObject>> watchableAccessor =
|
||||||
entityMetadata.getWatchableCollectionModifier();
|
entityMetadata.getWatchableCollectionModifier();
|
||||||
|
|
||||||
@ -356,13 +355,13 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
PacketContainer copy = (PacketContainer) SerializationUtils.clone(chat);
|
PacketContainer copy = (PacketContainer) SerializationUtils.clone(chat);
|
||||||
|
|
||||||
assertEquals(3, copy.getID());
|
assertEquals(PacketType.Play.Client.CHAT, copy.getType());
|
||||||
assertEquals("Test", copy.getStrings().read(0));
|
assertEquals("Test", copy.getStrings().read(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAttributeList() {
|
public void testAttributeList() {
|
||||||
PacketContainer attribute = new PacketContainer(Packets.Server.UPDATE_ATTRIBUTES);
|
PacketContainer attribute = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
||||||
attribute.getIntegers().write(0, 123); // Entity ID
|
attribute.getIntegers().write(0, 123); // Entity ID
|
||||||
|
|
||||||
// Initialize some test data
|
// Initialize some test data
|
||||||
@ -395,7 +394,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
// The constructor we want to call
|
// The constructor we want to call
|
||||||
PacketConstructor creator = PacketConstructor.DEFAULT.withPacket(
|
PacketConstructor creator = PacketConstructor.DEFAULT.withPacket(
|
||||||
Packets.Server.MOB_EFFECT, new Class<?>[] { int.class, PotionEffect.class });
|
PacketType.Play.Server.ENTITY_EFFECT, new Class<?>[] { int.class, PotionEffect.class });
|
||||||
PacketContainer packet = creator.createPacket(1, effect);
|
PacketContainer packet = creator.createPacket(1, effect);
|
||||||
|
|
||||||
assertEquals(1, (int) packet.getIntegers().read(0));
|
assertEquals(1, (int) packet.getIntegers().read(0));
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren