private static double updateStat(PlayerData data, String key, double value) { Player player = data.getPlayer(); if (player != null) { String mapKey = player.getName() + ":" + key; double current = bonuses.containsKey(mapKey) ? bonuses.remove(mapKey) : 0; double updated = data.scaleStat(key, value - current) - value + current; bonuses.put(mapKey, updated); return updated - current; } return 0; }
/** * Apply skill damage/defense attribute buffs * * @param event event details */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onSkillDamage(SkillDamageEvent event) { // Skill Damage if (event.getDamager() instanceof Player) { Player player = (Player) event.getDamager(); PlayerData data = SkillAPI.getPlayerData(player); double newAmount = data.scaleStat(AttributeManager.PHYSICAL_DAMAGE, event.getDamage()); event.setDamage(newAmount); } // Skill Defense if (event.getTarget() instanceof Player) { Player player = (Player) event.getTarget(); PlayerData data = SkillAPI.getPlayerData(player); double newAmount = data.scaleStat(AttributeManager.PHYSICAL_DEFENSE, event.getDamage()); event.setDamage(newAmount); } }