Class NetworkRegistry


  • public class NetworkRegistry
    extends java.lang.Object
    The network registry. Tracks channels on behalf of mods.
    • Field Detail

      • LOGGER

        private static final org.apache.logging.log4j.Logger LOGGER
      • NETREGISTRY

        private static final org.apache.logging.log4j.Marker NETREGISTRY
      • ABSENT

        public static java.lang.String ABSENT
        Special value for clientAcceptedVersions and serverAcceptedVersions predicates indicating the other side lacks this channel.
      • ACCEPTVANILLA

        public static java.lang.String ACCEPTVANILLA
      • lock

        private static boolean lock
    • Constructor Detail

      • NetworkRegistry

        public NetworkRegistry()
    • Method Detail

      • acceptMissingOr

        public static java.util.function.Predicate<java.lang.String> acceptMissingOr​(java.lang.String protocolVersion)
        Makes a version predicate that accepts connections to vanilla or without the channel.
        Parameters:
        protocolVersion - The protocol version, which will be matched exactly.
        Returns:
        A new predicate with the new conditions.
      • acceptMissingOr

        public static java.util.function.Predicate<java.lang.String> acceptMissingOr​(java.util.function.Predicate<java.lang.String> versionCheck)
        Makes a version predicate that accepts connections to vanilla or without the channel.
        Parameters:
        versionCheck - The main version predicate, which should check the version number of the protocol.
        Returns:
        A new predicate with the new conditions.
      • getServerNonVanillaNetworkMods

        public static java.util.List<java.lang.String> getServerNonVanillaNetworkMods()
      • getClientNonVanillaNetworkMods

        public static java.util.List<java.lang.String> getClientNonVanillaNetworkMods()
      • acceptsVanillaClientConnections

        public static boolean acceptsVanillaClientConnections()
      • canConnectToVanillaServer

        public static boolean canConnectToVanillaServer()
      • createInstance

        private static NetworkInstance createInstance​(ResourceLocation name,
                                                      java.util.function.Supplier<java.lang.String> networkProtocolVersion,
                                                      java.util.function.Predicate<java.lang.String> clientAcceptedVersions,
                                                      java.util.function.Predicate<java.lang.String> serverAcceptedVersions)
        Creates the internal NetworkInstance that tracks the channel data.
        Parameters:
        name - registry name
        networkProtocolVersion - The protocol version string
        clientAcceptedVersions - The client accepted predicate
        serverAcceptedVersions - The server accepted predicate
        Returns:
        The NetworkInstance
        Throws:
        java.lang.IllegalArgumentException - if the name already exists
      • listRejectedVanillaMods

        static java.util.List<java.lang.String> listRejectedVanillaMods​(java.util.function.BiFunction<NetworkInstance,​java.lang.String,​java.lang.Boolean> testFunction)
      • validateClientChannels

        static boolean validateClientChannels​(java.util.Map<ResourceLocation,​java.lang.String> channels)
        Validate the channels from the server on the client. Tests the client predicates against the server supplied network protocol version.
        Parameters:
        channels - An @Map of name->version pairs for testing
        Returns:
        true if all channels accept themselves
      • validateServerChannels

        static boolean validateServerChannels​(java.util.Map<ResourceLocation,​java.lang.String> channels)
        Validate the channels from the client on the server. Tests the server predicates against the client supplied network protocol version.
        Parameters:
        channels - An @Map of name->version pairs for testing
        Returns:
        true if all channels accept themselves
      • validateChannels

        private static boolean validateChannels​(java.util.Map<ResourceLocation,​java.lang.String> incoming,
                                                java.lang.String originName,
                                                java.util.function.BiFunction<NetworkInstance,​java.lang.String,​java.lang.Boolean> testFunction)
        Tests if the map matches with the supplied predicate tester
        Parameters:
        incoming - An @Map of name->version pairs for testing
        originName - A label for use in logging (where the version pairs came from)
        testFunction - The test function to use for testing
        Returns:
        true if all channels accept themselves
      • checkListPingCompatibilityForClient

        public static boolean checkListPingCompatibilityForClient​(java.util.Map<ResourceLocation,​org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.Boolean>> incoming)
      • isLocked

        public boolean isLocked()
      • lock

        public static void lock()