Command Warmups #6332
Conversation
…ertsmrek/Essentials into feature/command-warmups-1320
…ved sequential lookup performance
There was a problem hiding this comment.
Pull request overview
This PR introduces a command warmup system for EssentialsX, allowing server administrators to configure delays before commands execute. The feature mirrors the existing teleport warmup functionality but applies to any command, with cancellation triggers for player movement and damage.
Key Changes:
- Command warmup configuration with pattern matching support (wildcards and regex)
- Asynchronous timer implementation (
AsyncTimedCommand) to handle warmup delays and cancellation - Persistence system for warmups across server restarts
- Permission-based bypass and movement allowance controls
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
CommandWarmupTest.java |
Unit tests for CommandWarmup entity validation and pattern matching |
messages_en.properties |
Added three new message keys for warmup notifications (start, complete, cancelled) |
config.yml |
Configuration documentation and examples for command warmup settings |
CommandWarmupSerializer.java |
Serialization logic for persisting warmup data |
UserConfigHolder.java |
Added warmup list storage to user timestamps |
CommandWarmup.java |
Entity class defining warmup pattern and expiry value |
EssentialsConfiguration.java |
Registered CommandWarmupSerializer for configuration handling |
UserData.java |
CRUD operations for managing user warmup data |
Settings.java |
Configuration parsing and warmup entry lookup with optimized List-based storage |
IUser.java |
Interface additions for warmup management methods |
ISettings.java |
Interface additions for warmup configuration queries |
EssentialsPlayerListener.java |
Event handler integration for triggering warmups on command execution |
AsyncTimedCommand.java |
Core warmup timer implementation with movement/damage detection and async command execution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // Execute the command by dispatching it to the server | ||
| Bukkit.getScheduler().runTask(ess, () -> { | ||
| // Execute as server command to bypass the warmup check |
There was a problem hiding this comment.
The comment mentions "Execute as server command" but the code executes it as the player using Bukkit.dispatchCommand(user.getBase(), ...). This doesn't bypass permission checks as the comment suggests - the command is still executed as the player. If the intent is to bypass warmup checks, this is handled by clearing the warmup first, but the comment is misleading.
| // Execute as server command to bypass the warmup check | |
| // Execute the command as the player (not as server); warmup check is bypassed because it was cleared above |
| final int argStartIndex = effectiveCommand.indexOf(" "); | ||
| final String args = argStartIndex == -1 ? "" | ||
| : " " + effectiveCommand.substring(argStartIndex); | ||
| final String fullCommand = pluginCommand == null ? effectiveCommand : pluginCommand.getName() + args; |
There was a problem hiding this comment.
[nitpick] This code block for calculating args and fullCommand is duplicated from the command cooldowns section above (lines 836-839). Consider extracting this logic to avoid duplication and ensure consistency if the logic needs to change.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…yerListener.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…mand.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…mand.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…mand.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…mand.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR implements command warmups for EssentialsX, adding a configurable delay before commands are executed. During the warmup period, players must stand still and avoid taking damage, or the command will be cancelled.
This feature works similarly to the existing teleport warmup system but can be applied to any command, providing server administrators with better control over command execution timing.
Closes #1320
Configuration
Features
essentials.commandwarmups.movepermission)tp*,/^home-.*/)essentials.commandwarmups.bypass.<command>Breaking Changes
None. This is a fully opt-in feature with no default warmups configured.
Test Coverage
The unit tests verify:
Production Validation