Package com.ultikits.ultitools.manager
Class TaskManager
java.lang.Object
com.ultikits.ultitools.manager.TaskManager
Manages scheduled tasks for plugin modules.
Scans beans for Scheduled annotated methods and registers them
as Bukkit tasks. Automatically cancels all tasks when a plugin is unloaded.
管理插件模块的定时任务。扫描 Bean 中标注 Scheduled 的方法并注册为 Bukkit 任务。
插件卸载时自动取消所有任务。
- Since:
- 6.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.bukkit.plugin.java.JavaPluginprivate final Map<UltiToolsPlugin, List<org.bukkit.scheduler.BukkitTask>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelAll(UltiToolsPlugin plugin) Cancel all scheduled tasks for a plugin.voidcancelAllExternal(String pluginName) Cancel all scheduled tasks for an external plugin.(package private) intgetExternalTaskCount(String pluginName) Get the number of registered tasks for an external plugin (for testing).private Class<?> getTargetClass(Class<?> clazz) Get the original class, unwrapping CGLIB proxies.(package private) intgetTaskCount(UltiToolsPlugin plugin) Get the number of registered tasks for a plugin (for testing).voidregisterScheduledMethods(UltiToolsPlugin plugin, Object bean) Scan a bean forScheduledmethods and register them as Bukkit tasks.voidregisterScheduledMethodsExternal(String pluginName, Object bean) Scan a bean forScheduledmethods and register them for an external plugin.
-
Field Details
-
pluginTasks
-
externalTasks
-
hostPlugin
private final org.bukkit.plugin.java.JavaPlugin hostPlugin
-
-
Constructor Details
-
TaskManager
public TaskManager(org.bukkit.plugin.java.JavaPlugin hostPlugin)
-
-
Method Details
-
registerScheduledMethods
Scan a bean forScheduledmethods and register them as Bukkit tasks.扫描 Bean 中的
Scheduled方法并注册为 Bukkit 任务。- Parameters:
plugin- the owning plugin modulebean- the bean instance to scan
-
cancelAll
Cancel all scheduled tasks for a plugin.取消插件的所有定时任务。
- Parameters:
plugin- the plugin to cancel tasks for
-
getTargetClass
Get the original class, unwrapping CGLIB proxies. CGLIB proxy classes contain "$$" in their name. -
registerScheduledMethodsExternal
Scan a bean forScheduledmethods and register them for an external plugin.扫描 Bean 中的
Scheduled方法并为外部插件注册。- Parameters:
pluginName- the external plugin name (used as key)bean- the bean instance to scan- Since:
- 6.2.2
-
cancelAllExternal
Cancel all scheduled tasks for an external plugin.取消外部插件的所有定时任务。
- Parameters:
pluginName- the external plugin name- Since:
- 6.2.2
-
getTaskCount
Get the number of registered tasks for a plugin (for testing). -
getExternalTaskCount
Get the number of registered tasks for an external plugin (for testing).
-