普特莫斯维基 (Purtmars Wikipedia 📖)

ink.ptms.chemdah.api.event.PartyHookEvent (Chemdah 开发者文档)

来自Purtmars Wikipedia —— 普特莫斯维基

目录

ink.ptms.chemdah.api.event.PartyHookEvent

通过该事件对接自定义组队插件,该事件并非在插件启动时或任务加载时触发,而是在使用时触发,且只触发一次。

使用方法如下所示

@EventHandler
fun e(e: PartyHookEvent) {
    e.party = when (e.plugin) {
        "Parties" -> PartiesHook
        "PartyAndFriends" -> PartyAndFriendsHook
        "QuantumRPG", "PRORPG" -> QuantumHook
        else -> return
    }
}

使用 Parties 插件对接样例如下

object PartiesHook : Party {

    override fun getParty(player: Player): Party.PartyInfo? {
        val id = Parties.getApi().getPartyPlayer(player.uniqueId)?.partyId ?: return null
        val team = Parties.getApi().getParty(id) ?: return null
        return object : Party.PartyInfo {

            /**
             * 队伍的队长可以不存在
             */
            override fun getLeader(): Player? {
                return Bukkit.getPlayer(team.leader ?: return null)
            }

            /**
             * 队伍的队员中必须不包含队长
             */
            override fun getMembers(): List {
                val members = team.onlineMembers.filter { team.leader != it.playerUUID }
                return members.mapNotNull { Bukkit.getPlayer(it.playerUUID) }
            }
        }
    }
}