|
22 | 22 | import com.comphenix.protocol.PacketType.Sender;
|
23 | 23 | import com.comphenix.protocol.events.PacketContainer;
|
24 | 24 | import com.comphenix.protocol.injector.packet.PacketRegistry;
|
| 25 | +import com.comphenix.protocol.utility.MinecraftReflection; |
25 | 26 | import com.comphenix.protocol.utility.MinecraftReflectionTestUtil;
|
26 | 27 | import java.lang.reflect.Field;
|
27 | 28 | import java.util.ArrayList;
|
|
31 | 32 | import java.util.Map.Entry;
|
32 | 33 | import java.util.Set;
|
33 | 34 | import java.util.TreeMap;
|
| 35 | + |
| 36 | +import com.comphenix.protocol.wrappers.BukkitConverters; |
| 37 | +import com.comphenix.protocol.wrappers.WrappedChatComponent; |
34 | 38 | import net.minecraft.network.EnumProtocol;
|
35 | 39 | import net.minecraft.network.protocol.EnumProtocolDirection;
|
36 | 40 | import net.minecraft.network.protocol.login.PacketLoginInStart;
|
@@ -357,4 +361,17 @@ public void testPacketCreation() {
|
357 | 361 | }
|
358 | 362 | assertFalse(fail, "Packet type(s) failed to instantiate");
|
359 | 363 | }
|
| 364 | + |
| 365 | + @Test |
| 366 | + public void testPacketBundleWriting() { |
| 367 | + PacketContainer bundlePacket = new PacketContainer(PacketType.Play.Server.BUNDLE); |
| 368 | + assertEquals(MinecraftReflection.getPackedBundlePacketClass().orElseThrow(() -> new IllegalStateException("Packet Bundle class is not present")), bundlePacket.getHandle().getClass()); |
| 369 | + List<PacketContainer> bundle = new ArrayList<>(); |
| 370 | + |
| 371 | + PacketContainer chatMessage = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT); |
| 372 | + chatMessage.getStrings().write(0, WrappedChatComponent.fromText("Test").getJson()); |
| 373 | + chatMessage.getBooleans().write(0, false); |
| 374 | + bundle.add(chatMessage); |
| 375 | + bundlePacket.getPacketBundles().write(0, bundle); |
| 376 | + } |
360 | 377 | }
|
0 commit comments