9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2025-12-31 21:06:40 +00:00

Changed Potionmaster

This commit is contained in:
Auxilor
2021-09-30 12:34:17 +01:00
parent c089a854e6
commit 08076996b8
3 changed files with 37 additions and 44 deletions

View File

@@ -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;
};
}
}
}

View File

@@ -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
}
}

View File

@@ -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
)
)