Guest User

Untitled

a guest
Jun 20th, 2021
12
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. AsyncPlayerChatEvent::class
  3. .observable(false, EventPriority.HIGHEST)
  4. .doOnError(Logger.trackError("DiscordManager.AsyncPlayerChatEvent", "error occurs in event subscriber"))
  5. .subscribe {
  6. val ecPlayer = globalManager.players.getByPlayer(it.player)
  7. if (ecPlayer.state != ECPlayerState.AUTHENTICATED) {
  8. it.isCancelled = true
  9. return@subscribe
  10. }
  11.  
  12. val sender = it.player
  13. var message = it.message
  14. val chatType = when {
  15. message.startsWith("@party ") -> {
  16. message = message.replace("@party ", "")
  17. ChatType.PARTY
  18. }
  19. else -> ChatType.GLOBAL
  20. }
  21.  
  22. it.message = globalManager.message.playerChat(sender, chatType, message)
  23. if (chatType != ChatType.PARTY) {
  24. it.recipients.removeIf { p -> globalManager.players.getByPlayer(p).database[Players.ignoredPlayers].contains(sender.name) }
  25. } else {
  26. it.isCancelled = true
  27. globalManager.mcmmo.getPlayerParty(sender).map { p ->
  28. p.sendMessage(it.message)
  29. }
  30. }
  31. }
RAW Paste Data