Remove plugins.gradle and factor into common extension

This commit is contained in:
Gary Tierney
2017-09-16 18:49:06 +01:00
parent d323bcd69c
commit 36282cf81e
104 changed files with 608 additions and 408 deletions
@@ -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
}
}