diff --git a/eco-api/src/main/java/com/willfp/eco/core/integrations/shop/ShopSellEvent.java b/eco-api/src/main/java/com/willfp/eco/core/integrations/shop/ShopSellEvent.java index 3885e523..8192edea 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/integrations/shop/ShopSellEvent.java +++ b/eco-api/src/main/java/com/willfp/eco/core/integrations/shop/ShopSellEvent.java @@ -1,5 +1,7 @@ package com.willfp.eco.core.integrations.shop; +import com.willfp.eco.core.price.Price; +import com.willfp.eco.core.price.impl.PriceEconomy; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; @@ -19,7 +21,7 @@ public class ShopSellEvent extends PlayerEvent { /** * The sell price. */ - private double price; + private Price price; /** * The item to be sold. @@ -33,32 +35,79 @@ public class ShopSellEvent extends PlayerEvent { * @param who The player. * @param price The price. * @param item The item. + * @deprecated Use the price system instead. */ + @Deprecated(since = "6.47.0", forRemoval = true) public ShopSellEvent(@NotNull final Player who, final double price, @Nullable final ItemStack item) { + this(who, new PriceEconomy(price), item); + } + + /** + * Create new shop sell event. + * + * @param who The player. + * @param price The price. + * @param item The item. + */ + public ShopSellEvent(@NotNull final Player who, + @NotNull final Price price, + @Nullable final ItemStack item) { super(who); this.price = price; this.item = item; } + /** + * Get the value. + * + * @return The value. + */ + @NotNull + public Price getValue() { + return this.price; + } + + /** + * Set the value. + * + * @param price The value. + */ + public void setValue(@NotNull final Price price) { + this.price = price; + } + + /** + * Multiply the value by a certain amount. + * + * @param multiplier The multiplier. + */ + public void multiplyValueBy(final double multiplier) { + this.price = this.price.withMultiplier(multiplier); + } + /** * Get the price. * * @return The price. + * @deprecated Use the price system instead. */ + @Deprecated(since = "6.47.0", forRemoval = true) public double getPrice() { - return this.price; + return this.getValue().getValue(player); } /** * Set the price. * * @param price The price. + * @deprecated Use the price system instead. */ + @Deprecated(since = "6.47.0", forRemoval = true) public void setPrice(final double price) { - this.price = price; + this.setValue(new PriceEconomy(price)); } /** diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopDeluxeSellwands.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopDeluxeSellwands.kt index 4b543266..f601079f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopDeluxeSellwands.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopDeluxeSellwands.kt @@ -2,6 +2,7 @@ package com.willfp.eco.internal.spigot.integrations.shop import com.willfp.eco.core.integrations.shop.ShopIntegration import com.willfp.eco.core.integrations.shop.ShopSellEvent +import com.willfp.eco.core.price.impl.PriceEconomy import dev.norska.dsw.api.DeluxeSellwandSellEvent import org.bukkit.Bukkit import org.bukkit.event.EventHandler @@ -19,9 +20,9 @@ class ShopDeluxeSellwands : ShopIntegration { return } - val ecoEvent = ShopSellEvent(event.player, event.money, null) + val ecoEvent = ShopSellEvent(event.player, PriceEconomy(event.money), null) Bukkit.getPluginManager().callEvent(ecoEvent) - event.money = ecoEvent.price + event.money = ecoEvent.value.getValue(event.player) } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopEconomyShopGUI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopEconomyShopGUI.kt index 8c0696f0..4e543418 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopEconomyShopGUI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopEconomyShopGUI.kt @@ -34,9 +34,9 @@ class ShopEconomyShopGUI : ShopIntegration { return } - val ecoEvent = ShopSellEvent(event.player, event.price, event.itemStack) + val ecoEvent = ShopSellEvent(event.player, PriceEconomy(event.price), event.itemStack) Bukkit.getPluginManager().callEvent(ecoEvent) - event.price = ecoEvent.price + event.price = ecoEvent.value.getValue(event.player) } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopShopGuiPlus.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopShopGuiPlus.kt index f13412b6..4957eb10 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopShopGuiPlus.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopShopGuiPlus.kt @@ -63,9 +63,9 @@ class ShopShopGuiPlus : ShopIntegration { return } - val ecoEvent = ShopSellEvent(event.player, event.price, event.shopItem.item) + val ecoEvent = ShopSellEvent(event.player, PriceEconomy(event.price), event.shopItem.item) Bukkit.getPluginManager().callEvent(ecoEvent) - event.price = ecoEvent.price + event.price = ecoEvent.value.getValue(event.player) } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopZShop.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopZShop.kt index 5d0982fc..f8bb4a8d 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopZShop.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/integrations/shop/ShopZShop.kt @@ -2,6 +2,7 @@ package com.willfp.eco.internal.spigot.integrations.shop import com.willfp.eco.core.integrations.shop.ShopIntegration import com.willfp.eco.core.integrations.shop.ShopSellEvent +import com.willfp.eco.core.price.impl.PriceEconomy import fr.maxlego08.shop.api.events.ZShopSellEvent import org.bukkit.Bukkit import org.bukkit.event.EventHandler @@ -19,9 +20,9 @@ class ShopZShop : ShopIntegration { return } - val ecoEvent = ShopSellEvent(event.player, event.price, event.button.itemStack) + val ecoEvent = ShopSellEvent(event.player, PriceEconomy(event.price), event.button.itemStack) Bukkit.getPluginManager().callEvent(ecoEvent) - event.price = ecoEvent.price + event.price = ecoEvent.value.getValue(event.player) } }