mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 08:39:27 +00:00
Remove plugins.gradle and factor into common extension
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
apolloPlugin {
|
||||
name = "private-messaging"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import org.apollo.game.message.impl.AddFriendMessage
|
||||
import org.apollo.game.message.impl.SendFriendMessage
|
||||
import org.apollo.game.model.entity.setting.PrivacyState
|
||||
|
||||
on { AddFriendMessage::class }
|
||||
.then {
|
||||
it.addFriend(username)
|
||||
|
||||
val friend = it.world.getPlayer(username)
|
||||
|
||||
if (friend == null || friend.friendPrivacy == PrivacyState.OFF) {
|
||||
it.send(SendFriendMessage(username, 0))
|
||||
return@then
|
||||
} else {
|
||||
it.send(SendFriendMessage(username, friend.worldId))
|
||||
}
|
||||
|
||||
if (friend.friendsWith(it.username) && it.friendPrivacy != PrivacyState.OFF) {
|
||||
friend.send(SendFriendMessage(it.username, it.worldId))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import org.apollo.game.message.impl.AddIgnoreMessage
|
||||
import org.apollo.game.message.impl.RemoveIgnoreMessage
|
||||
|
||||
on { AddIgnoreMessage::class }
|
||||
.then { it.addIgnore(username) }
|
||||
|
||||
on { RemoveIgnoreMessage::class }
|
||||
.then { it.removeIgnore(username) }
|
||||
@@ -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