示例#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);
       }
     }
   }
 }
示例#2
0
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set(SkillSetting.CHANCE.node(), 0.2);
   node.set(SkillSetting.CHANCE_LEVEL.node(), 0);
   node.set("damage-multiplier", 2.0);
   node.set("damage-multiplier-increase", 0);
   return node;
 }
示例#3
0
 @Override
 public String getDescription(Hero hero) {
   double chance =
       (SkillConfigManager.getUseSetting(hero, this, SkillSetting.CHANCE.node(), 0.2, false)
               + (SkillConfigManager.getUseSetting(
                       hero, this, SkillSetting.CHANCE_LEVEL.node(), 0.0, false)
                   * hero.getSkillLevel(this)))
           * 100;
   chance = chance > 0 ? chance : 0;
   double damageMod =
       (SkillConfigManager.getUseSetting(hero, this, "damage-multiplier", 0.2, false)
           + (SkillConfigManager.getUseSetting(
                   hero, this, "damage-multiplier-increase", 0.0, false)
               * hero.getSkillLevel(this)));
   damageMod = damageMod > 0 ? damageMod : 0;
   String description = getDescription().replace("$1", chance + "").replace("$2", damageMod + "");
   return description;
 }