Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HoshiKurama committed Nov 6, 2022
1 parent c6b3b9a commit 297ffcb
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.bstats.bungeecord.Metrics
import java.nio.file.Files
import java.nio.file.Path
import java.util.*
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.TimeUnit

class WaterfallBridgeAdapter<T>(private val plugin: T) : ProxyBridge()
Expand Down Expand Up @@ -93,6 +94,7 @@ class WaterfallBridgeAdapter<T>(private val plugin: T) : ProxyBridge()
@Suppress("Unused")
class WaterfallBridge : Plugin(), Listener {
private val adapter = WaterfallBridgeAdapter(this)
private val onlyOnceMap = ConcurrentLinkedQueue<ByteArray>()

override fun onEnable() {
adapter.onInitialization()
Expand All @@ -105,6 +107,11 @@ class WaterfallBridge : Plugin(), Listener {

@EventHandler
fun onMessage(event: PluginMessageEvent) {
if (onlyOnceMap.any { Arrays.equals(it, event.data) }) return

onlyOnceMap.add(event.data)
proxy.scheduler.schedule(this, { onlyOnceMap.remove(event.data) }, 1, TimeUnit.SECONDS)

when (event.tag) {

"ticketmanager:inform_proxy" ->
Expand Down

0 comments on commit 297ffcb

Please sign in to comment.