Skip to content

Commit 990d682

Browse files
committed
Fix multi listener
1 parent 25f6246 commit 990d682

File tree

2 files changed

+2
-31
lines changed

2 files changed

+2
-31
lines changed

common/src/main/kotlin/com/lambda/Lambda.kt

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,11 @@ object Lambda {
2525
init {
2626
listener<PacketEvent.Send.Pre> {
2727
if (it.packet is LookAndOnGround) {
28-
// it.cancel()
28+
it.cancel()
2929
LOG.info("SAFE: Canceled: ${it.packet::class.simpleName}")
3030
}
3131
}
3232

33-
listener<PacketEvent.Send.Pre> {
34-
if (it.packet is LookAndOnGround) {
35-
// it.cancel()
36-
LOG.info("2 SAFE: Canceled: ${it.packet::class.simpleName}")
37-
}
38-
}
39-
40-
unsafeListener<PacketEvent.Send.Pre> {
41-
if (it.packet is LookAndOnGround) {
42-
// it.cancel()
43-
LOG.info("UNSAFE: Canceled: ${it.packet::class.simpleName}")
44-
}
45-
}
46-
47-
concurrentListener<PacketEvent.Send.Pre> {
48-
if (it.packet is LookAndOnGround) {
49-
LOG.info("CONCURRENT: ${it.packet::class.simpleName}")
50-
}
51-
}
52-
53-
unsafeConcurrentListener<PacketEvent.Send.Pre> {
54-
if (it.packet is LookAndOnGround) {
55-
LOG.info("UNSAFE CONCURRENT: ${it.packet::class.simpleName}")
56-
}
57-
}
58-
59-
LOG.info("Registered sync listeners: ${EventFlow.syncListeners}")
60-
LOG.info("Registered concurrent listeners: ${EventFlow.concurrentListeners}")
61-
6233
runConcurrent {
6334
sleep(60000)
6435
LOG.info("Unsubscribing")

common/src/main/kotlin/com/lambda/event/listener/Listener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ abstract class Listener : Comparable<Listener> {
99
abstract fun execute(event: Event)
1010

1111
override fun compareTo(other: Listener): Int {
12-
return priority.compareTo(other.priority)
12+
return compareBy<Listener> { it.priority }.thenBy { it.hashCode() }.compare(this, other)
1313
}
1414

1515
companion object {

0 commit comments

Comments
 (0)