Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ void onCommand(MVCommandIssuer issuer, World world) {
continue;
}
UUID playerUUID = UUID.fromString(Files.getNameWithoutExtension(playerDataFile.getName()));
Try<ProfileData> profileData = playerDataExtractor.extract(playerDataFile.toPath());
playerDataFutures.add(profileDataSource
.getGlobalProfile(GlobalProfileKey.of(playerUUID))
.thenCompose(profileDataSource::updateGlobalProfile)
.thenCompose(ignore -> profileDataSource.getPlayerProfile(
ProfileKey.of(ContainerType.WORLD, world.getName(), ProfileTypes.getDefault(), playerUUID)))
.thenCompose(playerProfile -> {
playerProfile.update(profileData.get());
return profileDataSource.updatePlayerProfile(playerProfile);
}));
playerDataExtractor.extract(playerDataFile.toPath())
.onSuccess(profileData -> playerDataFutures.add(profileDataSource
.getGlobalProfile(GlobalProfileKey.of(playerUUID))
.thenCompose(profileDataSource::updateGlobalProfile)
.thenCompose(ignore -> profileDataSource.getPlayerProfile(
ProfileKey.of(ContainerType.WORLD, world.getName(), ProfileTypes.getDefault(), playerUUID)))
.thenCompose(playerProfile -> {
playerProfile.update(profileData);
return profileDataSource.updatePlayerProfile(playerProfile);
})));
}
CompletableFuture.allOf(playerDataFutures.toArray(new CompletableFuture[0]))
.thenRun(() -> issuer.sendMessage("Successfully imported all player data from " + world.getName() + "."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ public Try<ProfileData> extract(Path path) {
profileData.set(Sharables.TOTAL_EXPERIENCE, playerData.getInt("XpTotal"));

return profileData;
}).onFailure(Throwable::printStackTrace);
}).onFailure(ex -> {
Logging.warning("Failed to extract player data from %s: %s", path, ex.getMessage());
ex.printStackTrace();
});
}

private ItemStack[] extractItems(@Nullable ListTag<CompoundTag> inventoryList, int dataVersion, int inventorySize) throws IOException {
Expand Down
Loading