use of org.terasology.engine.persistence.PlayerStore in project Terasology by MovingBlocks.
the class StorageManagerTest method testReferenceRemainsValidOverStorageRestoral.
@Test
public void testReferenceRemainsValidOverStorageRestoral() throws Exception {
EntityRef someEntity = entityManager.create();
character.addComponent(new EntityRefComponent(someEntity));
esm.waitForCompletionOfPreviousSaveAndStartSaving();
esm.finishSavingAndShutdown();
EntitySystemSetupUtil.addReflectionBasedLibraries(context);
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
EngineEntityManager newEntityManager = context.get(EngineEntityManager.class);
StorageManager newSM = new ReadWriteStorageManager(savePath, moduleEnvironment, newEntityManager, blockManager, extraDataManager, false, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus);
newSM.loadGlobalStore();
PlayerStore restored = newSM.loadPlayerStore(PLAYER_ID);
restored.restoreEntities();
assertTrue(restored.getCharacter().getComponent(EntityRefComponent.class).entityRef.exists());
}
use of org.terasology.engine.persistence.PlayerStore in project Terasology by MovingBlocks.
the class StorageManagerTest method testStoreAndRestoreOfPlayerWithoutCharacter.
@Test
public void testStoreAndRestoreOfPlayerWithoutCharacter() {
// remove character from player:
character.destroy();
esm.waitForCompletionOfPreviousSaveAndStartSaving();
esm.finishSavingAndShutdown();
PlayerStore restoredStore = esm.loadPlayerStore(PLAYER_ID);
assertNotNull(restoredStore);
assertFalse(restoredStore.hasCharacter());
assertEquals(new Vector3f(), restoredStore.getRelevanceLocation());
}
use of org.terasology.engine.persistence.PlayerStore in project Terasology by MovingBlocks.
the class NetworkSystemImpl method connectClient.
private void connectClient(Client client) {
PlayerStore entityStore = storageManager.loadPlayerStore(client.getId());
client.getEntity().send(new ConnectedEvent(entityStore));
}
Aggregations