Search in sources :

Example 1 with AutoConfigTypeHandlerFactory

use of org.terasology.engine.config.flexible.AutoConfigTypeHandlerFactory in project Terasology by MovingBlocks.

the class ConfigurationSubsystem method initialise.

@Override
public void initialise(GameEngine engine, Context rootContext) {
    // TODO: Put here because of TypeHandlerLibrary dependency,
    // might need to move to preInitialise or elsewhere
    TypeHandlerLibrary typeHandlerLibrary = rootContext.get(TypeHandlerLibrary.class);
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    Serializer<GsonPersistedData> serializer = new Serializer<>(typeHandlerLibrary, new GsonPersistedDataSerializer(), new GsonPersistedDataWriter(gson), new GsonPersistedDataReader(gson));
    autoConfigManager = new AutoConfigManager(serializer);
    typeHandlerLibrary.addTypeHandlerFactory(new AutoConfigTypeHandlerFactory(typeHandlerLibrary));
    rootContext.put(AutoConfigManager.class, autoConfigManager);
    autoConfigManager.loadConfigsIn(rootContext);
}
Also used : GsonPersistedDataSerializer(org.terasology.engine.persistence.typeHandling.gson.GsonPersistedDataSerializer) AutoConfigTypeHandlerFactory(org.terasology.engine.config.flexible.AutoConfigTypeHandlerFactory) GsonPersistedDataWriter(org.terasology.engine.persistence.typeHandling.gson.GsonPersistedDataWriter) GsonBuilder(com.google.gson.GsonBuilder) GsonPersistedData(org.terasology.engine.persistence.typeHandling.gson.GsonPersistedData) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) GsonPersistedDataReader(org.terasology.engine.persistence.typeHandling.gson.GsonPersistedDataReader) Gson(com.google.gson.Gson) AutoConfigManager(org.terasology.engine.config.flexible.AutoConfigManager) GsonPersistedDataSerializer(org.terasology.engine.persistence.typeHandling.gson.GsonPersistedDataSerializer) Serializer(org.terasology.persistence.serializers.Serializer)

Aggregations

Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 AutoConfigManager (org.terasology.engine.config.flexible.AutoConfigManager)1 AutoConfigTypeHandlerFactory (org.terasology.engine.config.flexible.AutoConfigTypeHandlerFactory)1 GsonPersistedData (org.terasology.engine.persistence.typeHandling.gson.GsonPersistedData)1 GsonPersistedDataReader (org.terasology.engine.persistence.typeHandling.gson.GsonPersistedDataReader)1 GsonPersistedDataSerializer (org.terasology.engine.persistence.typeHandling.gson.GsonPersistedDataSerializer)1 GsonPersistedDataWriter (org.terasology.engine.persistence.typeHandling.gson.GsonPersistedDataWriter)1 Serializer (org.terasology.persistence.serializers.Serializer)1 TypeHandlerLibrary (org.terasology.persistence.typeHandling.TypeHandlerLibrary)1