Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/com/Zrips/CMI/Modules/Worth/WorthEnchantment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,105 @@

public class WorthEnchantment {

/**
* The sell price.
*/
private Double sellPrice = 0D;

/**
* The buy price.
*/
private Double buyPrice = null;

/**
* The level.
*/
private Integer level = null;

/**
* The enchantment.
*/
private Enchantment enchant;

/**
* Create a new worth value for the given enchantment, level, sell price
* and buy price.
*
* @param enchant the enchantment to use.
* @param level the level to use.
* @param sellPrice the sell price.
* @param buyPrice the buy price.
*/
public WorthEnchantment(Enchantment enchant, int level, double sellPrice, Double buyPrice) {
this.enchant = enchant;
this.level = level;
this.sellPrice = sellPrice;
this.buyPrice = buyPrice;
}

/**
* Return the enchantment's sell price.
*
* @return the sell price.
*/
public Double getSellPrice() {
return sellPrice;
}

/**
* Set the enchantment's sell price.
*
* @param price the new sell price.
*/
public void setSellPrice(double price) {
this.sellPrice = price;
if (this.sellPrice < 0D)
this.sellPrice = 0D;
}

/**
* Return the enchantment's buy price.
*
* @return the buy price, or the sell price if it's null.
*/
public Double getBuyPrice() {
return buyPrice == null ? sellPrice : buyPrice;
}

/**
* Return if the enchantment's buy price has been set.
*
* @return true if the buy price has been set.
*/
public boolean isBuyPriceSet() {
return buyPrice != null;
}

/**
* Set the enchantment's buy price.
*
* @param buyPrice the new buy price.
*/
public void setBuyPrice(Double buyPrice) {
this.buyPrice = buyPrice;
if (this.buyPrice != null && this.buyPrice < 0D)
this.buyPrice = null;
}

/**
* Return the enchantment.
*
* @return the enchantment.
*/
public Enchantment getEnchant() {
return enchant;
}

/**
* Return the enchantment's level.
*
* @return the level.
*/
public Integer getLevel() {
return level;
}
Expand Down