Add Currency events

This commit is contained in:
Acrobot 2013-05-03 01:57:09 +02:00
parent f94ef396f0
commit a9102227f6
2 changed files with 105 additions and 1 deletions

View File

@ -1,7 +1,82 @@
package com.Acrobot.ChestShop.Events.Economy; package com.Acrobot.ChestShop.Events.Economy;
import org.bukkit.World;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.math.BigDecimal;
/** /**
* Represents a check for the existance of specified currency amount
*
* @author Acrobot * @author Acrobot
*/ */
public class CurrencyCheckEvent { public class CurrencyCheckEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private BigDecimal amount;
private String account;
private World world;
public CurrencyCheckEvent(BigDecimal amount, String account, World world) {
this.amount = amount;
this.account = account;
this.world = world;
}
/**
* @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 that is checked
*/
public String getAccount() {
return account;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -7,6 +7,8 @@ import org.bukkit.event.HandlerList;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* Represents a transaction of goods between two entities
*
* @author Acrobot * @author Acrobot
*/ */
public class CurrencyTransferEvent extends Event { public class CurrencyTransferEvent extends Event {
@ -29,30 +31,57 @@ public class CurrencyTransferEvent extends Event {
this(BigDecimal.valueOf(amount), sender, receiver, world); this(BigDecimal.valueOf(amount), sender, receiver, world);
} }
/**
* @return Amount of currency
*/
public BigDecimal getAmount() { public BigDecimal getAmount() {
return amount; return amount;
} }
/**
* @return Amount of currency, as a double
* @deprecated Use {@link #getAmount()} if possible
*/
public double getDoubleAmount() { public double getDoubleAmount() {
return amount.doubleValue(); return amount.doubleValue();
} }
/**
* Sets the amount of currency transferred
*
* @param amount Amount to transfer
*/
public void setAmount(BigDecimal amount) { public void setAmount(BigDecimal amount) {
this.amount = 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) { public void setAmount(double amount) {
this.amount = BigDecimal.valueOf(amount); this.amount = BigDecimal.valueOf(amount);
} }
/**
* @return The world in which the transaction occurs
*/
public World getWorld() { public World getWorld() {
return world; return world;
} }
/**
* @return Sender of the money
*/
public String getSender() { public String getSender() {
return sender; return sender;
} }
/**
* @return Receiver of the money
*/
public String getReceiver() { public String getReceiver() {
return receiver; return receiver;
} }