普特莫斯维基 (Purtmars Wikipedia 📖)

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

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

目录

ink.ptms.chemdah.api.event.PartyHookEvent

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

使用方法如下所示

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 }