up da te fi sh

This commit is contained in:
TONY_All 2022-07-03 22:58:24 +08:00
parent 90c80170bb
commit 521e11197b
3 changed files with 18 additions and 9 deletions

View File

@ -46,6 +46,7 @@ object FishListener {
if (fishEvent.state == PlayerFishEvent.State.CAUGHT_FISH) { if (fishEvent.state == PlayerFishEvent.State.CAUGHT_FISH) {
rod.handleFished(fishEvent) rod.handleFished(fishEvent)
} }
val resultItem = if (rod.durability <= 0) { val resultItem = if (rod.durability <= 0) {
player.sendMessage("§c| §7您的鱼竿已损坏") player.sendMessage("§c| §7您的鱼竿已损坏")
ItemStack(Material.AIR) ItemStack(Material.AIR)

View File

@ -29,16 +29,20 @@ class BaitReward(config: ConfigurationSection) {
rod.luck = if (rod.luck - it.deLuck > 0) rod.luck - it.deLuck else 0 rod.luck = if (rod.luck - it.deLuck > 0) rod.luck - it.deLuck else 0
} }
// handle Guarantees
if (it.isGuarantees) {
if (rod.luck == it.luckLimit) {
it.execute(player)
}
return
}
// handle common // handle common
it.execute(player) it.execute(player)
} }
} }
fun doGuarantee(player: Player, luck: Int, legacy: Int) {
rewardList.forEach {
// handle Guarantees
if (it.isGuarantees) {
if (it.luckLimit in legacy..luck) {
it.execute(player)
}
return
}
}
}
} }

View File

@ -25,10 +25,14 @@ data class FishingRodInstance(
fun handleFished(fishEvent: PlayerFishEvent) { fun handleFished(fishEvent: PlayerFishEvent) {
fishEvent.expToDrop = 0 fishEvent.expToDrop = 0
luck++
fishEvent.caught!!.remove() fishEvent.caught!!.remove()
fishEvent.player.inventory.itemInMainHand fishEvent.player.inventory.itemInMainHand
val bait = BaitManager.baits[item.itemMeta!!.persistentDataContainer[SanseFish.baitKey, PersistentDataType.STRING]?: return]!! val bait = BaitManager.baits[item.itemMeta!!.persistentDataContainer[SanseFish.baitKey, PersistentDataType.STRING]?: return]!!
luck++
val maxLuck = item.itemMeta!!.persistentDataContainer.getOrDefault(SanseFish.maxLuckKey, PersistentDataType.INTEGER, type.defaultLuck)
if (luck > maxLuck) {
bait.rewards.doGuarantee(fishEvent.player, luck, maxLuck)
}
bait.rewards.doReward(fishEvent.player, this) bait.rewards.doReward(fishEvent.player, this)
} }
} }