Chemdah 开发者文档:ink.ptms.chemdah.api.event.PartyHookEvent
来自Purtmars Wikipedia —— 普特莫斯维基
目录
- Chemdah
- 开始
- 基本
- 事件
- ink.ptms.chemdah.api.event.collect.ConversationEvents
- ink.ptms.chemdah.api.event.collect.ObjectiveEvents
- ink.ptms.chemdah.api.event.collect.PlayerEvents
- ink.ptms.chemdah.api.event.collect.QuestEvents
- ink.ptms.chemdah.api.event.collect.TemplateEvents
- ink.ptms.chemdah.api.event.InferEntityHookEvent
- ink.ptms.chemdah.api.event.InferItemHookEvent
- ink.ptms.chemdah.api.event.PartyHookEvent
- 对话相关
- 数据相关
- 任务相关
ink.ptms.chemdah.api.event.PartyHookEvent
通过该事件对接自定义组队插件,但需要注意的是这个事件会频繁执行,需缓存 Party 实现类以免造成内存泄漏。
使用方法如下所示
1 @EventHandler
2 fun e(e: PartyHookEvent) {
3 e.party = when (e.plugin) {
4 "Parties" -> PartiesHook
5 "PartyAndFriends" -> PartyAndFriendsHook
6 "QuantumRPG", "PRORPG" -> QuantumHook
7 else -> return
8 }
9 }
使用 Parties 插件对接样例如下
1 object PartiesHook : Party {
2
3 override fun getParty(player: Player): Party.PartyInfo? {
4 val id = Parties.getApi().getPartyPlayer(player.uniqueId)?.partyId ?: return null
5 val team = Parties.getApi().getParty(id) ?: return null
6 return object : Party.PartyInfo {
7
8 /**
9 * 队伍的队长可以不存在
10 */
11 override fun getLeader(): Player? {
12 return Bukkit.getPlayer(team.leader ?: return null)
13 }
14
15 /**
16 * 队伍的队员中必须不包含队长
17 */
18 override fun getMembers(): List<Player> {
19 val members = team.onlineMembers.filter { team.leader != it.playerUUID }
20 return members.mapNotNull { Bukkit.getPlayer(it.playerUUID) }
21 }
22 }
23 }
24 }