@Override public int compareTo(PacketType other) { return ComparisonChain.start(). compare(protocol, other.getProtocol()). compare(sender, other.getSender()). compare(currentId, other.getCurrentId()). result(); }
if (type.getProtocol() == protocol && type.getSender() == side) { result.add(type); it.remove();
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()) )); }
String name = args[2]; for (PacketType packet : PacketType.values()) { if (packet.getProtocol() == protocol && packet.getSender() == pSender) { if (packet.name().equalsIgnoreCase(name)) { type = packet;
/** * Retrieve the correct object enum from a specific packet type. * @param type - the packet type. * @return The corresponding object enum. */ public static PacketTypeEnum getObjectEnum(final PacketType type) { switch (type.getProtocol()) { case HANDSHAKING: return type.isClient() ? Handshake.Client.getInstance() : Handshake.Server.getInstance(); case PLAY: return type.isClient() ? Play.Client.getInstance() : Play.Server.getInstance(); case STATUS: return type.isClient() ? Status.Client.getInstance() : Status.Server.getInstance(); case LOGIN: return type.isClient() ? Login.Client.getInstance() : Login.Server.getInstance(); case LEGACY: return type.isClient() ? Legacy.Client.getInstance() : Legacy.Server.getInstance(); default: throw new IllegalStateException("Unexpected protocol: " + type.getProtocol()); } }
/** * 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; }