Skip to content

Commit 66d766c

Browse files
authored
Merge pull request #639 from Multiverse/fix/pdimport-error-message
Improve playerdata import error message output
2 parents 5de2315 + 35a3e5e commit 66d766c

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/main/java/org/mvplugins/multiverse/inventories/commands/PlayerDataImportCommand.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ void onCommand(MVCommandIssuer issuer, World world) {
6363
continue;
6464
}
6565
UUID playerUUID = UUID.fromString(Files.getNameWithoutExtension(playerDataFile.getName()));
66-
Try<ProfileData> profileData = playerDataExtractor.extract(playerDataFile.toPath());
67-
playerDataFutures.add(profileDataSource
68-
.getGlobalProfile(GlobalProfileKey.of(playerUUID))
69-
.thenCompose(profileDataSource::updateGlobalProfile)
70-
.thenCompose(ignore -> profileDataSource.getPlayerProfile(
71-
ProfileKey.of(ContainerType.WORLD, world.getName(), ProfileTypes.getDefault(), playerUUID)))
72-
.thenCompose(playerProfile -> {
73-
playerProfile.update(profileData.get());
74-
return profileDataSource.updatePlayerProfile(playerProfile);
75-
}));
66+
playerDataExtractor.extract(playerDataFile.toPath())
67+
.onSuccess(profileData -> playerDataFutures.add(profileDataSource
68+
.getGlobalProfile(GlobalProfileKey.of(playerUUID))
69+
.thenCompose(profileDataSource::updateGlobalProfile)
70+
.thenCompose(ignore -> profileDataSource.getPlayerProfile(
71+
ProfileKey.of(ContainerType.WORLD, world.getName(), ProfileTypes.getDefault(), playerUUID)))
72+
.thenCompose(playerProfile -> {
73+
playerProfile.update(profileData);
74+
return profileDataSource.updatePlayerProfile(playerProfile);
75+
})));
7676
}
7777
CompletableFuture.allOf(playerDataFutures.toArray(new CompletableFuture[0]))
7878
.thenRun(() -> issuer.sendMessage("Successfully imported all player data from " + world.getName() + "."));

src/main/java/org/mvplugins/multiverse/inventories/profile/nbt/PlayerDataExtractor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ public Try<ProfileData> extract(Path path) {
8383
profileData.set(Sharables.TOTAL_EXPERIENCE, playerData.getInt("XpTotal"));
8484

8585
return profileData;
86-
}).onFailure(Throwable::printStackTrace);
86+
}).onFailure(ex -> {
87+
Logging.warning("Failed to extract player data from %s: %s", path, ex.getMessage());
88+
ex.printStackTrace();
89+
});
8790
}
8891

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

0 commit comments

Comments
 (0)