Class BukkitPowerExecutor
- All Implemented Interfaces:
PowerActionHandler.PowerExecutor
The action is scheduled 20L ticks after the result frame was handed to the
socket, so the panel always receives its answer first. Scheduling goes through
PluginInitiationUtils.scheduleUnlessDisabling(String, java.util.function.Supplier), the
single hand-off check every scheduler call reachable from the socket thread uses: while the
framework is disabling the work is dropped with one FINE line instead of throwing.
Restart is supported only when the file the server would run — the part of
settings.restart-script in spigot.yml before its first space, or
"./start.sh" when the key is absent — exists as a regular file, resolved
against the server's working directory when that path is relative. Spigot's own restart stops
the server when that file is missing; this check keeps a requested restart from silently
becoming a stop.
This is the only Bukkit-facing part of the power path; the handler stays unit-testable without a live server. Package-private framework plumbing; not for module use.
- Since:
- 6.3.1
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringThe value Spigot uses forsettings.restart-scriptwhen the key is absent.(package private) static final longThe delay between the result frame and the stop or restart, matching the contract's "1 s".private final Runnableprivate final Runnableprivate final File -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static BukkitPowerExecutorcreate()Builds the production executor: the framework scheduler, the process working directory, the livespigot.ymlvalue, and the platform's own stop and restart calls.booleanWhether the file the platform would actually run exists as a regular file.private voidvoidSchedules the restart on the main thread, 20L ticks from now.voidSchedules the stop on the main thread, 20L ticks from now.
-
Field Details
-
DELAY_TICKS
static final long DELAY_TICKSThe delay between the result frame and the stop or restart, matching the contract's "1 s".- See Also:
-
DEFAULT_RESTART_SCRIPT
The value Spigot uses forsettings.restart-scriptwhen the key is absent.- See Also:
-
workingDirectory
-
restartScriptPath
-
stopAction
-
restartAction
-
-
Constructor Details
-
BukkitPowerExecutor
BukkitPowerExecutor(File workingDirectory, Supplier<String> restartScriptPath, Runnable stopAction, Runnable restartAction) Creates the executor over explicit collaborators.- Parameters:
workingDirectory- the server's working directory, against which a relativerestart-scriptpath is resolvedrestartScriptPath- suppliessettings.restart-scriptas configured, or nullstopAction- what the scheduled task does on a stop; production passesBukkit::shutdownrestartAction- what the scheduled task does on a restart; production passesBukkit.spigot()::restart
-
-
Method Details
-
create
Builds the production executor: the framework scheduler, the process working directory, the livespigot.ymlvalue, and the platform's own stop and restart calls.- Returns:
- the executor the wiring uses
-
restartSupported
public boolean restartSupported()Whether the file the platform would actually run exists as a regular file.This mirrors Spigot's own rule exactly, because any laxer answer turns a requested restart into a stop: only the part of the value before the first space names the script (the rest is passed to it as arguments), the value is never trimmed, and "./start.sh" applies only when the key is absent — never to an explicitly empty value, which names no file at all. A directory of that name is not a restart script.
- Specified by:
restartSupportedin interfacePowerActionHandler.PowerExecutor- Returns:
- true when a restart would restart rather than stop
-
scheduleStop
public void scheduleStop()Schedules the stop on the main thread, 20L ticks from now.- Specified by:
scheduleStopin interfacePowerActionHandler.PowerExecutor
-
scheduleRestart
public void scheduleRestart()Schedules the restart on the main thread, 20L ticks from now.- Specified by:
scheduleRestartin interfacePowerActionHandler.PowerExecutor
-
schedule
-