use of org.terasology.persistence.PlayerStore in project Terasology by MovingBlocks.
the class StorageManagerTest method testCharacterSurvivesStorage.
@Test
public void testCharacterSurvivesStorage() {
esm.waitForCompletionOfPreviousSaveAndStartSaving();
esm.finishSavingAndShutdown();
PlayerStore restored = esm.loadPlayerStore(PLAYER_ID);
restored.restoreEntities();
assertTrue(restored.hasCharacter());
assertEquals(character, restored.getCharacter());
}
use of org.terasology.persistence.PlayerStore in project Terasology by MovingBlocks.
the class StorageManagerTest method testPlayerRelevanceLocationSurvivesStorage.
@Test
public void testPlayerRelevanceLocationSurvivesStorage() {
Vector3f loc = new Vector3f(1, 2, 3);
character.addComponent(new LocationComponent(loc));
esm.waitForCompletionOfPreviousSaveAndStartSaving();
esm.finishSavingAndShutdown();
PlayerStore restored = esm.loadPlayerStore(PLAYER_ID);
assertEquals(loc, restored.getRelevanceLocation());
}
use of org.terasology.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, biomeManager, false);
newSM.loadGlobalStore();
PlayerStore restored = newSM.loadPlayerStore(PLAYER_ID);
restored.restoreEntities();
assertTrue(restored.getCharacter().getComponent(EntityRefComponent.class).entityRef.exists());
}
use of org.terasology.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));
}
use of org.terasology.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());
}
Aggregations