mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-24 17:17:49 +01:00
Add more Currency events
This commit is contained in:
parent
a9102227f6
commit
4b166bb801
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user