mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
Add private messaging plugin
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import org.apollo.game.message.impl.ForwardPrivateChatMessage
|
||||
import org.apollo.game.message.impl.PrivateChatMessage
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.entity.setting.PrivacyState.OFF
|
||||
import org.apollo.game.model.entity.setting.PrivacyState.ON
|
||||
|
||||
on { PrivateChatMessage::class }
|
||||
.then {
|
||||
val friend = it.world.getPlayer(username)
|
||||
|
||||
if (interactionPermitted(it, friend)) {
|
||||
friend.send(ForwardPrivateChatMessage(it.username, it.privilegeLevel, compressedMessage))
|
||||
}
|
||||
}
|
||||
|
||||
fun interactionPermitted(player: Player, friend: Player?): Boolean {
|
||||
val username = player.username
|
||||
val privacy = friend?.friendPrivacy
|
||||
|
||||
if (friend == null || friend.hasIgnored(username)) {
|
||||
return false
|
||||
} else {
|
||||
return if (friend.friendsWith(username)) privacy != OFF else privacy == ON
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user