/*
 * Copyright 2018 ImpactDevelopment
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package clientapi.util;

/**
 * List of official release version protocols
 * after the netty rewrite in 1.7
 *
 * @author Brady
 * @since 3/6/2017
 */
public enum Protocol {

    ProtocolVersion4(4, "1.7.2", "1.7.4", "1.7.5"),
    ProtocolVersion5(5, "1.7.6", "1.7.7", "1.7.8", "1.7.9", "1.7.10"),
    ProtocolVersion47(47, "1.8", "1.8.1", "1.8.2", "1.8.3", "1.8.4", "1.8.5", "1.8.6", "1.8.7", "1.8.8", "1.8.9"),
    ProtocolVersion107(107, "1.9"),
    ProtocolVersion108(108, "1.9.1"),
    ProtocolVersion109(109, "1.9.2"),
    ProtocolVersion110(110, "1.9.3", "1.9.4"),
    ProtocolVersion210(210, "1.10", "1.10.1", "1.10.2"),
    ProtocolVersion315(315, "1.11"),
    ProtocolVersion316(316, "1.11.1", "1.11.2"),
    ProtocolVersion335(335, "1.12"),
    ProtocolVersion338(338, "1.12.1"),
    ProtocolVersion340(340, "1.12.2");

    /**
     * The Protocol ID
     */
    private final int id;

    /**
     * Array of supported game versions for this protocol version
     */
    private final String[] versions;

    Protocol(int id, String... versions) {
        this.id = id;
        this.versions = versions;
    }

    /**
     * @return The Protocol ID
     */
    public final int getId() {
        return this.id;
    }

    /**
     * @return Array of supported game versions for this protocol version
     */
    public final String[] getVersions() {
        return this.versions;
    }
}

/*
 * Copyright 2018 ImpactDevelopment
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package clientapi.util;

import java.util.*;

/**
 * List of official release version protocols
 * after the netty rewrite in 1.7
 *
 * @author Brady
 * @since 3/6/2017
 */
public enum Protocol {

    ProtocolVersion4(4, "1.7.2", "1.7.4", "1.7.5"),
    ProtocolVersion5(5, "1.7.6", "1.7.7", "1.7.8", "1.7.9", "1.7.10"),
    ProtocolVersion47(47, "1.8", "1.8.1", "1.8.2", "1.8.3", "1.8.4", "1.8.5", "1.8.6", "1.8.7", "1.8.8", "1.8.9"),
    ProtocolVersion107(107, "1.9"),
    ProtocolVersion108(108, "1.9.1"),
    ProtocolVersion109(109, "1.9.2"),
    ProtocolVersion110(110, "1.9.3", "1.9.4"),
    ProtocolVersion210(210, "1.10", "1.10.1", "1.10.2"),
    ProtocolVersion315(315, "1.11"),
    ProtocolVersion316(316, "1.11.1", "1.11.2"),
    ProtocolVersion335(335, "1.12"),
    ProtocolVersion338(338, "1.12.1"),
    ProtocolVersion340(340, "1.12.2"),
    ProtocolVersion393(393, "1.13"),
    ProtocolVersion401(401, "1.13.1");

    /**
     * A list of all of the protocols in this enum
     */
    private static final List<Protocol> PROTOCOL_VALUES = Arrays.asList(Protocol.values());

    /**
     * A map of game versions to their respective {@link Protocol}
     */
    private static final Map<String, Protocol> VERSION_TO_PROTOCOL;

    static {
        Map<String, Protocol> versionToProtocolMap = new HashMap<>();
        PROTOCOL_VALUES.forEach(protocol -> {
            for (String version : protocol.getVersions()) {
                versionToProtocolMap.put(version, protocol);
            }
        });
        VERSION_TO_PROTOCOL = Collections.unmodifiableMap(versionToProtocolMap);
    }

    /**
     * The Protocol ID
     */
    private final int id;

    /**
     * Array of supported game versions for this protocol version
     */
    private final String[] versions;

    Protocol(int id, String... versions) {
        this.id = id;
        this.versions = versions;
    }

    /**
     * @return The Protocol ID
     */
    public final int getId() {
        return this.id;
    }

    /**
     * @return Array of supported game versions for this protocol version
     */
    public final String[] getVersions() {
        return this.versions;
    }

    /**
     * Finds the {@link Protocol} associated with a game version.
     *
     * @param version The game version
     * @return The associated {@link Protocol}
     */
    public static Protocol byVersion(String version) {
        return VERSION_TO_PROTOCOL.get(version);
    }
}

Add 1.13 and 1.13.1 protocol versions and byVersion method