Skip to content

Commit

Permalink
Fix deserialization error after removing a mod that adds a job (#10275)
Browse files Browse the repository at this point in the history
Fix citizen deserialization error after removing a job (by removing an addon mod).
  • Loading branch information
Raycoms committed Oct 23, 2024
1 parent a0e2a29 commit 82bc368
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;

public final class JobDataManager implements IJobDataManager
{
@Nullable
@Override
public IJob<?> createFrom(final ICitizenData citizen, @NotNull final CompoundTag compound, @NotNull final HolderLookup.Provider provider)
{
final ResourceLocation jobType =
compound.contains(NbtTagConstants.TAG_JOB_TYPE) ? ResourceLocation.parse(compound.getString(NbtTagConstants.TAG_JOB_TYPE)) : ModJobs.PLACEHOLDER_ID;
final IJob<?> job = IJobRegistry.getInstance().get(jobType).produceJob(citizen);
compound.contains(NbtTagConstants.TAG_JOB_TYPE) ? new ResourceLocation(compound.getString(NbtTagConstants.TAG_JOB_TYPE)) : ModJobs.PLACEHOLDER_ID;
final IJob<?> job = Optional.ofNullable(IJobRegistry.getInstance().getValue(jobType)).map(r -> r.produceJob(citizen)).orElse(null);

if (job != null)
{
Expand Down

0 comments on commit 82bc368

Please # to comment.