Add more Currency events

This commit is contained in:
Acrobot 2013-05-07 18:37:46 +02:00
parent a9102227f6
commit 4b166bb801
3 changed files with 235 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}