/** * Retrieve a member by name, * @param name - name of member to retrieve. * @return The member, or NULL if not found. * @deprecated Don't use this */ @Deprecated public PacketType valueOf(String name) { for (PacketType member : members) { if (member.name().equals(name)) return member; } return null; }
@Override public String toString() { Class<?> clazz = getPacketClass(); if (clazz == null) return name() + "[" + protocol + ", " + sender + ", " + currentId + ", classNames: " + Arrays.toString(classNames) + " (unregistered)]"; else return name() + "[class=" + clazz.getSimpleName() + ", id=" + currentId + "]"; }
private void printStatistic(Writer destination, PacketType key, final StatisticsStream stream) throws IOException { destination.write(String.format(STATISTICS_ROW, key != null ? key.getProtocol() : "SUM", key != null ? key.name() : "-", key != null ? getPacketId(key) : "-", stream.getCount(), toMilli(stream.getMinimum()), toMilli(stream.getMaximum()), toMilli(stream.getMean()), toMilli(stream.getStandardDeviation()) )); }
for (PacketType packet : PacketType.values()) { if (packet.getProtocol() == protocol && packet.getSender() == pSender) { if (packet.name().equalsIgnoreCase(name)) { type = packet; break;
/** * Add a collection of packet types to the lookup. * @param types - the types to add. */ public PacketTypeLookup addPacketTypes(Iterable<? extends PacketType> types) { Preconditions.checkNotNull(types, "types cannot be NULL"); for (PacketType type : types) { int legacy = type.getLegacyId(); // Skip unknown legacy packets if (legacy != PacketType.UNKNOWN_PACKET) { if (type.isServer()) serverLookup.put(type.getLegacyId(), type); if (type.isClient()) clientLookup.put(type.getLegacyId(), type); legacyLookup.put(type.getLegacyId(), type); } // Skip unknown current packets if (type.getCurrentId() != PacketType.UNKNOWN_PACKET) { idLookup.getMap(type.getProtocol(), type.getSender()).put(type.getCurrentId(), type); classLookup.getMap(type.getProtocol(), type.getSender()).put(type.getClassNames()[0], type); } nameLookup.put(type.name(), type); } return this; }