Add the long-awaited Enchantment::registerEnchantment() API method

api3/blocks users: I am sorry I kept you waiting so long
This commit is contained in:
Dylan K. Taylor 2017-10-09 11:40:53 +01:00
parent 9598b8cee4
commit 6dbdefafdd

View File

@ -89,9 +89,18 @@ class Enchantment{
public static function init(){
self::$enchantments = new \SplFixedArray(256);
self::$enchantments[self::PROTECTION] = new Enchantment(self::PROTECTION, "%enchantment.protect.all", self::RARITY_COMMON, self::ACTIVATION_EQUIP, self::SLOT_ARMOR);
self::$enchantments[self::FIRE_PROTECTION] = new Enchantment(self::FIRE_PROTECTION, "%enchantment.protect.fire", self::RARITY_UNCOMMON, self::ACTIVATION_EQUIP, self::SLOT_ARMOR);
self::$enchantments[self::FEATHER_FALLING] = new Enchantment(self::FEATHER_FALLING, "%enchantment.protect.fall", self::RARITY_UNCOMMON, self::ACTIVATION_EQUIP, self::SLOT_FEET);
self::registerEnchantment(new Enchantment(self::PROTECTION, "%enchantment.protect.all", self::RARITY_COMMON, self::ACTIVATION_EQUIP, self::SLOT_ARMOR));
self::registerEnchantment(new Enchantment(self::FIRE_PROTECTION, "%enchantment.protect.fire", self::RARITY_UNCOMMON, self::ACTIVATION_EQUIP, self::SLOT_ARMOR));
self::registerEnchantment(new Enchantment(self::FEATHER_FALLING, "%enchantment.protect.fall", self::RARITY_UNCOMMON, self::ACTIVATION_EQUIP, self::SLOT_FEET));
}
/**
* Registers an enchantment type.
*
* @param Enchantment $enchantment
*/
public static function registerEnchantment(Enchantment $enchantment) : void{
self::$enchantments[$enchantment->getId()] = clone $enchantment;
}
/**