use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class ForagingAbilities method lumberjack.
public void lumberjack(Player player, Block block) {
if (OptionL.isEnabled(Skills.FORAGING)) {
if (plugin.getAbilityManager().isEnabled(Ability.LUMBERJACK)) {
if (player.getGameMode().equals(GameMode.SURVIVAL)) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
if (playerData.getAbilityLevel(Ability.LUMBERJACK) > 0) {
if (r.nextDouble() < ((getValue(Ability.LUMBERJACK, playerData)) / 100)) {
for (ItemStack item : block.getDrops(player.getInventory().getItemInMainHand())) {
PlayerLootDropEvent event = new PlayerLootDropEvent(player, item.clone(), block.getLocation().add(0.5, 0.5, 0.5), LootDropCause.LUMBERJACK);
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 ArcheryAbilities method archeryListener.
@EventHandler(priority = EventPriority.HIGH)
public void archeryListener(EntityDamageByEntityEvent event) {
if (OptionL.isEnabled(Skills.ARCHERY)) {
if (!event.isCancelled()) {
if (event.getDamager() instanceof Arrow) {
Arrow arrow = (Arrow) event.getDamager();
if (arrow.getShooter() instanceof Player) {
Player player = (Player) arrow.getShooter();
if (blockAbility(player))
return;
// Applies abilities
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
AbilityManager options = plugin.getAbilityManager();
if (options.isEnabled(Ability.STUN)) {
if (event.getEntity() instanceof LivingEntity) {
LivingEntity entity = (LivingEntity) event.getEntity();
stun(playerData, entity);
}
}
if (options.isEnabled(Ability.PIERCING)) {
piercing(event, playerData, player, arrow);
}
}
}
}
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class DefenseAbilities method defenseListener.
@EventHandler
public void defenseListener(EntityDamageByEntityEvent event) {
if (OptionL.isEnabled(Skills.DEFENSE)) {
if (!event.isCancelled()) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (blockAbility(player))
return;
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
if (plugin.getAbilityManager().isEnabled(Ability.NO_DEBUFF)) {
if (event.getDamager() instanceof LivingEntity) {
LivingEntity entity = (LivingEntity) event.getDamager();
noDebuffFire(playerData, player, entity);
}
}
if (plugin.getAbilityManager().isEnabled(Ability.IMMUNITY)) {
immunity(event, playerData);
}
}
}
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class DefenseAbilities method noDebuff.
@EventHandler
public void noDebuff(PotionSplashEvent event) {
if (blockDisabled(Ability.NO_DEBUFF))
return;
for (LivingEntity entity : event.getAffectedEntities()) {
if (entity instanceof Player) {
Player player = (Player) entity;
if (blockAbility(player))
return;
for (PotionEffect effect : event.getPotion().getEffects()) {
PotionEffectType type = effect.getType();
if (type.equals(PotionEffectType.POISON) || type.equals(PotionEffectType.UNLUCK) || type.equals(PotionEffectType.WITHER) || type.equals(PotionEffectType.WEAKNESS) || type.equals(PotionEffectType.SLOW_DIGGING) || type.equals(PotionEffectType.SLOW) || type.equals(PotionEffectType.HUNGER) || type.equals(PotionEffectType.HARM) || type.equals(PotionEffectType.CONFUSION) || type.equals(PotionEffectType.BLINDNESS)) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
double chance = getValue(Ability.NO_DEBUFF, playerData) / 100;
if (r.nextDouble() < chance) {
if (!player.hasPotionEffect(type)) {
event.setIntensity(entity, 0);
}
}
}
}
}
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class EnchantingAbilities method xpWarrior.
@EventHandler
public void xpWarrior(EntityDeathEvent event) {
if (blockDisabled(Ability.XP_WARRIOR))
return;
LivingEntity entity = event.getEntity();
if (entity.getKiller() != null) {
Player player = entity.getKiller();
if (blockAbility(player))
return;
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
if (playerData.getAbilityLevel(Ability.XP_WARRIOR) > 0 && event.getDroppedExp() > 0) {
if (random.nextDouble() < getValue(Ability.XP_WARRIOR, playerData) / 100) {
event.setDroppedExp(event.getDroppedExp() * 2);
}
}
}
}
}
Aggregations