|
| 1 | +--- |
| 2 | +sidebar_position: 3 |
| 3 | +--- |
| 4 | + |
| 5 | +# Ad-Hoc Commands |
| 6 | + |
| 7 | +Ad-hoc commands allow you to schedule one-time command executions at a specific time in the future without creating a full [task](../jargon#task). This is perfect for temporary commands, delayed actions, or one-off scheduled executions. |
| 8 | + |
| 9 | +## Overview |
| 10 | + |
| 11 | +Ad-hoc commands are single-use scheduled commands that execute once at a specified time. Unlike regular tasks, they don't have intervals, conditions, or multiple commands - they're designed for simple, one-time executions. |
| 12 | + |
| 13 | +### Key Features |
| 14 | + |
| 15 | +- **One-time execution**: Commands execute once at the scheduled time |
| 16 | +- **Flexible scheduling**: Schedule commands to run at any future time |
| 17 | +- **All gender types supported**: Use any [gender](commands.md#genders) for command execution |
| 18 | +- **Persistent storage**: Commands are saved to disk and survive server restarts |
| 19 | +- **GUI management**: View and manage scheduled ad-hoc commands through the GUI |
| 20 | + |
| 21 | +## Command Syntax |
| 22 | + |
| 23 | +Schedule an ad-hoc command using the `/cmt schedule` command: |
| 24 | + |
| 25 | +``` |
| 26 | +/cmt schedule [-after <time>] [-gender <gender>] <command> |
| 27 | +``` |
| 28 | + |
| 29 | +### Parameters |
| 30 | + |
| 31 | +- **`-after <time>`** (optional): Delay before execution. Format: `1h10m5s` (hours, minutes, seconds) |
| 32 | + - Examples: `30s`, `5m`, `1h30m`, `2h15m30s` |
| 33 | + |
| 34 | +- **`-gender <gender>`** (optional): The [gender](commands.md#genders) to use for execution |
| 35 | + - Valid options: `CONSOLE`, `PLAYER`, `OPERATOR`, `CONSOLE_PER_USER`, `CONSOLE_PER_USER_OFFLINE`, `CONSOLE_PROXY` |
| 36 | + - Default: `CONSOLE` |
| 37 | + |
| 38 | +- **`<command>`** (required): The command to execute (without the leading `/`) |
| 39 | + |
| 40 | +### Examples |
| 41 | + |
| 42 | +#### Basic Examples |
| 43 | + |
| 44 | +```bash |
| 45 | +# Schedule a broadcast message in 5 minutes |
| 46 | +/cmt schedule -after 5m say Server maintenance in 5 minutes! |
| 47 | + |
| 48 | +# Schedule a command to run in 1 hour |
| 49 | +/cmt schedule -after 1h weather clear |
| 50 | + |
| 51 | +# Schedule a command to run in 2 hours, 15 minutes, and 30 seconds |
| 52 | +/cmt schedule -after 2h15m30s time set day |
| 53 | +``` |
| 54 | + |
| 55 | +#### Using Different Genders |
| 56 | + |
| 57 | +```bash |
| 58 | +# Execute as console (default) |
| 59 | +/cmt schedule -after 10m say Announcement |
| 60 | + |
| 61 | +# Execute for each online player |
| 62 | +/cmt schedule -after 30m -gender CONSOLE_PER_USER give %player_name% diamond 1 |
| 63 | + |
| 64 | +# Execute as if each player is OP |
| 65 | +/cmt schedule -after 1h -gender OPERATOR gamemode creative %player_name% |
| 66 | + |
| 67 | +# Execute for each player (respects permissions) |
| 68 | +/cmt schedule -after 2h -gender PLAYER home |
| 69 | +``` |
| 70 | + |
| 71 | +#### Real-World Use Cases |
| 72 | + |
| 73 | +```bash |
| 74 | +# Schedule a server restart announcement |
| 75 | +/cmt schedule -after 30m say Server restarting in 30 minutes! |
| 76 | +/cmt schedule -after 15m say Server restarting in 15 minutes! |
| 77 | +/cmt schedule -after 5m say Server restarting in 5 minutes! |
| 78 | +/cmt schedule -after 1m say Server restarting in 1 minute! |
| 79 | + |
| 80 | +# Schedule a timed event start |
| 81 | +/cmt schedule -after 1h -gender CONSOLE_PER_USER title %player_name% title {"text":"Event Starting!"} |
| 82 | + |
| 83 | +# Schedule maintenance commands |
| 84 | +/cmt schedule -after 2h save-all |
| 85 | +/cmt schedule -after 2h5m say Maintenance complete! |
| 86 | + |
| 87 | +# Schedule player rewards |
| 88 | +/cmt schedule -after 24h -gender CONSOLE_PER_USER give %player_name% emerald 10 |
| 89 | +``` |
| 90 | + |
| 91 | +## Managing Ad-Hoc Commands |
| 92 | + |
| 93 | +### GUI Management |
| 94 | + |
| 95 | +You can view and manage ad-hoc commands through the **Scheduled Executions** menu: |
| 96 | + |
| 97 | +1. Open the main menu: `/cmt` |
| 98 | +2. Click on **Scheduled Executions** |
| 99 | +3. Use the filter button to show only ad-hoc commands (filter: "Ad-Hoc Only") |
| 100 | +4. Right-click on an ad-hoc command to cancel it |
| 101 | + |
| 102 | +## Differences from Regular Tasks |
| 103 | + |
| 104 | +| Feature | Ad-Hoc Commands | Regular Tasks | |
| 105 | +|----------|----------------|---------------| |
| 106 | +| **Execution** | One-time only | Recurring or event-based | |
| 107 | +| **Commands** | Single command | Multiple commands | |
| 108 | +| **Intervals** | Not supported | Supported | |
| 109 | +| **Conditions** | Not supported | Supported | |
| 110 | +| **Events** | Not supported | Supported | |
| 111 | +| **Execution Modes** | Not applicable | ALL, ORDERED, RANDOM, INTERVAL | |
| 112 | +| **Use Case** | Temporary, one-off commands | Permanent, recurring automation | |
| 113 | + |
| 114 | +## Permissions |
| 115 | + |
| 116 | +- **`commandtimer.schedule`**: Required to schedule ad-hoc commands |
| 117 | +- **`commandtimer.manage`**: Required to view the GUI and manage commands |
| 118 | + |
| 119 | +## Troubleshooting |
| 120 | + |
| 121 | +### Command Not Executing |
| 122 | + |
| 123 | +- Check that the scheduled time has passed |
| 124 | +- Verify the command syntax is correct |
| 125 | +- Check server logs for execution errors |
| 126 | +- Ensure the ad-hoc command runner is active (should start automatically) |
| 127 | + |
| 128 | +### Command Executing Too Early/Late |
| 129 | + |
| 130 | +- Commands execute within 0.5 seconds of their scheduled time |
| 131 | +- Server lag may cause slight delays |
| 132 | +- For precise timing, schedule commands slightly earlier than needed |
| 133 | + |
| 134 | +### Commands Lost After Restart |
| 135 | + |
| 136 | +- Commands are saved to disk and should persist |
| 137 | +- Check that the scheduled time hasn't passed yet |
| 138 | +- Only non-executed commands are loaded on startup |
| 139 | + |
0 commit comments