diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/util/PotionUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/util/PotionUtils.java deleted file mode 100644 index f9cba64..0000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/util/PotionUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.ecoskills.util; - -import org.bukkit.potion.PotionData; -import org.jetbrains.annotations.NotNull; - -public class PotionUtils { - /** - * Get potion duration from data. - * - * @param data The data. - * @return The duration in ticks. - */ - public static int getDuration(@NotNull final PotionData data) { - if (data.isExtended()) { - return switch (data.getType()) { - case INSTANT_DAMAGE, INSTANT_HEAL -> 0; - case POISON, REGEN -> 1800; - case SLOW_FALLING, WEAKNESS, SLOWNESS -> 4800; - case TURTLE_MASTER -> 800; - default -> 9600; - }; - } else if (data.isUpgraded()) { - return switch (data.getType()) { - case INSTANT_DAMAGE, INSTANT_HEAL -> 0; - case POISON -> 420; - case REGEN -> 440; - case TURTLE_MASTER, SLOWNESS -> 400; - default -> 1800; - }; - } else { - return switch (data.getType()) { - case INSTANT_DAMAGE, INSTANT_HEAL -> 0; - case POISON, REGEN -> 900; - case TURTLE_MASTER -> 400; - case SLOW_FALLING, WEAKNESS, SLOWNESS -> 1800; - default -> 3600; - }; - } - } -} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/PotionHelper.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/PotionHelper.kt new file mode 100644 index 0000000..ed7f5bb --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/PotionHelper.kt @@ -0,0 +1,33 @@ +package com.willfp.ecoskills + +import org.bukkit.potion.PotionData +import org.bukkit.potion.PotionType + +val PotionData.duration: Int + get() { + if (this.isExtended) { + return when (this.type) { + PotionType.INSTANT_DAMAGE, PotionType.INSTANT_HEAL -> 0 + PotionType.POISON, PotionType.REGEN -> 1800 + PotionType.SLOW_FALLING, PotionType.WEAKNESS, PotionType.SLOWNESS -> 4800 + PotionType.TURTLE_MASTER -> 800 + else -> 9600 + } + } + if (this.isUpgraded) { + return when (this.type) { + PotionType.INSTANT_DAMAGE, PotionType.INSTANT_HEAL -> 0 + PotionType.POISON, PotionType.REGEN -> 420 + PotionType.SLOW_FALLING, PotionType.WEAKNESS, PotionType.SLOWNESS -> 440 + PotionType.TURTLE_MASTER -> 400 + else -> 1800 + } + } + return when (this.type) { + PotionType.INSTANT_DAMAGE, PotionType.INSTANT_HEAL -> 0 + PotionType.POISON, PotionType.REGEN -> 900 + PotionType.SLOW_FALLING, PotionType.WEAKNESS, PotionType.SLOWNESS -> 400 + PotionType.TURTLE_MASTER -> 1800 + else -> 3600 + } + } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectPotionmaster.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectPotionmaster.kt index 680865d..9d1995b 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectPotionmaster.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/effects/effects/EffectPotionmaster.kt @@ -2,9 +2,9 @@ package com.willfp.ecoskills.effects.effects import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.StringUtils +import com.willfp.ecoskills.duration import com.willfp.ecoskills.effects.Effect import com.willfp.ecoskills.getEffectLevel -import com.willfp.ecoskills.util.PotionUtils import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -54,7 +54,7 @@ class EffectPotionmaster : Effect( } } - val duration = PotionUtils.getDuration(potionData) + val duration = potionData.duration val delta = (duration * multiplier).toInt() - duration val secondsDelta = NumberUtils.format(delta / 20.0) @@ -107,7 +107,7 @@ class EffectPotionmaster : Effect( player.addPotionEffect( PotionEffect( k, - PotionUtils.getDuration(data) + delta, + data.duration + delta, v ) ) @@ -144,7 +144,7 @@ class EffectPotionmaster : Effect( entity.addPotionEffect( PotionEffect( key, - ((PotionUtils.getDuration(data) + delta) * event.getIntensity(entity)).toInt(), + ((data.duration + delta) * event.getIntensity(entity)).toInt(), value ) )