feat: add auto clean task

This commit is contained in:
Tsubasa6848
2024-01-05 11:01:51 +08:00
Unverified
parent f3d9fd39b5
commit 47579ff019
3 changed files with 9 additions and 2 deletions
+5 -2
View File
@@ -104,8 +104,11 @@ void CleanTask() {
});
}
void CountEntitiesTask() {
//
void AutoCleanTask() {
auto_clean_task->cancel();
auto_clean_task = scheduler.add<RepeatTask>(1min, [] {
CleanTask();
});
}
} // namespace Cleaner
+2
View File
@@ -5,7 +5,9 @@
extern ll::Logger logger;
extern void RegisterCommands();
extern void UnregisterCommands();
static std::shared_ptr<ll::schedule::task::Task<ll::chrono::GameTimeClock>> auto_clean_task;
namespace Cleaner {
extern void CleanTask();
extern void AutoCleanTask();
}
+2
View File
@@ -10,6 +10,7 @@ Plugin::Plugin(ll::plugin::NativePlugin& self) : mSelf(self) {
bool Plugin::enable() {
RegisterCommands();
Cleaner::AutoCleanTask();
logger.info("Cleaner Loaded!");
logger.info("Author: Tsubasa6848");
logger.info("Repository: https://github.com/GroupMountain/Cleaner");
@@ -19,6 +20,7 @@ bool Plugin::enable() {
bool Plugin::disable() {
logger.info("Disabling Cleaner...");
// Code for disabling the plugin goes here.
auto_clean_task->cancel();
UnregisterCommands();
logger.info("Cleaner Disabled!");
return true;