コード例 #1
0
  /**
   * Retrieve the packet ID of a given packet.
   *
   * @param packet - the type of packet to check.
   * @return The ID of the given packet.
   * @throws IllegalArgumentException If this is not a valid packet.
   */
  public static int getPacketID(Class<?> packet) {
    if (packet == null) throw new IllegalArgumentException("Packet type class cannot be NULL.");
    if (!MinecraftReflection.getPacketClass().isAssignableFrom(packet))
      throw new IllegalArgumentException("Type must be a packet.");

    // The registry contains both the overridden and original packets
    return getPacketToID().get(packet);
  }
コード例 #2
0
 /**
  * Retrieve the cached fuzzy reflection instance allowing access to the packet registry.
  *
  * @return Reflected packet registry.
  */
 private static FuzzyReflection getPacketRegistry() {
   if (packetRegistry == null)
     packetRegistry = FuzzyReflection.fromClass(MinecraftReflection.getPacketClass(), true);
   return packetRegistry;
 }