主类 
- //主类继承JavaPlugin,实现EnchantPlugin接口
 
 - public class Main extends JavaPlugin implements EnchantPlugin{
 
  
-         @Override
 
 -         public void onEnable(){
 
 -                 
 
 -         }
 
  
-         //添加未实现的方法,此方法用于注册附魔
 
 -         //调用EnchantmentRegistry 类的 register()方法
 
 -         //传入 CustomEnchantment 类型参数
 
 -         @Override
 
 -         public void registerEnchantments(EnchantmentRegistry registry) {
 
 -                 registry.register(
 
 -                 new TestEnchantment()
 
 -                 );
 
 -         }
 
 - }
 
  复制代码 自定义附魔类 
- //继承 CustomEnchantment 类
 
 - public class TestEnchantment extends CustomEnchantment{
 
  
-         //添加构造方法
 
 -         TestEnchantment() {
 
 -                 super("女装" ,"拿着立即获得全属性加成");
 
 -                 
 
 -                 //设置最大附魔等级
 
 -                 setMaxLevel(5);
 
 -                 //设置可附魔物品
 
 -                 //ItemSet 类提供了物品枚举,便于添加物品
 
 -                 addNaturalItems(ItemSet.CHESTPLATES.getItems());
 
 -                 
 
 -         }
 
 -         
 
 -         //重写applyEquip()方法,在玩家切换物品时触发
 
 -         //执行方法里面的所有内容
 
 -         @Override
 
 -         public void applyEquip(LivingEntity p, int level) {
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.LUCK, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1200, 1));
 
 -                 p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 1200, 1));
 
 -         }
 
 - }
 
  复制代码 |