Skip to content

Commit cfc8020

Browse files
committed
feat: new scheduling engine
1 parent b276e92 commit cfc8020

51 files changed

Lines changed: 1668 additions & 579 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ java {
99
}
1010

1111
group = 'me.playbosswar.com'
12-
version = '8.14.1'
12+
version = '8.15.0'
1313
description = 'CommandTimer'
1414

1515
repositories {
@@ -74,7 +74,7 @@ publishing {
7474
maven(MavenPublication) {
7575
groupId = 'me.playbosswar.com'
7676
artifactId = 'commandtimer'
77-
version = '8.14.1'
77+
version = '8.15.0'
7878

7979
from components.java
8080
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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+

docs/docs/configuration/conditions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ Conditions can have one of the following types:
1414
- `AND`: Creates a group of conditions. Each of these conditions needs to be true to execute your [task](../jargon#task).
1515
- `OR`: Creates a group of conditions. One of these conditions needs to be true to execute your [task](../jargon#task). Even if you have 50 conditions that do not match but one does, the [task](../jargon#task) will still go through
1616

17-
When using `AND` and `OR`, more conditions can be nested. Nesting does not have a depth limit, meaning you could have an `AND` condition in an `OR` condition in an `OR` condition in an `AND` condition which itself contains 4 different `SIMPLE` and `NOT` conditions. It is good to draw a visual map yourself before doing these nested conditions, because it can be cumberstone to debug in case there is an issue.
17+
When using `AND` and `OR`, more conditions can be nested. Nesting does not have a depth limit, meaning you could have an `AND` condition in an `OR` condition in an `OR` condition in an `AND` condition which itself contains 4 different `SIMPLE` and `NOT` conditions. It is good to draw a visual map yourself before doing these nested conditions, because it can be cumbersome to debug in case there is an issue.
1818

1919
## Available conditions
2020

21-
Conditions are made availabel through [extensions](../extensions). This means that CommandTimer by default will not have any conditions, making the whole conditions engine useless if no [extensions](../extensions) are installed.
21+
Conditions are made available through [extensions](../extensions). This means that CommandTimer by default will not have any conditions, making the whole conditions engine useless if no [extensions](../extensions) are installed.
2222

2323
## Condition values
2424

docs/docs/configuration/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ sidebar_position: 2
66

77
- [Commands](commands.md)
88
- [Schedules and Intervals](schedules.md)
9+
- [Ad-Hoc Commands](adhoc-commands.md)
910
- [Conditions](conditions.md)
1011
- [Others](others.md)

docs/docs/developers/index.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ dependencies {
2323
### Maven
2424

2525
```xml
26-
2726
<repositories>
2827
<repository>
2928
<id>jitpack.io</id>
@@ -33,7 +32,6 @@ dependencies {
3332
```
3433

3534
```xml
36-
3735
<dependency>
3836
<groupId>com.github.titivermeesch</groupId>
3937
<artifactId>CommandTimer</artifactId>
@@ -50,5 +48,4 @@ functionalities are not available there, the internal CommandTimer API can be us
5048

5149
## Contributing
5250

53-
Did you found a bug or want to do a general improvement on the plugin or the documentation itself? Feel free to open a
54-
PR!
51+
Did you find a bug or want to make a general improvement to the plugin or the documentation? Feel free to open a PR!

docs/docs/extensions/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Once the jar file is in that folder, you should see the extension in different m
1919
Here is a list of extensions that can be installed. Official extensions are made by the team behind CommandTimer, while
2020
community extensions, as the name says, are made by the community.
2121

22-
### Oficial extensions
22+
### Official extensions
2323

2424
- [Time Extension](https://www.spigotmc.org/resources/time-conditions-commandtimer-extension.105591/)
2525
- [Player Extension](https://www.spigotmc.org/resources/player-conditions-commandtimer-extension.97186/)

docs/docs/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar_position: 8
55

66
## Can I execute a task on restart only
77

8-
Yes, by using [execution limits](configuration/others#Execution-limits).
8+
Yes, by using [execution limits](configuration/others#execution-limits).
99

1010
1. Set the execution limit to 1
1111
2. Activate the feature "reset execution after restart"

docs/docs/intro.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,25 @@ Clicking the paper will create a fresh task for you.
2525
| `/cmt activate <task>` | Enable the specified task | `commandtimer.activate` or `commandtimer.toggle` |
2626
| `/cmt deactivate <task>` | Disable the specified task | `commandtimer.deactivate` or `commandtimer.toggle` |
2727
| `/cmt execute <task>` | Instantly execute the specified task | `commandtimer.execute` |
28+
| `/cmt schedule` | Schedule a one-time [ad-hoc command](configuration/adhoc-commands) | `commandtimer.schedule` |
2829
| `/cmt reload` | Reload the plugin. Extensions will not be reloaded. **It is not recommended to use this command** | `commandtimer.manage` |
2930

3031
## Configuration file
3132

3233
The global configuration file allows you to change the global behaviour of CommandTimer:
3334

34-
- `timeonload`: Show the current server time in the console when the plugin loads
35-
- `debug`: Enable debug mode. This will print additional information to the console
36-
- `showUpdateMessage`: Show a message in the chat when a plugin update is available
37-
- `timezoneOverwrite`: Overwrite the timezone of the server (**This feature does not work right now**)
38-
- `timezoneOverwriteValue`: The timezone to overwrite the server timezone with (**This feature does not work right now**)
39-
- `language`: The language to use for the plugin. You can add more languages under the `languages` folder
40-
- `disablePapiPlaceholderWarnings`: Disable the warning message that appears when a PAPI placeholder is not used correctly
35+
| Option | Description |
36+
|---------------------------------|---------------------------------------------------------------------------------------------|
37+
| `timeonload` | Show the current server time in the console when the plugin loads |
38+
| `debug` | Enable debug mode. This will print additional information to the console |
39+
| `showUpdateMessage` | Show a message in the chat when a plugin update is available |
40+
| `timezoneOverwrite` | Overwrite the timezone of the server (**Not working currently**) |
41+
| `timezoneOverwriteValue` | The timezone to overwrite the server timezone with (**Not working currently**) |
42+
| `language` | The language to use for the plugin. You can add more languages under the `languages` folder |
43+
| `disablePapiPlaceholderWarnings`| Disable the warning message that appears when a PAPI placeholder is not used correctly |
4144

45+
## Other Languages
4246

43-
# Other languages
44-
45-
Here is a list of community maintained translations. These are not guaranteed to always be up to date
47+
Here is a list of community maintained translations. These are not guaranteed to always be up to date.
4648

4749
- Chinese: https://snowcutieowo.github.io/CommandTimer/#/

docs/docs/jargon.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
---
2-
sidebar_position: 8
2+
sidebar_position: 10
33
---
4+
45
# Jargon
56

6-
The jargon is a collection of names and definitions specificly targetting a certain group or topic, in this case CommandTimer.
7+
The jargon is a collection of names and definitions specifically targeting a certain group or topic, in this case CommandTimer.
78

8-
You don't necessarily need to read this; other documentation pages will directly reference to this page.
9+
You don't necessarily need to read this; other documentation pages will directly reference this page.
910

1011
## Task
1112

12-
A task is a group of commands linked to a group of rules and conditions. Usually a task groups together commands that are all related to each-other, or execute different things to achieve a common goal.
13+
A task is a group of commands linked to a group of rules and conditions. Usually a task groups together commands that are all related to each other, or execute different things to achieve a common goal.
14+
15+
## Gender
16+
17+
A gender defines how and for whom a command is executed. See [Genders](configuration/commands#genders) for all available options.
18+
19+
## Interval
20+
21+
An interval is a duration that defines how often a task should be executed. See [Intervals](configuration/schedules#intervals) for more details.
22+
23+
## Condition
24+
25+
A condition is a rule that must be met before a task can execute. Conditions are provided by [extensions](extensions).

docs/docs/jsonschema.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,31 @@ Documentation about the Events Engine can be found [here](events)
104104
|-------------|------------------------------------------------------|-------------------------------------------------------------------------------------|
105105
| `fieldName` | Name of the parameter | `string` |
106106
| `value` | Given value for the configured parameter | `any` |
107-
| `compare` | Compare value between event value and passed `value` | `EQUAL`, `GREATER_THAN`, `LESS_THAN`, `GREATER_OR_EQUAL_THAN`, `LESS_OR_EQUAL_THEN` |
107+
| `compare` | Compare value between event value and passed `value` | `EQUAL`, `GREATER_THAN`, `LESS_THAN`, `GREATER_OR_EQUAL_THAN`, `LESS_OR_EQUAL_THAN` |
108+
109+
## Ad-Hoc Command
110+
111+
Ad-hoc commands are stored in `plugins/CommandTimer/ad-hoc-commands/` as individual JSON files. See [Ad-Hoc Commands](configuration/adhoc-commands) for more information.
112+
113+
| Field | Description | Type |
114+
|-----------------|------------------------------------------------------------------|------------------------------------------|
115+
| `id` | Unique identifier for the ad-hoc command. **Do not update manually** | `UUID` |
116+
| `command` | Command to execute. Do not include `/` in front of the command | `string` |
117+
| `gender` | Gender of the command | [Gender](configuration/commands#genders) |
118+
| `scheduledTime` | The date and time when the command should be executed | `ISO-8601 DateTime` |
119+
| `executed` | Whether the command has been executed. **Do not update manually** | `boolean` |
120+
121+
### Ad-Hoc Command example
122+
123+
```json
124+
{
125+
"id": "550e8400-e29b-41d4-a716-446655440000",
126+
"command": "say Server maintenance in 5 minutes!",
127+
"gender": "CONSOLE",
128+
"scheduledTime": "2025-12-07T15:30:00+01:00",
129+
"executed": false
130+
}
131+
```
108132

109133
## Example
110134

0 commit comments

Comments
 (0)