ChestShop-3/src/main/java/com/Acrobot/ChestShop/Events/Economy/CurrencyCheckEvent.java

119 lines
2.6 KiB
Java
Raw Normal View History

2013-05-03 01:56:43 +02:00
package com.Acrobot.ChestShop.Events.Economy;
2013-05-03 01:57:09 +02:00
import org.bukkit.World;
import org.bukkit.entity.Player;
2013-05-03 01:57:09 +02:00
import org.bukkit.event.HandlerList;
import java.math.BigDecimal;
2014-06-14 20:46:59 +02:00
import java.util.UUID;
2013-05-03 01:57:09 +02:00
2013-05-03 01:56:43 +02:00
/**
* Represents a check for the existence of specified currency amount
2013-05-03 01:57:09 +02:00
*
2013-05-03 01:56:43 +02:00
* @author Acrobot
*/
public class CurrencyCheckEvent extends EconomicEvent {
2013-05-03 01:57:09 +02:00
private static final HandlerList handlers = new HandlerList();
private boolean outcome = false;
2013-05-30 16:58:22 +02:00
2013-05-03 01:57:09 +02:00
private BigDecimal amount;
2014-06-14 20:46:59 +02:00
private UUID account;
2013-05-03 01:57:09 +02:00
private World world;
2014-06-14 20:46:59 +02:00
public CurrencyCheckEvent(BigDecimal amount, UUID account, World world) {
2013-05-03 01:57:09 +02:00
this.amount = amount;
this.account = account;
this.world = world;
}
public CurrencyCheckEvent(BigDecimal amount, Player player) {
2014-06-14 20:46:59 +02:00
this(amount, player.getUniqueId(), player.getWorld());
}
2013-05-30 16:58:22 +02:00
/**
* @return Does the account have enough currency available?
*/
public boolean hasEnough() {
2013-05-30 16:58:22 +02:00
return outcome;
}
/**
* Sets if the account holds enough currency
*
* @param outcome Outcome of the currency check
*/
public void hasEnough(boolean outcome) {
this.outcome = outcome;
}
2013-05-03 01:57:09 +02:00
/**
* @return Amount of currency
*/
public BigDecimal getAmount() {
return amount;
}
/**
* @return Amount of currency, as a double
* @deprecated Use {@link #getAmount()} if possible
*/
@Deprecated
2013-05-03 01:57:09 +02:00
public double getDoubleAmount() {
return amount.doubleValue();
}
/**
* Sets the amount of currency transferred
*
* @param amount Amount to transfer
* @deprecated The amount should not be changed!
2013-05-03 01:57:09 +02:00
*/
@Deprecated
2013-05-03 01:57:09 +02:00
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
/**
* Sets the amount of currency transferred
*
* @param amount Amount to transfer
* @deprecated The amount should not be changed! Use {@link #setAmount(java.math.BigDecimal)} if possible
2013-05-03 01:57:09 +02:00
*/
@Deprecated
2013-05-03 01:57:09 +02:00
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 that is checked
*/
2014-06-14 20:46:59 +02:00
public UUID getAccount() {
2013-05-03 01:57:09 +02:00
return account;
}
2013-05-30 16:58:22 +02:00
/**
* Sets the account name
*
* @param account Account name
*/
2014-06-14 20:46:59 +02:00
public void setAccount(UUID account) {
2013-05-30 16:58:22 +02:00
this.account = account;
}
2013-05-03 01:57:09 +02:00
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
2013-05-03 01:56:43 +02:00
}