[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:
Gold856
2025-07-02 16:46:59 -04:00
committed by GitHub
parent a3ce880334
commit 26771e38fb
42 changed files with 77 additions and 66 deletions

View File

@@ -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()) {

View File

@@ -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

View File

@@ -28,7 +28,7 @@ public class ScheduleCommand extends Command {
@Override
public void initialize() {
for (Command command : m_toSchedule) {
command.schedule();
CommandScheduler.getInstance().schedule(command);
}
}

View File

@@ -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);
}
}
});