use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class HealingAbilities method lifeSteal.
@EventHandler
public void lifeSteal(EntityDeathEvent event) {
if (blockDisabled(Ability.LIFE_STEAL))
return;
LivingEntity entity = event.getEntity();
boolean hostile = entity instanceof Monster || entity instanceof Player;
if (XMaterial.isNewVersion()) {
if (entity instanceof Phantom) {
hostile = true;
}
}
if (hostile) {
if (entity.getKiller() == null)
return;
Player player = entity.getKiller();
if (player.equals(entity))
return;
if (blockAbility(player))
return;
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
if (playerData.getAbilityLevel(Ability.LIFE_STEAL) > 0) {
AttributeInstance entityAttribute = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (entityAttribute == null)
return;
double maxHealth = entityAttribute.getValue();
double percent = getValue(Ability.LIFE_STEAL, playerData) / 100;
double healthRegen = maxHealth * percent;
AttributeInstance playerAttribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (playerAttribute == null)
return;
player.setHealth(player.getHealth() + Math.min(healthRegen, playerAttribute.getValue() - player.getHealth()));
}
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class AlchemyAbilities method getSplasherMultiplier.
private double getSplasherMultiplier(ProjectileSource source, Collection<LivingEntity> affectedEntities) {
double splasherMultiplier = 1.0;
if (source instanceof Player) {
Player player = (Player) source;
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null && plugin.getAbilityManager().isEnabled(Ability.SPLASHER)) {
if (playerData.getAbilityLevel(Ability.SPLASHER) > 0) {
double splasherPercent = getValue(Ability.SPLASHER, playerData);
int affectedPlayers = (int) affectedEntities.stream().filter(entity -> entity instanceof Player).filter(entity -> plugin.getPlayerManager().getPlayerData(entity.getUniqueId()) != null).count();
splasherMultiplier = 1 + (splasherPercent / 100 * affectedPlayers);
}
}
}
return splasherMultiplier;
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class FarmingAbilities method tripleHarvest.
public void tripleHarvest(Player player, Block block) {
if (OptionL.isEnabled(Skills.FARMING)) {
if (plugin.getAbilityManager().isEnabled(Ability.TRIPLE_HARVEST)) {
if (player.getGameMode().equals(GameMode.SURVIVAL)) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
if (playerData.getAbilityLevel(Ability.TRIPLE_HARVEST) > 0) {
if (r.nextDouble() < (getValue(Ability.TRIPLE_HARVEST, playerData)) / 100) {
for (ItemStack item : block.getDrops()) {
checkMelonSilkTouch(player, block, item);
ItemStack droppedItem = item.clone();
droppedItem.setAmount(2);
PlayerLootDropEvent event = new PlayerLootDropEvent(player, droppedItem, block.getLocation().add(0.5, 0.5, 0.5), LootDropCause.TRIPLE_HARVEST);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
block.getWorld().dropItem(event.getLocation(), event.getItemStack());
}
}
}
}
}
}
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class FarmingAbilities method geneticist.
@EventHandler
public void geneticist(PlayerItemConsumeEvent event) {
if (blockDisabled(Ability.GENETICIST))
return;
Player player = event.getPlayer();
if (blockAbility(player))
return;
Material mat = event.getItem().getType();
if (mat.equals(Material.BREAD) || mat.equals(Material.APPLE) || mat.equals(Material.GOLDEN_APPLE) || mat.equals(XMaterial.POTATO.parseMaterial()) || mat.equals(Material.BAKED_POTATO) || mat.equals(XMaterial.CARROT.parseMaterial()) || mat.equals(Material.GOLDEN_CARROT) || mat.equals(Material.MELON) || mat.equals(Material.PUMPKIN_PIE) || mat.equals(Material.BEETROOT) || mat.equals(Material.BEETROOT_SOUP) || mat.equals(XMaterial.MUSHROOM_STEW.parseMaterial()) || mat.equals(Material.POISONOUS_POTATO)) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
float amount = (float) getValue(Ability.GENETICIST, playerData) / 10;
player.setSaturation(player.getSaturation() + amount);
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class FishingAbilities method grappler.
@EventHandler
public void grappler(PlayerFishEvent event) {
if (blockDisabled(Ability.GRAPPLER))
return;
if (event.getCaught() != null) {
if (!(event.getCaught() instanceof Item)) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(event.getPlayer());
if (playerData != null) {
Player player = event.getPlayer();
if (blockAbility(player))
return;
Vector vector = player.getLocation().toVector().subtract(event.getCaught().getLocation().toVector());
Vector result = vector.multiply(0.004 + (getValue(Ability.GRAPPLER, playerData) / 25000));
if (isUnsafeVelocity(result)) {
// Prevent excessive velocity warnings
return;
}
event.getCaught().setVelocity(result);
}
}
}
}
Aggregations