Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
617b2318
Commit
617b2318
authored
Feb 14, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
japt Events
parent
61973170
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
11 deletions
+44
-11
mirai-japt/src/main/java/net/mamoe/mirai/japt/Events.java
mirai-japt/src/main/java/net/mamoe/mirai/japt/Events.java
+39
-0
mirai-japt/src/main/kotlin/net/mamoe/mirai/japt/internal/EventsImpl.kt
...c/main/kotlin/net/mamoe/mirai/japt/internal/EventsImpl.kt
+5
-11
No files found.
mirai-japt/src/main/java/net/mamoe/mirai/japt/Events.java
0 → 100644
View file @
617b2318
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package
net.mamoe.mirai.japt
;
import
kotlinx.coroutines.GlobalScope
;
import
net.mamoe.mirai.event.Event
;
import
net.mamoe.mirai.event.Listener
;
import
net.mamoe.mirai.event.ListeningStatus
;
import
net.mamoe.mirai.event.internal.EventInternalJvmKt
;
import
net.mamoe.mirai.japt.internal.EventsImplKt
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
public
final
class
Events
{
@NotNull
public
static
<
E
extends
Event
>
Listener
<
E
>
subscribe
(
@NotNull
Class
<
E
>
eventClass
,
@NotNull
Function
<
E
,
ListeningStatus
>
onEvent
)
{
return
EventInternalJvmKt
.
_subscribeEventForJaptOnly
(
eventClass
,
GlobalScope
.
INSTANCE
,
onEvent
);
}
@NotNull
public
static
<
E
extends
Event
>
Listener
<
E
>
subscribeAlways
(
@NotNull
Class
<
E
>
eventClass
,
@NotNull
Consumer
<
E
>
onEvent
)
{
return
EventInternalJvmKt
.
_subscribeEventForJaptOnly
(
eventClass
,
GlobalScope
.
INSTANCE
,
onEvent
);
}
@NotNull
public
static
<
E
extends
Event
>
E
broadcast
(
@NotNull
E
event
)
{
return
EventsImplKt
.
broadcast
(
event
);
}
}
\ No newline at end of file
mirai-
core/src/jvmMain/kotlin/net/mamoe/mirai/event/SubscribersJvm
.kt
→
mirai-
japt/src/main/kotlin/net/mamoe/mirai/japt/internal/EventsImpl
.kt
View file @
617b2318
...
@@ -7,16 +7,10 @@
...
@@ -7,16 +7,10 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
*/
package
net.mamoe.mirai.
event
package
net.mamoe.mirai.
japt.internal
import
kotlinx.coroutines.runBlocking
import
net.mamoe.mirai.event.Event
import
net.mamoe.mirai.event.broadcast
// TODO 添加更多
internal
fun
<
E
:
Event
>
broadcast
(
e
:
E
):
E
=
runBlocking
{
e
.
broadcast
()
}
/**
\ No newline at end of file
* Jvm 调用实现(阻塞)
*/
object
Events
{
/*
@JvmStatic
fun <E : Event> subscribe(type: Class<E>, handler: suspend (E) -> ListeningStatus) =
runBlocking { type.kotlin.subscribe(handler) }*/
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment