use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class ChargedShot method activationListener.
@EventHandler
public void activationListener(EntityShootBowEvent event) {
if (blockDisabled(MAbility.CHARGED_SHOT))
return;
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 (playerData.getAbilityData(MAbility.CHARGED_SHOT).getBoolean("enabled")) {
if (playerData.getManaAbilityLevel(MAbility.CHARGED_SHOT) == 0)
return;
ManaAbilityManager manager = plugin.getManaAbilityManager();
int cooldown = manager.getPlayerCooldown(player.getUniqueId(), MAbility.SHARP_HOOK);
if (cooldown == 0) {
playerData.getMetadata().put("charged_shot_projectile", event.getProjectile());
playerData.getMetadata().put("charged_shot_force", event.getForce());
activate(player);
} else {
if (manager.getErrorTimer(player.getUniqueId(), MAbility.SHARP_HOOK) == 0) {
Locale locale = playerData.getLocale();
plugin.getAbilityManager().sendMessage(player, TextUtil.replace(Lang.getMessage(ManaAbilityMessage.NOT_READY, locale), "{cooldown}", NumberUtil.format1((double) (cooldown) / 20)));
manager.setErrorTimer(player.getUniqueId(), MAbility.SHARP_HOOK, 2);
}
}
}
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class BlockLootHandler method onBreak.
@EventHandler(priority = EventPriority.HIGH)
public void onBreak(BlockBreakEvent event) {
if (!OptionL.isEnabled(skill))
return;
if (event.isCancelled())
return;
Block block = event.getBlock();
if (getSource(block) == null)
return;
Player player = event.getPlayer();
if (blockAbility(player))
return;
if (player.getGameMode() != GameMode.SURVIVAL) {
// Only drop loot in survival mode
return;
}
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
Source originalSource = getSource(block);
LootTable table = plugin.getLootTableManager().getLootTable(skill);
if (table == null)
return;
for (LootPool pool : table.getPools()) {
// Calculate chance for pool
double chance = getChance(pool, playerData);
LootDropCause cause = getCause(pool);
// Select pool and give loot
if (selectBlockLoot(pool, player, chance, originalSource, event, cause)) {
break;
}
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class ManaAbilityProvider method stop.
public void stop(Player player) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
// Mana ability specific stop behavior is run
onStop(player, playerData);
// Apply cooldown
manager.setPlayerCooldown(player, mAbility);
// Send stop message if applicable
if (stopMessage != null) {
plugin.getAbilityManager().sendMessage(player, Lang.getMessage(stopMessage, plugin.getLang().getLocale(player)));
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class Leveler method setXp.
// Method for setting xp with a defined amount
public void setXp(Player player, Skill skill, double amount) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
// Checks if player has a skill profile for safety
if (playerData != null) {
double originalAmount = playerData.getSkillXp(skill);
// Sets Xp
playerData.setSkillXp(skill, amount);
// Check if player leveled up
checkLevelUp(player, skill);
// Sends action bar message
plugin.getActionBar().sendXpActionBar(player, skill, amount - originalAmount);
// Sends boss bar if enabled
sendBossBar(player, skill, playerData);
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class SkillInfoItem method getAbilityLevelsLore.
private String getAbilityLevelsLore(Skill skill, PlayerData playerData, Locale locale) {
StringBuilder abilityLevelsLore = new StringBuilder();
if (skill.getAbilities().size() == 5) {
String levelsMessage = Lang.getMessage(MenuMessage.ABILITY_LEVELS, locale);
int num = 1;
List<Ability> abilities = new ArrayList<>();
for (Supplier<Ability> abilitySupplier : skill.getAbilities()) {
abilities.add(abilitySupplier.get());
}
abilities.sort(Comparator.comparingInt(a -> plugin.getAbilityManager().getUnlock(a)));
for (Ability ability : abilities) {
if (plugin.getAbilityManager().isEnabled(ability)) {
if (playerData.getAbilityLevel(ability) > 0) {
int abilityLevel = playerData.getAbilityLevel(ability);
levelsMessage = TextUtil.replace(levelsMessage, "{ability_" + num + "}", TextUtil.replace(Lang.getMessage(MenuMessage.ABILITY_LEVEL_ENTRY, locale), "{ability}", ability.getDisplayName(locale), "{level}", RomanNumber.toRoman(playerData.getAbilityLevel(ability)), "{info}", TextUtil.replace(ability.getInfo(locale), "{value}", NumberUtil.format1(plugin.getAbilityManager().getValue(ability, abilityLevel)), "{value_2}", NumberUtil.format1(plugin.getAbilityManager().getValue2(ability, abilityLevel)))));
} else {
levelsMessage = TextUtil.replace(levelsMessage, "{ability_" + num + "}", TextUtil.replace(Lang.getMessage(MenuMessage.ABILITY_LEVEL_ENTRY_LOCKED, locale), "{ability}", ability.getDisplayName(locale)));
}
} else {
levelsMessage = TextUtil.replace(levelsMessage, "\\n {ability_" + num + "}", "", "{ability_" + num + "}", "");
}
num++;
}
abilityLevelsLore.append(levelsMessage);
}
return abilityLevelsLore.toString();
}
Aggregations