Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
2020/9/30 HUGE UPDATE
Browse files Browse the repository at this point in the history
Former-commit-id: 7fa4f0f
  • Loading branch information
Nambers committed Sep 30, 2020
1 parent 7f057be commit af94fd9
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 2 deletions.
Binary file modified kotlin_mirai/.gradle/6.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/6.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/6.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/6.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified kotlin_mirai/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
6 changes: 6 additions & 0 deletions kotlin_mirai/src/main/kotlin/com/example/plugin/CPP_lib.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class CPP_lib {
System.load("D:\\Mirai\\libraries\\mirai-demo.dll")
}
@JvmStatic
fun SendGroup(message:String,id:Long){
GlobalScope.launch(Dispatchers.Default) {
SendG(message, id)
}
}
@JvmStatic
fun SendLog(log:String){
BasicSendLog(log)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ lateinit var Logger:net.mamoe.mirai.utils.MiraiLogger
fun BasicSendLog(log:String){
Logger.info(log)
}
suspend fun SendG(message:String,id:Long){
AIbot.getGroup(id).sendMessage(message)
}
object ExamplePluginMain : PluginBase() {
override fun onEnable() {
Logger=logger
Expand Down
Binary file modified mirai-demo/.vs/mirai-demo/v16/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion mirai-demo/.vs/mirai-demo/v16/Browse.VC.db.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0e7a49f467223b89d85c3c8723e0772f8fdc45f9
07f4f50ff196414800d4a2d6f1b3a7471871abbf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15282a0547c9111ded7e04483b8ee5aebc992eb5
3c06f60055cb3a2a702caf58fa078d8835f9bf96
23 changes: 23 additions & 0 deletions mirai-demo/pch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ void SendPrivate(JNIEnv* env, jobject job, string mess,long id) {
//4.删除掉本地引用
env->DeleteLocalRef(java_first);
}
void SendGroup(JNIEnv* env, jobject job, string mess, long id) {
//1.首先要在C中获取jclass对象,也就是找到方法所在的类,通过完整 包名+类名
jclass java_first = env->FindClass("com/example/plugin/CPP_lib");

/**2.找到该方法的方法ID
*参数一:jclass
*参数二:方法名
*参数三:方法签名
*方法签名,网上有详细说明,如果不想查,可以使用javap -s指令查询
*/
jmethodID static_method_id = env->GetStaticMethodID(java_first, "SendGroup", "(Ljava/lang/String;J)V");

/**3.调用静态方法
*参数一:jclass
*参数二:方法ID
*参数三:参数三是可变长参数,也就是该方法声明时候对应的参数列表,相当于调用方法时的传参
*这个方法声明的是(s: String, i: Int)
*/
env->CallStaticVoidMethod(java_first, static_method_id, tools.str2jstring(env, mess.c_str()), (jlong)id);

//4.删除掉本地引用
env->DeleteLocalRef(java_first);
}
void SendLog(JNIEnv* env, jobject job, string log) {
//1.首先要在C中获取jclass对象,也就是找到方法所在的类,通过完整 包名+类名
jclass java_first = env->FindClass("com/example/plugin/CPP_lib");
Expand Down

0 comments on commit af94fd9

Please sign in to comment.