Skip to content

Commit 7cc760d

Browse files
committed
fix a bug where safe-mode may not be initialized
1 parent c43a679 commit 7cc760d

5 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/main/java/org/carlmontrobotics/lib199/safeMode/SafeCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public class SafeCommand extends FunctionalCommand {
1414

1515
private final Command command;
1616

17+
static {
18+
SafeMode.ensureRegistered();
19+
}
20+
1721
/**
1822
* Creates a new SafeCommand
1923
* @param command The command to run

src/main/java/org/carlmontrobotics/lib199/safeMode/SafeExecuteBlockingCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public class SafeExecuteBlockingCommand extends FunctionalCommand {
1515

1616
private final Command command;
1717

18+
static {
19+
SafeMode.ensureRegistered();
20+
}
21+
1822
public SafeExecuteBlockingCommand(Command command) {
1923
super(
2024
() -> command.initialize(),

src/main/java/org/carlmontrobotics/lib199/safeMode/SafeMode.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public class SafeMode {
4646
Lib199Subsystem.registerPeriodic(SafeMode::updateCallbacks);
4747
}
4848

49+
/**
50+
* Ensures that the static block of this class is called, setting up safe-mode
51+
*/
52+
public static void ensureRegistered() {}
53+
4954
/**
5055
* Enables safe-mode
5156
*/

src/main/java/org/carlmontrobotics/lib199/safeMode/UnsafeCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public class UnsafeCommand extends FunctionalCommand {
1414

1515
private final Command command;
1616

17+
static {
18+
SafeMode.ensureRegistered();
19+
}
20+
1721
public UnsafeCommand(Command command) {
1822
super(
1923
() -> { if(!SafeMode.isEnabled()) command.initialize(); },

src/main/java/org/carlmontrobotics/lib199/safeMode/UnsafeExecuteBlockingCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public class UnsafeExecuteBlockingCommand extends FunctionalCommand {
1515

1616
private final Command command;
1717

18+
static {
19+
SafeMode.ensureRegistered();
20+
}
21+
1822
public UnsafeExecuteBlockingCommand(Command command) {
1923
super(
2024
command::initialize,

0 commit comments

Comments
 (0)