Download the PHP package nicktee/taskondemand without Composer
On this page you can find all versions of the php package nicktee/taskondemand. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nicktee/taskondemand
More information about nicktee/taskondemand
Files in nicktee/taskondemand
Package taskondemand
Short Description A lightweight conditional task/event manager for PocketMine-MP.
License MIT
Informations about the package taskondemand
TaskOnDemand
A lightweight, centralized conditional task and event manager for PocketMine-MP.
TaskOnDemand lets you easily schedule and execute delayed or conditional tasks in response to specific PocketMine events — all without manually handling event listeners, TaskHandler references, or cancellation logic.
Everything is centralized, so there are no loose closures or dangling references that could lead to memory leaks. The library handles event registration, validation, and task cleanup for you.
✨ Key Advantages
- 🧩 Centralized management — all conditional tasks are tracked and cleaned automatically.
- ⚡ Zero manual cleanup — no need to store or cancel
TaskHandlers yourself. - 🧠 Conditional triggers — run tasks only when event conditions evaluate to true.
- 🕒 Delayed execution — run actions after a specified delay.
- 🧺 Memory-safe — callables and parameters are released once tasks complete or are removed.
- 🔧 Modular design — ideal for plugins that need flexible event-driven logic.
📦 Installation
🧠 Usage Example — Combat Log System
⚙️ Registering an Event
Register conditional events in your plugin’s onEnable() method:
⏳ Scheduling a Delayed Conditional Task
Once your event is registered, you can schedule a delayed task that listens for it:
💡 This example means:
- The task will automatically run after 15 seconds.
- If the player quits before that, the event condition will trigger the task immediately.
- You don’t need to manually cancel the task — TaskOnDemand manages that internally.
⚡ Forcing Task Execution
Force-run a task immediately (e.g., cancel combat):
❌ Removing a Scheduled Task
Remove a pending task entirely:
🔍 Checking if a Task Exists
You can check whether a specific conditional task currently exists using hasConditionalTask():
This is useful to verify whether a player is currently under an active timed condition (e.g., combat, cooldown, or ability effect).
🧩 When to Use TaskOnDemand
- Cooldown/Delayed task systems
onDisable()tasks (use PluginDisableEvent)- When you have several events modifying the same task
- Graceful handling of player disconnects and active player references
- Temporary player abilities/effects that should be reversed on death/quit/teleport etc.
🛠 Technical Details
- Automatically manages
TaskHandlers and closures. - Ensures memory safety by removing references when tasks are done.
- All event and task data is centralized for clean lifecycle management.
- Works seamlessly with PocketMine’s scheduler and event system.
💬 Feedback & Feature Requests
If you have suggestions, feature ideas, or bug reports, please open an issue on the GitHub repository.
Your feedback helps improve TaskOnDemand for everyone. ❤️