fix(D-01): clamp component config values to valid ranges (RISK-003)

- LockableComponent: lock_resistance clamped to >= 0
- ResistanceComponent: base resistance clamped to >= 0
- GaggingComponent: comprehension clamped to [0.0, 1.0], range to >= 0.0

Prevents nonsensical negative values from malformed JSON configs.
This commit is contained in:
NotEvil
2026-04-14 02:28:42 +02:00
parent bb589d44f8
commit 3a81bb6e12
3 changed files with 4 additions and 0 deletions

View File

@@ -28,6 +28,8 @@ public class GaggingComponent implements IItemComponent {
range = config.get("range").getAsDouble(); range = config.get("range").getAsDouble();
} }
} }
comprehension = Math.max(0.0, Math.min(1.0, comprehension));
range = Math.max(0.0, range);
return new GaggingComponent(comprehension, range); return new GaggingComponent(comprehension, range);
} }

View File

@@ -29,6 +29,7 @@ public class LockableComponent implements IItemComponent {
if (config != null && config.has("lock_resistance")) { if (config != null && config.has("lock_resistance")) {
resistance = config.get("lock_resistance").getAsInt(); resistance = config.get("lock_resistance").getAsInt();
} }
resistance = Math.max(0, resistance);
return new LockableComponent(resistance); return new LockableComponent(resistance);
} }

View File

@@ -20,6 +20,7 @@ public class ResistanceComponent implements IItemComponent {
if (config != null && config.has("base")) { if (config != null && config.has("base")) {
base = config.get("base").getAsInt(); base = config.get("base").getAsInt();
} }
base = Math.max(0, base);
return new ResistanceComponent(base); return new ResistanceComponent(base);
} }