fix ghost LaborRecord entries for non-working prisoners on escape
This commit is contained in:
@@ -113,6 +113,14 @@ public class PrisonerManager extends SavedData {
|
|||||||
return laborRecords.computeIfAbsent(playerId, id -> new LaborRecord());
|
return laborRecords.computeIfAbsent(playerId, id -> new LaborRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get labor record only if one exists. Does not create ghost entries.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public LaborRecord getLaborRecordIfExists(UUID playerId) {
|
||||||
|
return laborRecords.get(playerId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the labor record for a player.
|
* Set the labor record for a player.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -94,8 +94,9 @@ public class EscapeMonitorService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Step 1: Save guard ID BEFORE state transition (manager.escape() removes the LaborRecord)
|
// Step 1: Save guard ID BEFORE state transition (manager.escape() removes the LaborRecord)
|
||||||
LaborRecord laborBeforeEscape = manager.getLaborRecord(playerId);
|
// Use direct map lookup to avoid creating ghost LaborRecord entries for non-WORKING prisoners
|
||||||
UUID guardId = laborBeforeEscape.getGuardId();
|
LaborRecord laborBeforeEscape = manager.getLaborRecordIfExists(playerId);
|
||||||
|
UUID guardId = laborBeforeEscape != null ? laborBeforeEscape.getGuardId() : null;
|
||||||
|
|
||||||
// Step 2: Transition prisoner state to FREE
|
// Step 2: Transition prisoner state to FREE
|
||||||
boolean stateChanged = manager.escape(playerId, currentTime, reason);
|
boolean stateChanged = manager.escape(playerId, currentTime, reason);
|
||||||
|
|||||||
Reference in New Issue
Block a user