Fixs: DimFinder nullPtr error on saving PlayerData before player loads in

This commit is contained in:
TomTheFurry
2022-06-13 00:14:24 +08:00
parent 4f2076b48e
commit 3ca0757358
@@ -107,11 +107,17 @@ public class PlayerData
/** Writes everything from this object to the file given. */
public void toTomlFile(CommentedFileConfig toml)
{
// player block pos
toml.add(PLAYER_BLOCK_POS_X_PATH, playerBlockPos.getX());
toml.add(PLAYER_BLOCK_POS_Y_PATH, playerBlockPos.getY());
toml.add(PLAYER_BLOCK_POS_Z_PATH, playerBlockPos.getZ());
if (playerBlockPos == null)
{
toml.remove(PLAYER_BLOCK_POS_X_PATH);
toml.remove(PLAYER_BLOCK_POS_Y_PATH);
toml.remove(PLAYER_BLOCK_POS_Z_PATH);
} else {
// player block pos
toml.add(PLAYER_BLOCK_POS_X_PATH, playerBlockPos.getX());
toml.add(PLAYER_BLOCK_POS_Y_PATH, playerBlockPos.getY());
toml.add(PLAYER_BLOCK_POS_Z_PATH, playerBlockPos.getZ());
}
toml.save();
}