cn.nukkit.item.enchantment.protection.EnchantmentProtection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.item.enchantment.protection;
import cn.nukkit.item.enchantment.Enchantment;
import cn.nukkit.item.enchantment.EnchantmentType;
/**
* @author MagicDroidX (Nukkit Project)
*/
public abstract class EnchantmentProtection extends Enchantment {
public enum TYPE {
ALL,
FIRE,
FALL,
EXPLOSION,
PROJECTILE
}
protected final TYPE protectionType;
protected EnchantmentProtection(int id, String name, int weight, EnchantmentProtection.TYPE type) {
super(id, name, weight, EnchantmentType.ARMOR);
this.protectionType = type;
if (protectionType == TYPE.FALL) {
this.type = EnchantmentType.ARMOR_FEET;
}
}
@Override
public boolean isCompatibleWith(Enchantment enchantment) {
if (enchantment instanceof EnchantmentProtection) {
if (((EnchantmentProtection) enchantment).protectionType == this.protectionType) {
return false;
}
return ((EnchantmentProtection) enchantment).protectionType == TYPE.FALL || this.protectionType == TYPE.FALL;
}
return super.isCompatibleWith(enchantment);
}
@Override
public int getMaxLevel() {
return 4;
}
@Override
public String getName() {
return "%enchantment.protect." + this.name;
}
public double getTypeModifier() {
return 0;
}
@Override
public boolean isMajor() {
return true;
}
}