use of org.terasology.engine.persistence.typeHandling.gson.GsonPersistedDataWriter in project Terasology by MovingBlocks.
the class TypeSerializerTest method setup.
@Override
public void setup() {
ModuleContext.setContext(moduleManager.getEnvironment().get(new Name("unittest")));
typeHandlerLibrary = TypeHandlerLibraryImpl.forModuleEnvironment(moduleManager, typeRegistry);
Gson gson = new Gson();
gsonSerializer = new Serializer<>(typeHandlerLibrary, new GsonPersistedDataSerializer(), new GsonPersistedDataWriter(gson), new GsonPersistedDataReader(gson));
}
use of org.terasology.engine.persistence.typeHandling.gson.GsonPersistedDataWriter 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);
}
Aggregations