Class ProtocolUtil

java.lang.Object
com.viaversion.viaversion.util.ProtocolUtil

public final class ProtocolUtil extends Object
  • Constructor Details

    • ProtocolUtil

      public ProtocolUtil()
  • Method Details

    • packetTypeMap

      @SafeVarargs public static <P extends PacketType> Map<State,PacketTypeMap<P>> packetTypeMap(@Nullable Class<P> parent, Class<? extends P>... packetTypeClasses)
      Returns a map of packet types by state.
      Type Parameters:
      P - packet type class
      Parameters:
      parent - parent packet type class as given by the Protocol generics
      packetTypeClasses - packet type enum classes belonging to the parent type
      Returns:
      map of packet types by state
    • toNiceHex

      public static String toNiceHex(int id)
      Returns a hex string of a packet id.
      Parameters:
      id - packet id
      Returns:
      packet id as a nice hex string
    • toNiceName

      public static String toNiceName(Class<? extends Protocol> protocol)
      Returns a readable name of a protocol. For example, "Protocol1_12_2To1_13" becomes "1.12.2->1.13".
      Parameters:
      protocol - protocol class
      Returns:
      readable name of the protocol