示例#1
0
 @EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
 public void onEntityDamage(WeaponDamageEvent event) {
   if (!(event.isCancelled()) && (event.getDamager() instanceof Hero)) {
     Hero hero = (Hero) event.getDamager();
     Material m = hero.getPlayer().getItemInHand().getType();
     String heroClass = hero.getHeroClass().getName();
     if (hero.hasEffect("Critical")
         && ((heroClass.equalsIgnoreCase("Kundschafter") && m == Material.SHEARS)
             || (heroClass.equalsIgnoreCase("Barbar")
                 && (m == Material.WOOD_AXE || m == Material.STONE_AXE)))) {
       double chance =
           (SkillConfigManager.getUseSetting(hero, skill, SkillSetting.CHANCE.node(), 0.2, false)
               + (SkillConfigManager.getUseSetting(
                       hero, skill, SkillSetting.CHANCE_LEVEL.node(), 0.0, false)
                   * hero.getSkillLevel(skill)));
       chance = chance > 0 ? chance : 0;
       if (Math.random() <= chance) {
         double damageMod =
             (SkillConfigManager.getUseSetting(hero, skill, "damage-multiplier", 0.2, false)
                 + (SkillConfigManager.getUseSetting(
                         hero, skill, "damage-multiplier-increase", 0.0, false)
                     * hero.getSkillLevel(skill)));
         damageMod = damageMod > 0 ? damageMod : 0;
         event.setDamage((event.getDamage() * damageMod));
         hero.getPlayer()
             .getWorld()
             .playSound(hero.getPlayer().getLocation(), Sound.SUCCESSFUL_HIT, 10, 1);
       }
     }
   }
 }
 @EventHandler(priority = EventPriority.HIGH)
 public void onEntityDamage(WeaponDamageEvent event) {
   if (!(event.isCancelled())
       && (event.getDamager() instanceof Hero)
       && (event.getCause().equals(DamageCause.PROJECTILE))) {
     Hero hero = (Hero) event.getDamager();
     if (hero.hasEffect("RetrieveArrow")) {
       double chance =
           (SkillConfigManager.getUseSetting(hero, skill, Setting.CHANCE.node(), 0.2, false)
               + (SkillConfigManager.getUseSetting(
                       hero, skill, Setting.CHANCE_LEVEL.node(), 0.0, false)
                   * hero.getSkillLevel(skill)));
       if (hst != null)
         chance +=
             (SkillConfigManager.getUseSetting(hero, skill, "hst-amount", 0.0, false)
                 * (hst.getSkillLevel(hero, skill) - 1));
       chance = chance > 0 ? chance : 0;
       if (Math.random() <= chance) {
         if (event.getEntity() instanceof Player) {
           if (SkillRetrieveArrow.this
                   .plugin
                   .getCharacterManager()
                   .getHero((Player) event.getEntity())
                   .getHealth()
               < event.getDamage()) {
             event
                 .getEntity()
                 .getWorld()
                 .dropItemNaturally(event.getEntity().getLocation(), new ItemStack(262, 1));
           }
         } else if (event.getEntity() instanceof LivingEntity) {
           if (SkillRetrieveArrow.this
                   .plugin
                   .getCharacterManager()
                   .getMonster((LivingEntity) event.getEntity())
                   .getHealth()
               < event.getDamage()) {
             event
                 .getEntity()
                 .getWorld()
                 .dropItemNaturally(event.getEntity().getLocation(), new ItemStack(262, 1));
           }
         }
       }
     }
   }
 }