mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Make Effect and Enchantment functions less verbose
This commit is contained in:
parent
01904adf49
commit
ad19696364
@ -69,10 +69,10 @@ class EffectCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
$effect = Effect::getEffectByName($args[1]);
|
||||
$effect = Effect::fromString($args[1]);
|
||||
|
||||
if($effect === null){
|
||||
$effect = Effect::getEffect((int) $args[1]);
|
||||
$effect = Effect::get((int) $args[1]);
|
||||
}
|
||||
|
||||
if($effect === null){
|
||||
|
@ -67,9 +67,9 @@ class EnchantCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
if(is_numeric($args[1])){
|
||||
$enchantment = Enchantment::getEnchantment((int) $args[1]);
|
||||
$enchantment = Enchantment::get((int) $args[1]);
|
||||
}else{
|
||||
$enchantment = Enchantment::getEnchantmentByName($args[1]);
|
||||
$enchantment = Enchantment::fromString($args[1]);
|
||||
}
|
||||
|
||||
if(!($enchantment instanceof Enchantment)){
|
||||
|
@ -121,7 +121,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
$activeEffectsTag = $nbt->getListTag("ActiveEffects");
|
||||
if($activeEffectsTag !== null){
|
||||
foreach($activeEffectsTag as $e){
|
||||
$effect = Effect::getEffect($e->getByte("Id"));
|
||||
$effect = Effect::get($e->getByte("Id"));
|
||||
if($effect === null){
|
||||
continue;
|
||||
}
|
||||
|
@ -64,144 +64,144 @@ class Effect{
|
||||
protected static $effects = [];
|
||||
|
||||
public static function init() : void{
|
||||
self::registerEffect(new SpeedEffect(Effect::SPEED, "%potion.moveSpeed", new Color(0x7c, 0xaf, 0xc6)));
|
||||
self::registerEffect(new SlownessEffect(Effect::SLOWNESS, "%potion.moveSlowdown", new Color(0x5a, 0x6c, 0x81), true));
|
||||
self::registerEffect(new Effect(Effect::HASTE, "%potion.digSpeed", new Color(0xd9, 0xc0, 0x43)));
|
||||
self::registerEffect(new Effect(Effect::MINING_FATIGUE, "%potion.digSlowDown", new Color(0x4a, 0x42, 0x17), true));
|
||||
self::registerEffect(new Effect(Effect::STRENGTH, "%potion.damageBoost", new Color(0x93, 0x24, 0x23)));
|
||||
self::registerEffect(new InstantHealthEffect(Effect::INSTANT_HEALTH, "%potion.heal", new Color(0xf8, 0x24, 0x23), false, false));
|
||||
self::registerEffect(new InstantDamageEffect(Effect::INSTANT_DAMAGE, "%potion.harm", new Color(0x43, 0x0a, 0x09), true, false));
|
||||
self::registerEffect(new Effect(Effect::JUMP_BOOST, "%potion.jump", new Color(0x22, 0xff, 0x4c)));
|
||||
self::registerEffect(new Effect(Effect::NAUSEA, "%potion.confusion", new Color(0x55, 0x1d, 0x4a), true));
|
||||
self::registerEffect(new RegenerationEffect(Effect::REGENERATION, "%potion.regeneration", new Color(0xcd, 0x5c, 0xab)));
|
||||
self::registerEffect(new Effect(Effect::RESISTANCE, "%potion.resistance", new Color(0x99, 0x45, 0x3a)));
|
||||
self::registerEffect(new Effect(Effect::FIRE_RESISTANCE, "%potion.fireResistance", new Color(0xe4, 0x9a, 0x3a)));
|
||||
self::registerEffect(new Effect(Effect::WATER_BREATHING, "%potion.waterBreathing", new Color(0x2e, 0x52, 0x99)));
|
||||
self::registerEffect(new InvisibilityEffect(Effect::INVISIBILITY, "%potion.invisibility", new Color(0x7f, 0x83, 0x92)));
|
||||
self::registerEffect(new Effect(Effect::BLINDNESS, "%potion.blindness", new Color(0x1f, 0x1f, 0x23), true));
|
||||
self::registerEffect(new Effect(Effect::NIGHT_VISION, "%potion.nightVision", new Color(0x1f, 0x1f, 0xa1)));
|
||||
self::registerEffect(new HungerEffect(Effect::HUNGER, "%potion.hunger", new Color(0x58, 0x76, 0x53), true));
|
||||
self::registerEffect(new Effect(Effect::WEAKNESS, "%potion.weakness", new Color(0x48, 0x4d, 0x48), true));
|
||||
self::registerEffect(new PoisonEffect(Effect::POISON, "%potion.poison", new Color(0x4e, 0x93, 0x31), true));
|
||||
self::registerEffect(new WitherEffect(Effect::WITHER, "%potion.wither", new Color(0x35, 0x2a, 0x27), true));
|
||||
self::registerEffect(new HealthBoostEffect(Effect::HEALTH_BOOST, "%potion.healthBoost", new Color(0xf8, 0x7d, 0x23)));
|
||||
self::registerEffect(new AbsorptionEffect(Effect::ABSORPTION, "%potion.absorption", new Color(0x25, 0x52, 0xa5)));
|
||||
self::registerEffect(new SaturationEffect(Effect::SATURATION, "%potion.saturation", new Color(0xf8, 0x24, 0x23), false));
|
||||
self::registerEffect(new LevitationEffect(Effect::LEVITATION, "%potion.levitation", new Color(0xce, 0xff, 0xff)));
|
||||
self::registerEffect(new PoisonEffect(Effect::FATAL_POISON, "%potion.poison", new Color(0x4e, 0x93, 0x31), true, true, true));
|
||||
self::registerEffect(new Effect(Effect::CONDUIT_POWER, "%potion.conduitPower", new Color(0x1d, 0xc2, 0xd1)));
|
||||
self::register(new SpeedEffect(Effect::SPEED, "%potion.moveSpeed", new Color(0x7c, 0xaf, 0xc6)));
|
||||
self::register(new SlownessEffect(Effect::SLOWNESS, "%potion.moveSlowdown", new Color(0x5a, 0x6c, 0x81), true));
|
||||
self::register(new Effect(Effect::HASTE, "%potion.digSpeed", new Color(0xd9, 0xc0, 0x43)));
|
||||
self::register(new Effect(Effect::MINING_FATIGUE, "%potion.digSlowDown", new Color(0x4a, 0x42, 0x17), true));
|
||||
self::register(new Effect(Effect::STRENGTH, "%potion.damageBoost", new Color(0x93, 0x24, 0x23)));
|
||||
self::register(new InstantHealthEffect(Effect::INSTANT_HEALTH, "%potion.heal", new Color(0xf8, 0x24, 0x23), false, false));
|
||||
self::register(new InstantDamageEffect(Effect::INSTANT_DAMAGE, "%potion.harm", new Color(0x43, 0x0a, 0x09), true, false));
|
||||
self::register(new Effect(Effect::JUMP_BOOST, "%potion.jump", new Color(0x22, 0xff, 0x4c)));
|
||||
self::register(new Effect(Effect::NAUSEA, "%potion.confusion", new Color(0x55, 0x1d, 0x4a), true));
|
||||
self::register(new RegenerationEffect(Effect::REGENERATION, "%potion.regeneration", new Color(0xcd, 0x5c, 0xab)));
|
||||
self::register(new Effect(Effect::RESISTANCE, "%potion.resistance", new Color(0x99, 0x45, 0x3a)));
|
||||
self::register(new Effect(Effect::FIRE_RESISTANCE, "%potion.fireResistance", new Color(0xe4, 0x9a, 0x3a)));
|
||||
self::register(new Effect(Effect::WATER_BREATHING, "%potion.waterBreathing", new Color(0x2e, 0x52, 0x99)));
|
||||
self::register(new InvisibilityEffect(Effect::INVISIBILITY, "%potion.invisibility", new Color(0x7f, 0x83, 0x92)));
|
||||
self::register(new Effect(Effect::BLINDNESS, "%potion.blindness", new Color(0x1f, 0x1f, 0x23), true));
|
||||
self::register(new Effect(Effect::NIGHT_VISION, "%potion.nightVision", new Color(0x1f, 0x1f, 0xa1)));
|
||||
self::register(new HungerEffect(Effect::HUNGER, "%potion.hunger", new Color(0x58, 0x76, 0x53), true));
|
||||
self::register(new Effect(Effect::WEAKNESS, "%potion.weakness", new Color(0x48, 0x4d, 0x48), true));
|
||||
self::register(new PoisonEffect(Effect::POISON, "%potion.poison", new Color(0x4e, 0x93, 0x31), true));
|
||||
self::register(new WitherEffect(Effect::WITHER, "%potion.wither", new Color(0x35, 0x2a, 0x27), true));
|
||||
self::register(new HealthBoostEffect(Effect::HEALTH_BOOST, "%potion.healthBoost", new Color(0xf8, 0x7d, 0x23)));
|
||||
self::register(new AbsorptionEffect(Effect::ABSORPTION, "%potion.absorption", new Color(0x25, 0x52, 0xa5)));
|
||||
self::register(new SaturationEffect(Effect::SATURATION, "%potion.saturation", new Color(0xf8, 0x24, 0x23), false));
|
||||
self::register(new LevitationEffect(Effect::LEVITATION, "%potion.levitation", new Color(0xce, 0xff, 0xff)));
|
||||
self::register(new PoisonEffect(Effect::FATAL_POISON, "%potion.poison", new Color(0x4e, 0x93, 0x31), true, true, true));
|
||||
self::register(new Effect(Effect::CONDUIT_POWER, "%potion.conduitPower", new Color(0x1d, 0xc2, 0xd1)));
|
||||
}
|
||||
|
||||
/* auto-generated code */
|
||||
|
||||
public static function ABSORPTION() : Effect{
|
||||
return self::getEffect(Effect::ABSORPTION);
|
||||
return self::get(Effect::ABSORPTION);
|
||||
}
|
||||
|
||||
public static function BLINDNESS() : Effect{
|
||||
return self::getEffect(Effect::BLINDNESS);
|
||||
return self::get(Effect::BLINDNESS);
|
||||
}
|
||||
|
||||
public static function CONDUIT_POWER() : Effect{
|
||||
return self::getEffect(Effect::CONDUIT_POWER);
|
||||
return self::get(Effect::CONDUIT_POWER);
|
||||
}
|
||||
|
||||
public static function FATAL_POISON() : Effect{
|
||||
return self::getEffect(Effect::FATAL_POISON);
|
||||
return self::get(Effect::FATAL_POISON);
|
||||
}
|
||||
|
||||
public static function FIRE_RESISTANCE() : Effect{
|
||||
return self::getEffect(Effect::FIRE_RESISTANCE);
|
||||
return self::get(Effect::FIRE_RESISTANCE);
|
||||
}
|
||||
|
||||
public static function HASTE() : Effect{
|
||||
return self::getEffect(Effect::HASTE);
|
||||
return self::get(Effect::HASTE);
|
||||
}
|
||||
|
||||
public static function HEALTH_BOOST() : Effect{
|
||||
return self::getEffect(Effect::HEALTH_BOOST);
|
||||
return self::get(Effect::HEALTH_BOOST);
|
||||
}
|
||||
|
||||
public static function HUNGER() : Effect{
|
||||
return self::getEffect(Effect::HUNGER);
|
||||
return self::get(Effect::HUNGER);
|
||||
}
|
||||
|
||||
public static function INSTANT_DAMAGE() : Effect{
|
||||
return self::getEffect(Effect::INSTANT_DAMAGE);
|
||||
return self::get(Effect::INSTANT_DAMAGE);
|
||||
}
|
||||
|
||||
public static function INSTANT_HEALTH() : Effect{
|
||||
return self::getEffect(Effect::INSTANT_HEALTH);
|
||||
return self::get(Effect::INSTANT_HEALTH);
|
||||
}
|
||||
|
||||
public static function INVISIBILITY() : Effect{
|
||||
return self::getEffect(Effect::INVISIBILITY);
|
||||
return self::get(Effect::INVISIBILITY);
|
||||
}
|
||||
|
||||
public static function JUMP_BOOST() : Effect{
|
||||
return self::getEffect(Effect::JUMP_BOOST);
|
||||
return self::get(Effect::JUMP_BOOST);
|
||||
}
|
||||
|
||||
public static function LEVITATION() : Effect{
|
||||
return self::getEffect(Effect::LEVITATION);
|
||||
return self::get(Effect::LEVITATION);
|
||||
}
|
||||
|
||||
public static function MINING_FATIGUE() : Effect{
|
||||
return self::getEffect(Effect::MINING_FATIGUE);
|
||||
return self::get(Effect::MINING_FATIGUE);
|
||||
}
|
||||
|
||||
public static function NAUSEA() : Effect{
|
||||
return self::getEffect(Effect::NAUSEA);
|
||||
return self::get(Effect::NAUSEA);
|
||||
}
|
||||
|
||||
public static function NIGHT_VISION() : Effect{
|
||||
return self::getEffect(Effect::NIGHT_VISION);
|
||||
return self::get(Effect::NIGHT_VISION);
|
||||
}
|
||||
|
||||
public static function POISON() : Effect{
|
||||
return self::getEffect(Effect::POISON);
|
||||
return self::get(Effect::POISON);
|
||||
}
|
||||
|
||||
public static function REGENERATION() : Effect{
|
||||
return self::getEffect(Effect::REGENERATION);
|
||||
return self::get(Effect::REGENERATION);
|
||||
}
|
||||
|
||||
public static function RESISTANCE() : Effect{
|
||||
return self::getEffect(Effect::RESISTANCE);
|
||||
return self::get(Effect::RESISTANCE);
|
||||
}
|
||||
|
||||
public static function SATURATION() : Effect{
|
||||
return self::getEffect(Effect::SATURATION);
|
||||
return self::get(Effect::SATURATION);
|
||||
}
|
||||
|
||||
public static function SLOWNESS() : Effect{
|
||||
return self::getEffect(Effect::SLOWNESS);
|
||||
return self::get(Effect::SLOWNESS);
|
||||
}
|
||||
|
||||
public static function SPEED() : Effect{
|
||||
return self::getEffect(Effect::SPEED);
|
||||
return self::get(Effect::SPEED);
|
||||
}
|
||||
|
||||
public static function STRENGTH() : Effect{
|
||||
return self::getEffect(Effect::STRENGTH);
|
||||
return self::get(Effect::STRENGTH);
|
||||
}
|
||||
|
||||
public static function WATER_BREATHING() : Effect{
|
||||
return self::getEffect(Effect::WATER_BREATHING);
|
||||
return self::get(Effect::WATER_BREATHING);
|
||||
}
|
||||
|
||||
public static function WEAKNESS() : Effect{
|
||||
return self::getEffect(Effect::WEAKNESS);
|
||||
return self::get(Effect::WEAKNESS);
|
||||
}
|
||||
|
||||
public static function WITHER() : Effect{
|
||||
return self::getEffect(Effect::WITHER);
|
||||
return self::get(Effect::WITHER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Effect $effect
|
||||
*/
|
||||
public static function registerEffect(Effect $effect) : void{
|
||||
public static function register(Effect $effect) : void{
|
||||
self::$effects[$effect->getId()] = $effect;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ class Effect{
|
||||
*
|
||||
* @return Effect|null
|
||||
*/
|
||||
public static function getEffect(int $id) : ?Effect{
|
||||
public static function get(int $id) : ?Effect{
|
||||
return self::$effects[$id] ?? null;
|
||||
}
|
||||
|
||||
@ -219,10 +219,10 @@ class Effect{
|
||||
*
|
||||
* @return Effect|null
|
||||
*/
|
||||
public static function getEffectByName(string $name) : ?Effect{
|
||||
public static function fromString(string $name) : ?Effect{
|
||||
$const = self::class . "::" . strtoupper($name);
|
||||
if(defined($const)){
|
||||
return self::getEffect(constant($const));
|
||||
return self::get(constant($const));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
/** @var CompoundTag $entry */
|
||||
foreach($ench as $entry){
|
||||
if($entry->getShort("id") === $id){
|
||||
$e = Enchantment::getEnchantment($entry->getShort("id"));
|
||||
$e = Enchantment::get($entry->getShort("id"));
|
||||
if($e !== null){
|
||||
return new EnchantmentInstance($e, $entry->getShort("lvl"));
|
||||
}
|
||||
@ -353,7 +353,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
if($ench instanceof ListTag){
|
||||
/** @var CompoundTag $entry */
|
||||
foreach($ench as $entry){
|
||||
$e = Enchantment::getEnchantment($entry->getShort("id"));
|
||||
$e = Enchantment::get($entry->getShort("id"));
|
||||
if($e !== null){
|
||||
$enchantments[] = new EnchantmentInstance($e, $entry->getShort("lvl"));
|
||||
}
|
||||
|
@ -100,120 +100,120 @@ class Enchantment{
|
||||
public static function init() : void{
|
||||
self::$enchantments = new \SplFixedArray(256);
|
||||
|
||||
self::registerEnchantment(new ProtectionEnchantment(self::PROTECTION, "%enchantment.protect.all", self::RARITY_COMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 0.75, null));
|
||||
self::registerEnchantment(new ProtectionEnchantment(self::FIRE_PROTECTION, "%enchantment.protect.fire", self::RARITY_UNCOMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 1.25, [
|
||||
self::register(new ProtectionEnchantment(self::PROTECTION, "%enchantment.protect.all", self::RARITY_COMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 0.75, null));
|
||||
self::register(new ProtectionEnchantment(self::FIRE_PROTECTION, "%enchantment.protect.fire", self::RARITY_UNCOMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 1.25, [
|
||||
EntityDamageEvent::CAUSE_FIRE,
|
||||
EntityDamageEvent::CAUSE_FIRE_TICK,
|
||||
EntityDamageEvent::CAUSE_LAVA
|
||||
//TODO: check fireballs
|
||||
]));
|
||||
self::registerEnchantment(new ProtectionEnchantment(self::FEATHER_FALLING, "%enchantment.protect.fall", self::RARITY_UNCOMMON, self::SLOT_FEET, self::SLOT_NONE, 4, 2.5, [
|
||||
self::register(new ProtectionEnchantment(self::FEATHER_FALLING, "%enchantment.protect.fall", self::RARITY_UNCOMMON, self::SLOT_FEET, self::SLOT_NONE, 4, 2.5, [
|
||||
EntityDamageEvent::CAUSE_FALL
|
||||
]));
|
||||
self::registerEnchantment(new ProtectionEnchantment(self::BLAST_PROTECTION, "%enchantment.protect.explosion", self::RARITY_RARE, self::SLOT_ARMOR, self::SLOT_NONE, 4, 1.5, [
|
||||
self::register(new ProtectionEnchantment(self::BLAST_PROTECTION, "%enchantment.protect.explosion", self::RARITY_RARE, self::SLOT_ARMOR, self::SLOT_NONE, 4, 1.5, [
|
||||
EntityDamageEvent::CAUSE_BLOCK_EXPLOSION,
|
||||
EntityDamageEvent::CAUSE_ENTITY_EXPLOSION
|
||||
]));
|
||||
self::registerEnchantment(new ProtectionEnchantment(self::PROJECTILE_PROTECTION, "%enchantment.protect.projectile", self::RARITY_UNCOMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 1.5, [
|
||||
self::register(new ProtectionEnchantment(self::PROJECTILE_PROTECTION, "%enchantment.protect.projectile", self::RARITY_UNCOMMON, self::SLOT_ARMOR, self::SLOT_NONE, 4, 1.5, [
|
||||
EntityDamageEvent::CAUSE_PROJECTILE
|
||||
]));
|
||||
self::registerEnchantment(new Enchantment(self::THORNS, "%enchantment.thorns", self::RARITY_MYTHIC, self::SLOT_TORSO, self::SLOT_HEAD | self::SLOT_LEGS | self::SLOT_FEET, 3));
|
||||
self::registerEnchantment(new Enchantment(self::RESPIRATION, "%enchantment.oxygen", self::RARITY_RARE, self::SLOT_HEAD, self::SLOT_NONE, 3));
|
||||
self::register(new Enchantment(self::THORNS, "%enchantment.thorns", self::RARITY_MYTHIC, self::SLOT_TORSO, self::SLOT_HEAD | self::SLOT_LEGS | self::SLOT_FEET, 3));
|
||||
self::register(new Enchantment(self::RESPIRATION, "%enchantment.oxygen", self::RARITY_RARE, self::SLOT_HEAD, self::SLOT_NONE, 3));
|
||||
|
||||
self::registerEnchantment(new SharpnessEnchantment(self::SHARPNESS, "%enchantment.damage.all", self::RARITY_COMMON, self::SLOT_SWORD, self::SLOT_AXE, 5));
|
||||
self::register(new SharpnessEnchantment(self::SHARPNESS, "%enchantment.damage.all", self::RARITY_COMMON, self::SLOT_SWORD, self::SLOT_AXE, 5));
|
||||
//TODO: smite, bane of arthropods (these don't make sense now because their applicable mobs don't exist yet)
|
||||
|
||||
self::registerEnchantment(new KnockbackEnchantment(self::KNOCKBACK, "%enchantment.knockback", self::RARITY_UNCOMMON, self::SLOT_SWORD, self::SLOT_NONE, 2));
|
||||
self::registerEnchantment(new FireAspectEnchantment(self::FIRE_ASPECT, "%enchantment.fire", self::RARITY_RARE, self::SLOT_SWORD, self::SLOT_NONE, 2));
|
||||
self::register(new KnockbackEnchantment(self::KNOCKBACK, "%enchantment.knockback", self::RARITY_UNCOMMON, self::SLOT_SWORD, self::SLOT_NONE, 2));
|
||||
self::register(new FireAspectEnchantment(self::FIRE_ASPECT, "%enchantment.fire", self::RARITY_RARE, self::SLOT_SWORD, self::SLOT_NONE, 2));
|
||||
|
||||
self::registerEnchantment(new Enchantment(self::EFFICIENCY, "%enchantment.digging", self::RARITY_COMMON, self::SLOT_DIG, self::SLOT_SHEARS, 5));
|
||||
self::registerEnchantment(new Enchantment(self::SILK_TOUCH, "%enchantment.untouching", self::RARITY_MYTHIC, self::SLOT_DIG, self::SLOT_SHEARS, 1));
|
||||
self::registerEnchantment(new Enchantment(self::UNBREAKING, "%enchantment.durability", self::RARITY_UNCOMMON, self::SLOT_DIG | self::SLOT_ARMOR | self::SLOT_FISHING_ROD | self::SLOT_BOW, self::SLOT_TOOL | self::SLOT_CARROT_STICK | self::SLOT_ELYTRA, 3));
|
||||
self::register(new Enchantment(self::EFFICIENCY, "%enchantment.digging", self::RARITY_COMMON, self::SLOT_DIG, self::SLOT_SHEARS, 5));
|
||||
self::register(new Enchantment(self::SILK_TOUCH, "%enchantment.untouching", self::RARITY_MYTHIC, self::SLOT_DIG, self::SLOT_SHEARS, 1));
|
||||
self::register(new Enchantment(self::UNBREAKING, "%enchantment.durability", self::RARITY_UNCOMMON, self::SLOT_DIG | self::SLOT_ARMOR | self::SLOT_FISHING_ROD | self::SLOT_BOW, self::SLOT_TOOL | self::SLOT_CARROT_STICK | self::SLOT_ELYTRA, 3));
|
||||
|
||||
self::registerEnchantment(new Enchantment(self::POWER, "%enchantment.arrowDamage", self::RARITY_COMMON, self::SLOT_BOW, self::SLOT_NONE, 5));
|
||||
self::registerEnchantment(new Enchantment(self::PUNCH, "%enchantment.arrowKnockback", self::RARITY_RARE, self::SLOT_BOW, self::SLOT_NONE, 2));
|
||||
self::registerEnchantment(new Enchantment(self::FLAME, "%enchantment.arrowFire", self::RARITY_RARE, self::SLOT_BOW, self::SLOT_NONE, 1));
|
||||
self::registerEnchantment(new Enchantment(self::INFINITY, "%enchantment.arrowInfinite", self::RARITY_MYTHIC, self::SLOT_BOW, self::SLOT_NONE, 1));
|
||||
self::register(new Enchantment(self::POWER, "%enchantment.arrowDamage", self::RARITY_COMMON, self::SLOT_BOW, self::SLOT_NONE, 5));
|
||||
self::register(new Enchantment(self::PUNCH, "%enchantment.arrowKnockback", self::RARITY_RARE, self::SLOT_BOW, self::SLOT_NONE, 2));
|
||||
self::register(new Enchantment(self::FLAME, "%enchantment.arrowFire", self::RARITY_RARE, self::SLOT_BOW, self::SLOT_NONE, 1));
|
||||
self::register(new Enchantment(self::INFINITY, "%enchantment.arrowInfinite", self::RARITY_MYTHIC, self::SLOT_BOW, self::SLOT_NONE, 1));
|
||||
|
||||
self::registerEnchantment(new Enchantment(self::MENDING, "%enchantment.mending", self::RARITY_RARE, self::SLOT_NONE, self::SLOT_ALL, 1));
|
||||
self::register(new Enchantment(self::MENDING, "%enchantment.mending", self::RARITY_RARE, self::SLOT_NONE, self::SLOT_ALL, 1));
|
||||
|
||||
self::registerEnchantment(new Enchantment(self::VANISHING, "%enchantment.curse.vanishing", self::RARITY_MYTHIC, self::SLOT_NONE, self::SLOT_ALL, 1));
|
||||
self::register(new Enchantment(self::VANISHING, "%enchantment.curse.vanishing", self::RARITY_MYTHIC, self::SLOT_NONE, self::SLOT_ALL, 1));
|
||||
}
|
||||
|
||||
public static function BLAST_PROTECTION() : Enchantment{
|
||||
return self::getEnchantment(self::BLAST_PROTECTION);
|
||||
return self::get(self::BLAST_PROTECTION);
|
||||
}
|
||||
|
||||
public static function EFFICIENCY() : Enchantment{
|
||||
return self::getEnchantment(self::EFFICIENCY);
|
||||
return self::get(self::EFFICIENCY);
|
||||
}
|
||||
|
||||
public static function FEATHER_FALLING() : Enchantment{
|
||||
return self::getEnchantment(self::FEATHER_FALLING);
|
||||
return self::get(self::FEATHER_FALLING);
|
||||
}
|
||||
|
||||
public static function FIRE_ASPECT() : Enchantment{
|
||||
return self::getEnchantment(self::FIRE_ASPECT);
|
||||
return self::get(self::FIRE_ASPECT);
|
||||
}
|
||||
|
||||
public static function FIRE_PROTECTION() : Enchantment{
|
||||
return self::getEnchantment(self::FIRE_PROTECTION);
|
||||
return self::get(self::FIRE_PROTECTION);
|
||||
}
|
||||
|
||||
public static function FLAME() : Enchantment{
|
||||
return self::getEnchantment(self::FLAME);
|
||||
return self::get(self::FLAME);
|
||||
}
|
||||
|
||||
public static function INFINITY() : Enchantment{
|
||||
return self::getEnchantment(self::INFINITY);
|
||||
return self::get(self::INFINITY);
|
||||
}
|
||||
|
||||
public static function KNOCKBACK() : Enchantment{
|
||||
return self::getEnchantment(self::KNOCKBACK);
|
||||
return self::get(self::KNOCKBACK);
|
||||
}
|
||||
|
||||
public static function MENDING() : Enchantment{
|
||||
return self::getEnchantment(self::MENDING);
|
||||
return self::get(self::MENDING);
|
||||
}
|
||||
|
||||
public static function POWER() : Enchantment{
|
||||
return self::getEnchantment(self::POWER);
|
||||
return self::get(self::POWER);
|
||||
}
|
||||
|
||||
public static function PROJECTILE_PROTECTION() : Enchantment{
|
||||
return self::getEnchantment(self::PROJECTILE_PROTECTION);
|
||||
return self::get(self::PROJECTILE_PROTECTION);
|
||||
}
|
||||
|
||||
public static function PROTECTION() : Enchantment{
|
||||
return self::getEnchantment(self::PROTECTION);
|
||||
return self::get(self::PROTECTION);
|
||||
}
|
||||
|
||||
public static function PUNCH() : Enchantment{
|
||||
return self::getEnchantment(self::PUNCH);
|
||||
return self::get(self::PUNCH);
|
||||
}
|
||||
|
||||
public static function RESPIRATION() : Enchantment{
|
||||
return self::getEnchantment(self::RESPIRATION);
|
||||
return self::get(self::RESPIRATION);
|
||||
}
|
||||
|
||||
public static function SHARPNESS() : Enchantment{
|
||||
return self::getEnchantment(self::SHARPNESS);
|
||||
return self::get(self::SHARPNESS);
|
||||
}
|
||||
|
||||
public static function SILK_TOUCH() : Enchantment{
|
||||
return self::getEnchantment(self::SILK_TOUCH);
|
||||
return self::get(self::SILK_TOUCH);
|
||||
}
|
||||
|
||||
public static function THORNS() : Enchantment{
|
||||
return self::getEnchantment(self::THORNS);
|
||||
return self::get(self::THORNS);
|
||||
}
|
||||
|
||||
public static function UNBREAKING() : Enchantment{
|
||||
return self::getEnchantment(self::UNBREAKING);
|
||||
return self::get(self::UNBREAKING);
|
||||
}
|
||||
|
||||
public static function VANISHING() : Enchantment{
|
||||
return self::getEnchantment(self::VANISHING);
|
||||
return self::get(self::VANISHING);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +221,7 @@ class Enchantment{
|
||||
*
|
||||
* @param Enchantment $enchantment
|
||||
*/
|
||||
public static function registerEnchantment(Enchantment $enchantment) : void{
|
||||
public static function register(Enchantment $enchantment) : void{
|
||||
self::$enchantments[$enchantment->getId()] = clone $enchantment;
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ class Enchantment{
|
||||
*
|
||||
* @return Enchantment|null
|
||||
*/
|
||||
public static function getEnchantment(int $id) : ?Enchantment{
|
||||
public static function get(int $id) : ?Enchantment{
|
||||
return self::$enchantments[$id] ?? null;
|
||||
}
|
||||
|
||||
@ -239,10 +239,10 @@ class Enchantment{
|
||||
*
|
||||
* @return Enchantment|null
|
||||
*/
|
||||
public static function getEnchantmentByName(string $name) : ?Enchantment{
|
||||
public static function fromString(string $name) : ?Enchantment{
|
||||
$const = Enchantment::class . "::" . strtoupper($name);
|
||||
if(defined($const)){
|
||||
return self::getEnchantment(constant($const));
|
||||
return self::get(constant($const));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user