-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2f7034
commit 8802254
Showing
5 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
dist/src/main/kotlin/kr/toxicity/healthbar/compatibility/PartiesCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package kr.toxicity.healthbar.compatibility | ||
|
||
import com.alessiodp.parties.bukkit.BukkitPartiesPlugin | ||
import kr.toxicity.healthbar.api.placeholder.PlaceholderContainer | ||
import kr.toxicity.healthbar.util.placeholder | ||
import org.bukkit.Bukkit | ||
import java.util.function.Function | ||
|
||
class PartiesCompatibility : Compatibility { | ||
override fun accept() { | ||
val parties = Class.forName("com.alessiodp.parties.core.bukkit.bootstrap.ADPBukkitBootstrap").getDeclaredField("plugin").run { | ||
isAccessible = true | ||
get(Bukkit.getPluginManager().getPlugin("Parties")) | ||
} as BukkitPartiesPlugin | ||
PlaceholderContainer.BOOL.addPlaceholder("parties_is_leader", placeholder(0) { | ||
Function get@ { | ||
val uuid = it.entity.entity().uniqueId | ||
val player = parties.playerManager.getPlayer(uuid) ?: return@get false | ||
val party = parties.partyManager.getPartyOfPlayer(player) ?: return@get false | ||
party.leader == player.playerUUID | ||
} | ||
}) | ||
PlaceholderContainer.BOOL.addPlaceholder("parties_is_member", placeholder(0) { | ||
Function get@{ | ||
val my = parties.playerManager.getPlayer(it.player.player().uniqueId)?.partyId ?: return@get false | ||
val other = parties.playerManager.getPlayer(it.entity.entity().uniqueId)?.partyId ?: return@get false | ||
my == other | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters