Skip to content

Commit

Permalink
#2 - added check for item in hand and offhand
Browse files Browse the repository at this point in the history
  • Loading branch information
makeevrserg committed Jul 28, 2023
1 parent b5b2a17 commit 49ddc6d
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ class PassiveManaRestore(
model: MainConfiguration.ManaConfiguration.PassiveManaRestoreModel,
player: Player
) {
player.inventory.armorContents.firstOrNull {
val customItem = it?.let(CustomStack::byItemStack)
val allContent = listOf(
player.inventory.itemInMainHand,
player.inventory.itemInOffHand
) + player.inventory.armorContents.filterNotNull()

allContent.firstOrNull {
val customItem = it.let(CustomStack::byItemStack)
customItem?.id == model.id
} ?: return
withContext(dispatchers.BukkitMain) {
Expand All @@ -57,7 +62,10 @@ class PassiveManaRestore(
if (player.isOp)
logger.info("PassiveManaRestore-$jobId", "Player ${player.name} has OP! Mana will not be changed!")

logger.info("PassiveManaRestore-$jobId", "Player ${player.name} mana now is ${newValue}. Increased by ${model.mana}")
logger.info(
"PassiveManaRestore-$jobId",
"Player ${player.name} mana now is ${newValue}. Increased by ${model.mana}"
)
}
}
}
Expand Down

0 comments on commit 49ddc6d

Please sign in to comment.