use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class ActionBar method sendAbilityActionBar.
public void sendAbilityActionBar(Player player, String message) {
if (!actionBarDisabled.contains(player.getUniqueId())) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
sendActionBar(player, TextUtil.replace(Lang.getMessage(ActionBarMessage.ABILITY, playerData.getLocale()), "{hp}", getHp(player), "{max_hp}", getMaxHp(player), "{mana}", getMana(playerData), "{max_mana}", getMaxMana(playerData), "{message}", message));
setPaused(player, 40);
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class ForgingAbilities method getHighestPlayer.
@Nullable
private Player getHighestPlayer(List<HumanEntity> viewers) {
int highestLevel = 0;
Player highestPlayer = null;
for (HumanEntity entity : viewers) {
if (entity instanceof Player) {
Player player = (Player) entity;
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
int level = playerData.getSkillLevel(Skills.FORGING);
if (level > highestLevel) {
highestLevel = level;
highestPlayer = player;
}
}
}
}
return highestPlayer;
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class ForgingAbilities method repairing.
@EventHandler(priority = EventPriority.MONITOR)
@SuppressWarnings("deprecation")
public void repairing(PrepareAnvilEvent event) {
if (blockDisabled(Ability.REPAIRING))
return;
Player player = getHighestPlayer(event.getViewers());
if (player == null)
return;
if (blockAbility(player))
return;
AnvilInventory inventory = event.getInventory();
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
if (playerData.getAbilityLevel(Ability.REPAIRING) == 0)
return;
ItemStack first = inventory.getItem(0);
ItemStack second = inventory.getItem(1);
ItemStack result = event.getResult();
if (first == null || second == null || result == null)
return;
// Check if the seconds slot is a raw material for repair
XMaterial rawMaterial = getRawMaterial(first.getType());
if (rawMaterial == null)
return;
if (second.getType() == rawMaterial.parseMaterial()) {
if (XMaterial.isNewVersion()) {
ItemMeta meta = first.getItemMeta();
if (meta == null)
return;
if (meta instanceof Damageable) {
Damageable damageable = (Damageable) meta;
short max = first.getType().getMaxDurability();
// Calculate durability to add, vanilla by default adds 20% of the max durability
long addedLong = second.getAmount() * (Math.round(0.25 * max) + Math.round(max * 0.25 * (getValue(Ability.REPAIRING, playerData) / 100)));
short added;
if (addedLong > Short.MAX_VALUE) {
added = (short) damageable.getDamage();
} else if (addedLong < Short.MIN_VALUE) {
added = 0;
} else {
added = (short) addedLong;
}
damageable.setDamage(Math.max(damageable.getDamage() - added, 0));
result.setItemMeta(damageable);
}
} else {
// For old versions
short max = result.getType().getMaxDurability();
long addedLong = second.getAmount() * (Math.round(0.25 * max) + Math.round(max * 0.25 * (getValue(Ability.REPAIRING, playerData) / 100)));
short added;
if (addedLong > Short.MAX_VALUE) {
added = first.getDurability();
} else if (addedLong < Short.MIN_VALUE) {
added = 0;
} else {
added = (short) addedLong;
}
result.setDurability((short) Math.max(first.getDurability() - added, 0));
}
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class HealingAbilities method revivalLeave.
@EventHandler(priority = EventPriority.LOW)
public void revivalLeave(PlayerQuitEvent event) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(event.getPlayer());
if (playerData == null) {
return;
}
playerData.removeStatModifier("AureliumSkills.Ability.Revival.Health");
playerData.removeStatModifier("AureliumSkills.Ability.Revival.Regeneration");
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class HealingAbilities method lifeEssence.
@EventHandler
public void lifeEssence(EntityRegainHealthEvent event) {
if (blockDisabled(Ability.LIFE_ESSENCE))
return;
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (blockAbility(player))
return;
if (event.getRegainReason() == EntityRegainHealthEvent.RegainReason.MAGIC) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
if (playerData.getAbilityLevel(Ability.LIFE_ESSENCE) > 0) {
double multiplier = 1 + getValue(Ability.LIFE_ESSENCE, playerData) / 100;
event.setAmount(event.getAmount() * multiplier);
}
}
}
}
Aggregations