mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-16 05:40:14 +08:00
add Java API
This commit is contained in:
parent
4d8753d8e2
commit
e82281367e
@ -14,7 +14,7 @@ public class EventListener {
|
|||||||
|
|
||||||
PluginBase base;
|
PluginBase base;
|
||||||
|
|
||||||
protected EventListener(
|
public EventListener(
|
||||||
PluginBase base
|
PluginBase base
|
||||||
){
|
){
|
||||||
this.base = base;
|
this.base = base;
|
||||||
|
@ -15,6 +15,7 @@ import kotlinx.coroutines.*
|
|||||||
import net.mamoe.mirai.console.MiraiConsole
|
import net.mamoe.mirai.console.MiraiConsole
|
||||||
import net.mamoe.mirai.console.command.Command
|
import net.mamoe.mirai.console.command.Command
|
||||||
import net.mamoe.mirai.console.command.CommandSender
|
import net.mamoe.mirai.console.command.CommandSender
|
||||||
|
import net.mamoe.mirai.console.events.EventListener
|
||||||
import net.mamoe.mirai.console.scheduler.PluginScheduler
|
import net.mamoe.mirai.console.scheduler.PluginScheduler
|
||||||
import net.mamoe.mirai.console.scheduler.SchedulerTaskManagerInstance
|
import net.mamoe.mirai.console.scheduler.SchedulerTaskManagerInstance
|
||||||
import net.mamoe.mirai.utils.MiraiLogger
|
import net.mamoe.mirai.utils.MiraiLogger
|
||||||
@ -138,6 +139,14 @@ abstract class PluginBase
|
|||||||
return scheduler!!
|
return scheduler!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var eventListener:EventListener? = null
|
||||||
|
fun getEventListener():EventListener{
|
||||||
|
if(eventListener == null){
|
||||||
|
eventListener = EventListener(this)
|
||||||
|
}
|
||||||
|
return eventListener!!
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,9 +100,22 @@ class PluginScheduler(_coroutineContext: CoroutineContext) :CoroutineScope{
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步执行一个任务, 没有返回
|
||||||
|
*/
|
||||||
|
fun async(runnable: Runnable){
|
||||||
|
this.launch {
|
||||||
|
withContext(Dispatchers.IO){
|
||||||
|
runnable.run()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 这个类作为java与kotlin的桥接
|
* 这个类作为java与kotlin的桥接
|
||||||
* 用java的interface进行了kotlin的实现
|
* 用java的interface进行了kotlin的实现
|
||||||
|
Loading…
Reference in New Issue
Block a user