mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[commands] Deprecate Command.schedule() (#7072)
It's only syntactic sugar over the CommandScheduler's schedule method and creates a footgun because it’s too obvious to try to use in incorrect places. Co-authored-by: Starlight220 <53231611+Starlight220@users.noreply.github.com>
This commit is contained in:
@@ -533,7 +533,12 @@ public abstract class Command implements Sendable {
|
||||
});
|
||||
}
|
||||
|
||||
/** Schedules this command. */
|
||||
/**
|
||||
* Schedules this command.
|
||||
*
|
||||
* @deprecated Use CommandScheduler.getInstance().schedule(Command...) instead
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public void schedule() {
|
||||
CommandScheduler.getInstance().schedule(this);
|
||||
}
|
||||
@@ -610,7 +615,7 @@ public abstract class Command implements Sendable {
|
||||
value -> {
|
||||
if (value) {
|
||||
if (!isScheduled()) {
|
||||
schedule();
|
||||
CommandScheduler.getInstance().schedule(this);
|
||||
}
|
||||
} else {
|
||||
if (isScheduled()) {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ProxyCommand extends Command {
|
||||
@Override
|
||||
public void initialize() {
|
||||
m_command = m_supplier.get();
|
||||
m_command.schedule();
|
||||
CommandScheduler.getInstance().schedule(m_command);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ScheduleCommand extends Command {
|
||||
@Override
|
||||
public void initialize() {
|
||||
for (Command command : m_toSchedule) {
|
||||
command.schedule();
|
||||
CommandScheduler.getInstance().schedule(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class Trigger implements BooleanSupplier {
|
||||
addBinding(
|
||||
(previous, current) -> {
|
||||
if (previous != current) {
|
||||
command.schedule();
|
||||
CommandScheduler.getInstance().schedule(command);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
@@ -110,7 +110,7 @@ public class Trigger implements BooleanSupplier {
|
||||
addBinding(
|
||||
(previous, current) -> {
|
||||
if (!previous && current) {
|
||||
command.schedule();
|
||||
CommandScheduler.getInstance().schedule(command);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
@@ -127,7 +127,7 @@ public class Trigger implements BooleanSupplier {
|
||||
addBinding(
|
||||
(previous, current) -> {
|
||||
if (previous && !current) {
|
||||
command.schedule();
|
||||
CommandScheduler.getInstance().schedule(command);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
@@ -148,7 +148,7 @@ public class Trigger implements BooleanSupplier {
|
||||
addBinding(
|
||||
(previous, current) -> {
|
||||
if (!previous && current) {
|
||||
command.schedule();
|
||||
CommandScheduler.getInstance().schedule(command);
|
||||
} else if (previous && !current) {
|
||||
command.cancel();
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class Trigger implements BooleanSupplier {
|
||||
addBinding(
|
||||
(previous, current) -> {
|
||||
if (previous && !current) {
|
||||
command.schedule();
|
||||
CommandScheduler.getInstance().schedule(command);
|
||||
} else if (!previous && current) {
|
||||
command.cancel();
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class Trigger implements BooleanSupplier {
|
||||
if (command.isScheduled()) {
|
||||
command.cancel();
|
||||
} else {
|
||||
command.schedule();
|
||||
CommandScheduler.getInstance().schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -214,7 +214,7 @@ public class Trigger implements BooleanSupplier {
|
||||
if (command.isScheduled()) {
|
||||
command.cancel();
|
||||
} else {
|
||||
command.schedule();
|
||||
CommandScheduler.getInstance().schedule(command);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user