Class ConfigSync

java.lang.Object
net.neoforged.neoforge.network.ConfigSync

@Internal public final class ConfigSync extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Map<net.minecraft.network.Connection,Map<String,byte[]>>
    Connection -> Config file name -> byte[] of the config serialized to TOML.
    private static final Object
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    receiveSyncedConfig(byte[] contents, String fileName)
     
    static void
    Registers a listener for ModConfigEvent.Reloading for all mod busses, that will sync changes to server configs to connected clients.
    static void
    syncAllConfigs(net.minecraft.network.protocol.configuration.ServerConfigurationPacketListener listener)
     
    static void
    syncPendingConfigs(net.minecraft.server.MinecraftServer server)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • lock

      private static final Object lock
    • configsToSync

      private static final Map<net.minecraft.network.Connection,Map<String,byte[]>> configsToSync
      Connection -> Config file name -> byte[] of the config serialized to TOML.

      Pending config updates get sent to players in the PLAY phase only, but start being tracked as soon as the SyncConfig configuration task runs. This ensures that all updates during the configuration phase will eventually arrive to the clients.

      Connections get removed when GC'ed thanks to the WeakHashMap.

  • Constructor Details

    • ConfigSync

      private ConfigSync()
  • Method Details

    • syncAllConfigs

      public static void syncAllConfigs(net.minecraft.network.protocol.configuration.ServerConfigurationPacketListener listener)
    • registerEventListeners

      public static void registerEventListeners()
      Registers a listener for ModConfigEvent.Reloading for all mod busses, that will sync changes to server configs to connected clients.
    • syncPendingConfigs

      public static void syncPendingConfigs(net.minecraft.server.MinecraftServer server)
    • receiveSyncedConfig

      public static void receiveSyncedConfig(byte[] contents, String fileName)