mirror of
https://github.com/Auxilor/EcoBits.git
synced 2025-12-19 15:09:19 +00:00
Updated Price API
This commit is contained in:
@@ -44,7 +44,7 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'com.willfp:eco:6.46.0'
|
compileOnly 'com.willfp:eco:6.47.0'
|
||||||
|
|
||||||
compileOnly 'org.jetbrains:annotations:23.0.0'
|
compileOnly 'org.jetbrains:annotations:23.0.0'
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ version rootProject.version
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
|
||||||
compileOnly "com.github.MilkBowl:VaultAPI:1.7"
|
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
|
||||||
|
|
||||||
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
|
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.willfp.eco.core.price.PriceFactory
|
|||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import java.util.function.Function
|
import java.util.function.Function
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
class PriceFactoryCurrency(
|
class PriceFactoryCurrency(
|
||||||
private val currency: Currency
|
private val currency: Currency
|
||||||
@@ -26,19 +25,17 @@ class PriceFactoryCurrency(
|
|||||||
) : Price {
|
) : Price {
|
||||||
private val multipliers = mutableMapOf<UUID, Double>()
|
private val multipliers = mutableMapOf<UUID, Double>()
|
||||||
|
|
||||||
override fun canAfford(player: Player) = player.getBalance(currency) >= getValue(player)
|
override fun canAfford(player: Player, multiplier: Double) =
|
||||||
|
player.getBalance(currency) >= getValue(player, multiplier)
|
||||||
|
|
||||||
override fun pay(player: Player) {
|
override fun pay(player: Player, multiplier: Double) =
|
||||||
player.adjustBalance(currency, -getValue(player))
|
player.adjustBalance(currency, -getValue(player, multiplier))
|
||||||
}
|
|
||||||
|
|
||||||
override fun giveTo(player: Player) {
|
override fun giveTo(player: Player, multiplier: Double) =
|
||||||
player.adjustBalance(currency, getValue(player))
|
player.adjustBalance(currency, getValue(player, multiplier))
|
||||||
}
|
|
||||||
|
|
||||||
override fun getValue(player: Player): Double {
|
override fun getValue(player: Player, multiplier: Double) =
|
||||||
return xp(MathContext.copyWithPlayer(baseContext, player)) * getMultiplier(player)
|
xp(MathContext.copyWithPlayer(baseContext, player)) * getMultiplier(player) * multiplier
|
||||||
}
|
|
||||||
|
|
||||||
override fun getMultiplier(player: Player): Double {
|
override fun getMultiplier(player: Player): Double {
|
||||||
return multipliers[player.uniqueId] ?: 1.0
|
return multipliers[player.uniqueId] ?: 1.0
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
version = 1.3.0
|
version = 1.4.0
|
||||||
plugin-name = EcoBits
|
plugin-name = EcoBits
|
||||||
|
|||||||
Reference in New Issue
Block a user