Search in sources :

Example 1 with PacketType

use of com.comphenix.protocol.PacketType in project NoCheatPlus by NoCheatPlus.

the class MovingFlying method initPacketTypes.

private static PacketType[] initPacketTypes() {
    final List<PacketType> types = new LinkedList<PacketType>(Arrays.asList(PacketType.Play.Client.FLYING, PacketType.Play.Client.LOOK, PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK));
    // Add confirm teleport.
    // PacketPlayInTeleportAccept
    PacketType confirmType = ProtocolLibComponent.findPacketTypeByName(Protocol.PLAY, Sender.CLIENT, "PacketPlayInTeleportAccept");
    if (confirmType != null) {
        StaticLog.logInfo("Confirm teleport packet available (via name): " + confirmType);
        types.add(confirmType);
    }
    return types.toArray(new PacketType[types.size()]);
}
Also used : PacketType(com.comphenix.protocol.PacketType) LinkedList(java.util.LinkedList)

Example 2 with PacketType

use of com.comphenix.protocol.PacketType in project TriggerReactor by wysohn.

the class ProtocolLibSupport method createPacket.

/**
 * Create empty packet.
 * @param packetType type of packet as String. Should match with any
 * <a href="https://aadnk.github.io/ProtocolLib/Javadoc/com/comphenix/protocol/package-frame.html">PacketType</a>.
 * For example, ENTITY is under PacketType.Play.Server.
 * @return
 */
public PacketContainer createPacket(String packetType) {
    ValidationUtil.notNull(packetType);
    Collection<PacketType> types = PacketType.fromName(packetType);
    if (types.isEmpty())
        throw new RuntimeException("Cannot find packet type " + packetType);
    PacketType type = types.iterator().next();
    return protocolManager.createPacket(type);
}
Also used : PacketType(com.comphenix.protocol.PacketType)

Aggregations

PacketType (com.comphenix.protocol.PacketType)2 LinkedList (java.util.LinkedList)1