refactor/god-class-decomposition #17
@@ -113,6 +113,14 @@ public class PrisonerManager extends SavedData {
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -94,8 +94,9 @@ public class EscapeMonitorService {
|
||||
);
|
||||
|
||||
// Step 1: Save guard ID BEFORE state transition (manager.escape() removes the LaborRecord)
|
||||
LaborRecord laborBeforeEscape = manager.getLaborRecord(playerId);
|
||||
UUID guardId = laborBeforeEscape.getGuardId();
|
||||
// Use direct map lookup to avoid creating ghost LaborRecord entries for non-WORKING prisoners
|
||||
LaborRecord laborBeforeEscape = manager.getLaborRecordIfExists(playerId);
|
||||
UUID guardId = laborBeforeEscape != null ? laborBeforeEscape.getGuardId() : null;
|
||||
|
||||
// Step 2: Transition prisoner state to FREE
|
||||
boolean stateChanged = manager.escape(playerId, currentTime, reason);
|
||||
|
||||
Reference in New Issue
Block a user