Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ public interface ConfigManager extends DamageManager {
* @return auto save time
*/
long autoSaveTime();

/**
* Checks if decimal damage display is enabled
* Default: false
* @return decimal damage
*/
boolean showDecimalDamage();
/**
* Gets default damage effect
* @return default damage effect
Expand Down
17 changes: 13 additions & 4 deletions core/src/main/kotlin/kr/toxicity/damage/effect/DamageEffectImpl.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kr.toxicity.damage.effect

import kr.toxicity.damage.api.BetterDamage
import kr.toxicity.damage.api.effect.DamageEffect
import kr.toxicity.damage.api.effect.DamageEffectCounter
import kr.toxicity.damage.api.equation.TEquation
Expand Down Expand Up @@ -38,8 +39,12 @@ class DamageEffectImpl(section: ConfigurationSection) : DamageEffect {
private val opacity = section.getAsEquation("opacity") ?: TEquation.FULL_OPACITY
private val counter = DamageEffectCounter()
private val numberFormat = runCatching {
DecimalFormat(section.getString("number-format", "#"))
}.getOrNull() ?: DecimalFormat("#")
if (section.isSet("number-format")) {
DecimalFormat(section.getString("number-format", "#"))
} else {
null
}
}.getOrNull()

override fun image(): DamageImage = image
override fun duration(): Int = duration
Expand All @@ -53,5 +58,9 @@ class DamageEffectImpl(section: ConfigurationSection) : DamageEffect {
override fun skyLight(): TEquation = skyLight
override fun counter(): DamageEffectCounter = counter
override fun opacity(): TEquation = opacity
override fun numberFormat(): NumberFormat = numberFormat
}
override fun numberFormat(): NumberFormat = numberFormat ?: if (BetterDamage.inst().configManager().showDecimalDamage()) {
DecimalFormat("#.#") // Format avec une décimale si l'option est activée
} else {
DecimalFormat("#") // Format entier par défaut
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ object ConfigManagerImpl : ConfigManager {
private var packType = "zip"
private var createMcmeta = false
private var autoSaveTime = 300L * 20
private var showDecimalDamage = false
private var effectSupplier: () -> DamageEffect? = {
null
}
Expand All @@ -46,6 +47,7 @@ object ConfigManagerImpl : ConfigManager {
packType = getString("pack-type") ?: "zip"
createMcmeta = getBoolean("create-mcmeta")
autoSaveTime = getLong("auto-save-time", 300) * 20
showDecimalDamage = getBoolean("show-decimal-damage", false)
effectSupplier = (getString("default-effect") ?: "default_effect").let {
{
EffectManagerImpl.effect(it)
Expand Down Expand Up @@ -84,6 +86,7 @@ object ConfigManagerImpl : ConfigManager {
override fun createMcmeta(): Boolean = createMcmeta
override fun autoSaveTime(): Long = autoSaveTime
override fun metrics(): Boolean = metrics != null
override fun showDecimalDamage(): Boolean = showDecimalDamage
override fun defaultEffect(): DamageEffect? = effectSupplier()
override fun defaultSkin(): DamageSkin? = skinSupplier()
}
}
3 changes: 2 additions & 1 deletion core/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pack-type: zip #folder, zip
create-mcmeta: false
auto-save-time: 300
default-effect: "null" #Default effect
default-skin: "default_skin"
default-skin: "default_skin"
show-decimal-damage: false
21 changes: 20 additions & 1 deletion core/src/main/resources/default/effects/default_effect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,23 @@ default_effect_crit:
scale: #1.5 to 0
x: 1.5cos(t / 40 * pi)
y: 1.5cos(t / 40 * pi)
z: 1.5cos(t / 40 * pi)
z: 1.5cos(t / 40 * pi)
default_effect_decimal:
image: default_image
duration: 20
interval: 2
number-format: "#.#"
color: "#FFD800"
transformation:
position:
x: 0
y: 1.5sin(t / 40 * pi)
z: 0
rotation:
x: 60(r - 0.5)
z: 0
y: 60(r - 0.5)
scale:
x: cos(t / 40 * pi)
y: cos(t / 40 * pi)
z: cos(t / 40 * pi)
3 changes: 2 additions & 1 deletion core/src/main/resources/default/images/default_image.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
default_image:
file: "default.png"
space: -2
codepoints: "0123456789."
space: -2