diff --git a/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyAddEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyAddEvent.java new file mode 100644 index 0000000..371663e --- /dev/null +++ b/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyAddEvent.java @@ -0,0 +1,87 @@ +package com.Acrobot.ChestShop.Events.Economy; + +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import java.math.BigDecimal; + +/** + * Represents an addition of goods to entity + * + * @author Acrobot + */ +public class CurrencyAddEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + private BigDecimal amount; + private String target; + private World world; + + public CurrencyAddEvent(BigDecimal amount, String target, World world) { + this.amount = amount; + this.target = target; + this.world = world; + } + + public CurrencyAddEvent(BigDecimal amount, Player target) { + this(amount, target.getName(), target.getWorld()); + } + + /** + * @return Amount of currency + */ + public BigDecimal getAmount() { + return amount; + } + + /** + * @return Amount of currency, as a double + * @deprecated Use {@link #getAmount()} if possible + */ + public double getDoubleAmount() { + return amount.doubleValue(); + } + + /** + * Sets the amount of currency transferred + * + * @param amount Amount to transfer + */ + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + /** + * Sets the amount of currency transferred + * + * @param amount Amount to transfer + * @deprecated Use {@link #setAmount(java.math.BigDecimal)} if possible + */ + public void setAmount(double amount) { + this.amount = BigDecimal.valueOf(amount); + } + + /** + * @return The world in which the transaction occurs + */ + public World getWorld() { + return world; + } + + /** + * @return Account from which the currency is subtracted + */ + public String getTarget() { + return target; + } + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyFormatEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyFormatEvent.java new file mode 100644 index 0000000..ccd455f --- /dev/null +++ b/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyFormatEvent.java @@ -0,0 +1,61 @@ +package com.Acrobot.ChestShop.Events.Economy; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import java.math.BigDecimal; + +/** + * Represents a moment when the currency needs to be shown + * + * @author Acrobot + */ +public class CurrencyFormatEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + private final BigDecimal amount; + private String formattedAmount; + + public CurrencyFormatEvent(BigDecimal amount) { + this.amount = amount; + } + + /** + * @return Amount of currency + */ + public BigDecimal getAmount() { + return amount; + } + + /** + * @return Amount of currency, as a double + * @deprecated Use {@link #getAmount()} if possible + */ + public double getDoubleAmount() { + return amount.doubleValue(); + } + + /** + * @return Already formatted currency amount + */ + public String getFormattedAmount() { + return formattedAmount; + } + + /** + * Sets the currency formatting + * + * @param formattedAmount Formatted amount + */ + public void setFormattedAmount(String formattedAmount) { + this.formattedAmount = formattedAmount; + } + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencySubtractEvent.java b/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencySubtractEvent.java new file mode 100644 index 0000000..4c9cac0 --- /dev/null +++ b/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencySubtractEvent.java @@ -0,0 +1,87 @@ +package com.Acrobot.ChestShop.Events.Economy; + +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import java.math.BigDecimal; + +/** + * Represents a subtraction of goods from entity + * + * @author Acrobot + */ +public class CurrencySubtractEvent extends Event { + private static final HandlerList handlers = new HandlerList(); + + private BigDecimal amount; + private String target; + private World world; + + public CurrencySubtractEvent(BigDecimal amount, String target, World world) { + this.amount = amount; + this.target = target; + this.world = world; + } + + public CurrencySubtractEvent(BigDecimal amount, Player target) { + this(amount, target.getName(), target.getWorld()); + } + + /** + * @return Amount of currency + */ + public BigDecimal getAmount() { + return amount; + } + + /** + * @return Amount of currency, as a double + * @deprecated Use {@link #getAmount()} if possible + */ + public double getDoubleAmount() { + return amount.doubleValue(); + } + + /** + * Sets the amount of currency transferred + * + * @param amount Amount to transfer + */ + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + /** + * Sets the amount of currency transferred + * + * @param amount Amount to transfer + * @deprecated Use {@link #setAmount(java.math.BigDecimal)} if possible + */ + public void setAmount(double amount) { + this.amount = BigDecimal.valueOf(amount); + } + + /** + * @return The world in which the transaction occurs + */ + public World getWorld() { + return world; + } + + /** + * @return Account from which the currency is subtracted + */ + public String getTarget() { + return target; + } + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +}