mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-03 06:12:21 +00:00
Fixed level rewards
This commit is contained in:
@@ -101,7 +101,7 @@ class CommandRecount(plugin: EcoPlugin): Subcommand(
|
||||
if (reward.obj is Effect && reward.obj == effect) {
|
||||
for (i in range) {
|
||||
val obj = reward.obj
|
||||
val toGive = skill.getLevelUpReward(obj, i)
|
||||
val toGive = skill.getLevelUpReward(reward, i)
|
||||
ofSkill+=toGive
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class DataListener : Listener {
|
||||
}
|
||||
event.player.setEffectLevel(
|
||||
obj,
|
||||
skill.getCumulativeLevelUpReward(obj, event.player.getSkillLevel(skill))
|
||||
skill.getCumulativeLevelUpReward(levelUpReward, event.player.getSkillLevel(skill))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,9 +209,9 @@ abstract class Skill(
|
||||
return ArrayList(rewards)
|
||||
}
|
||||
|
||||
fun getLevelUpReward(skillObject: SkillObject, to: Int): Int {
|
||||
fun getLevelUpReward(skillObjectReward: SkillObjectReward, to: Int): Int {
|
||||
for (reward in rewards) {
|
||||
if (reward.obj != skillObject) {
|
||||
if (reward != skillObjectReward) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -226,10 +226,10 @@ abstract class Skill(
|
||||
return 0
|
||||
}
|
||||
|
||||
fun getCumulativeLevelUpReward(skillObject: SkillObject, to: Int): Int {
|
||||
fun getCumulativeLevelUpReward(skillObjectReward: SkillObjectReward, to: Int): Int {
|
||||
var levels = 0
|
||||
for (i in 1..to) {
|
||||
levels += getLevelUpReward(skillObject, i)
|
||||
levels += getLevelUpReward(skillObjectReward, i)
|
||||
}
|
||||
|
||||
return levels
|
||||
@@ -259,7 +259,7 @@ abstract class Skill(
|
||||
val skillObject = levelUpReward.obj
|
||||
|
||||
if (skillObject is Effect) {
|
||||
val objLevel = this.getCumulativeLevelUpReward(skillObject, level)
|
||||
val objLevel = this.getCumulativeLevelUpReward(levelUpReward, level)
|
||||
msg = msg.replace(
|
||||
"%ecoskills_${skillObject.id}_description%",
|
||||
skillObject.getDescription(objLevel)
|
||||
@@ -298,7 +298,7 @@ abstract class Skill(
|
||||
|
||||
for (levelUpReward in this.getLevelUpRewards()) {
|
||||
val skillObject = levelUpReward.obj
|
||||
val objLevel = this.getCumulativeLevelUpReward(skillObject, level)
|
||||
val objLevel = this.getCumulativeLevelUpReward(levelUpReward, level)
|
||||
|
||||
s = s.replace("%ecoskills_${skillObject.id}%", objLevel.toString())
|
||||
s = s.replace("%ecoskills_${skillObject.id}_numeral%", NumberUtils.toNumeral(objLevel))
|
||||
|
||||
@@ -20,7 +20,7 @@ class SkillLevellingListener : Listener {
|
||||
|
||||
for (reward in skill.getLevelUpRewards()) {
|
||||
val obj = reward.obj
|
||||
val toGive = skill.getLevelUpReward(obj, to)
|
||||
val toGive = skill.getLevelUpReward(reward, to)
|
||||
|
||||
when (obj) {
|
||||
is Effect -> {
|
||||
|
||||
@@ -5,4 +5,20 @@ import com.willfp.ecoskills.SkillObject
|
||||
data class SkillObjectReward (
|
||||
val obj: SkillObject,
|
||||
val options: SkillObjectOptions
|
||||
)
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is SkillObjectReward) {
|
||||
return false
|
||||
}
|
||||
|
||||
return this.obj == other.obj && this.options.endLevel == other.options.endLevel &&
|
||||
this.options.startLevel == other.options.startLevel
|
||||
&& this.options.amountPerLevel == other.options.amountPerLevel
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = obj.hashCode()
|
||||
result = 31 * result + options.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user