Add EnchantmentOffer to PrepareItemEnchantEvent

By: LukBukkit <luk.bukkit@gmail.com>
This commit is contained in:
Bukkit/Spigot
2016-11-27 20:48:06 +01:00
parent 1630d4344b
commit 70550c8dce
2 changed files with 107 additions and 8 deletions

View File

@@ -0,0 +1,81 @@
package org.bukkit.enchantments;
import org.apache.commons.lang.Validate;
/**
* A class for the available enchantment offers in the enchantment table.
*/
public class EnchantmentOffer {
private Enchantment enchantment;
private int enchantmentLevel;
private int cost;
public EnchantmentOffer(Enchantment enchantment, int enchantmentLevel, int cost) {
this.enchantment = enchantment;
this.enchantmentLevel = enchantmentLevel;
this.cost = cost;
}
/**
* Get the type of the enchantment.
*
* @return type of enchantment
*/
public Enchantment getEnchantment() {
return enchantment;
}
/**
* Sets the type of the enchantment.
*
* @param enchantment type of the enchantment
*/
public void setEnchantment(Enchantment enchantment) {
Validate.notNull(enchantment, "The enchantment may not be null!");
this.enchantment = enchantment;
}
/**
* Gets the level of the enchantment.
*
* @return level of the enchantment
*/
public int getEnchantmentLevel() {
return enchantmentLevel;
}
/**
* Sets the level of the enchantment.
*
* @param enchantmentLevel level of the enchantment
*/
public void setEnchantmentLevel(int enchantmentLevel) {
Validate.isTrue(enchantmentLevel > 0, "The enchantment level must be greater than 0!");
this.enchantmentLevel = enchantmentLevel;
}
/**
* Gets the cost in experience levels the player has to pay to enchant his
* item with this enchantment.
*
* @return cost for this enchantment
*/
public int getCost() {
return cost;
}
/**
* Sets the cost in experience levels the player has to pay to enchant his
* item with this enchantment
*
* @param cost cost for this enchantment
*/
public void setCost(int cost) {
Validate.isTrue(cost > 0, "The cost must be greater than 0!");
this.cost = cost;
}
}