use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class SkillsCommand method onMultiplier.
@Subcommand("multiplier")
@CommandCompletion("@players")
@CommandPermission("aureliumskills.multipliercommand")
@Description("Shows a player's current XP multiplier based on their permissions.")
public void onMultiplier(CommandSender sender, @Optional @Flags("other") Player player) {
Player target;
if (player == null) {
if (sender instanceof Player) {
target = (Player) sender;
} else {
sender.sendMessage(AureliumSkills.getPrefix(Lang.getDefaultLanguage()) + Lang.getMessage(CommandMessage.MULTIPLIER_PLAYERS_ONLY, Lang.getDefaultLanguage()));
return;
}
} else {
target = player;
}
Locale locale = plugin.getLang().getLocale(target);
double multiplier = plugin.getLeveler().getMultiplier(target);
sender.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.MULTIPLIER_LIST, locale), "{player}", target.getName(), "{multiplier}", NumberUtil.format2(multiplier), "{percent}", NumberUtil.format2((multiplier - 1) * 100)));
// Send skill specific multipliers if different from global
for (Skill skill : plugin.getSkillRegistry().getSkills()) {
double skillMultiplier = plugin.getLeveler().getMultiplier(target, skill);
if (skillMultiplier != multiplier) {
sender.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.MULTIPLIER_SKILL_ENTRY, locale), "{skill}", skill.getDisplayName(locale), "{multiplier}", NumberUtil.format2(skillMultiplier), "{percent}", NumberUtil.format2((skillMultiplier - 1) * 100)));
}
}
}
use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class SkillsCommand method onArmorRequirementList.
@Subcommand("armor requirement list")
@CommandPermission("aureliumskills.armor.requirement.list")
@Description("Lists the armor requirements on the item held.")
public void onArmorRequirementList(@Flags("itemheld") Player player) {
Locale locale = plugin.getLang().getLocale(player);
player.sendMessage(Lang.getMessage(CommandMessage.ARMOR_REQUIREMENT_LIST_HEADER, locale));
Requirements requirements = new Requirements(plugin);
for (Map.Entry<Skill, Integer> entry : requirements.getRequirements(ModifierType.ARMOR, player.getInventory().getItemInMainHand()).entrySet()) {
player.sendMessage(TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_REQUIREMENT_LIST_ENTRY, locale), "{skill}", entry.getKey().getDisplayName(locale), "{level}", String.valueOf(entry.getValue())));
}
}
use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class AbilityManager method getUnlock.
public int getUnlock(Ability ability) {
AbilityOption option = getAbilityOption(ability);
if (option != null) {
return option.getUnlock();
}
int defUnlock = 2;
Skill skill = ability.getSkill();
for (int i = 0; i < skill.getAbilities().size(); i++) {
if (skill.getAbilities().get(i).get() == ability) {
defUnlock += i;
break;
}
}
return defUnlock;
}
use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class PlayerData method getAbilityLevel.
public int getAbilityLevel(Ability ability) {
Skill skill = ability.getSkill();
RewardTable rewardTable = plugin.getRewardManager().getRewardTable(skill);
if (getSkillLevel(ability.getSkill()) < plugin.getAbilityManager().getUnlock(ability)) {
return 0;
}
int level = (getSkillLevel(ability.getSkill()) - plugin.getAbilityManager().getUnlock(ability)) / plugin.getAbilityManager().getLevelUp(ability) + 1;
// Check max level
if (level <= plugin.getAbilityManager().getMaxLevel(ability) || plugin.getAbilityManager().getMaxLevel(ability) == 0) {
return level;
} else {
return plugin.getAbilityManager().getMaxLevel(ability);
}
}
use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class PlaceholderSupport method onPlaceholderRequest.
@Override
public String onPlaceholderRequest(Player player, String identifier) {
if (player == null) {
return "";
}
// Gets total combined skill level
if (identifier.equals("power")) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
return String.valueOf(playerData.getPowerLevel());
}
}
// Gets HP with scaling as an integer
if (identifier.equals("hp")) {
return String.valueOf(Math.round(player.getHealth() * OptionL.getDouble(Option.HEALTH_HP_INDICATOR_SCALING)));
}
// Gets HP with scaling with 1 decimal
if (identifier.equals("hp_1")) {
return NumberUtil.format1(player.getHealth() * OptionL.getDouble(Option.HEALTH_HP_INDICATOR_SCALING));
}
// Gets max hp
if (identifier.equals("hp_max")) {
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (attribute != null) {
return String.valueOf(Math.round(attribute.getValue() * OptionL.getDouble(Option.HEALTH_HP_INDICATOR_SCALING)));
} else {
return "";
}
}
// Gets HP with scaling with 2 decimal
if (identifier.equals("hp_2")) {
return NumberUtil.format2(player.getHealth() * OptionL.getDouble(Option.HEALTH_HP_INDICATOR_SCALING));
}
// Gets HP Percent as an integer
if (identifier.equals("hp_percent")) {
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (attribute != null) {
return String.valueOf(Math.round(player.getHealth() / attribute.getValue()));
} else {
return "";
}
}
// Gets mana
if (identifier.equals("mana")) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
return String.valueOf(playerData.getMana());
}
}
// Gets mana rounded to an integer
if (identifier.equals("mana_int")) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
return String.valueOf(Math.round(playerData.getMana()));
}
}
// Gets max mana
if (identifier.equals("mana_max")) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
return String.valueOf(playerData.getMaxMana());
}
}
// Gets max mana rounded to an integer
if (identifier.equals("mana_max_int")) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
return String.valueOf(Math.round(playerData.getMaxMana()));
}
}
// Gets stat values
for (Stat stat : plugin.getStatRegistry().getStats()) {
if (identifier.equals(stat.name().toLowerCase(Locale.ENGLISH))) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
return String.valueOf(playerData.getStatLevel(stat));
}
} else if (identifier.equals(stat.name().toLowerCase(Locale.ROOT) + "_int")) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
return String.valueOf(Math.round(playerData.getStatLevel(stat)));
}
}
}
// Gets skill levels
for (Skill skill : plugin.getSkillRegistry().getSkills()) {
if (identifier.equals(skill.name().toLowerCase(Locale.ENGLISH))) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
return String.valueOf(playerData.getSkillLevel(skill));
}
} else if (identifier.equals(skill.name().toLowerCase(Locale.ENGLISH) + "_roman")) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
return RomanNumber.toRoman(playerData.getSkillLevel(skill));
}
}
}
if (identifier.startsWith("lb_")) {
String leaderboardType = TextUtil.replace(identifier, "lb_", "");
if (leaderboardType.startsWith("power_")) {
int place = NumberUtils.toInt(TextUtil.replace(leaderboardType, "power_", ""));
if (place > 0) {
List<SkillValue> list = plugin.getLeaderboardManager().getPowerLeaderboard(place, 1);
if (list.size() > 0) {
SkillValue skillValue = list.get(0);
String name = Bukkit.getOfflinePlayer(skillValue.getId()).getName();
return (name != null ? name : "?") + " - " + skillValue.getLevel();
} else
return "";
} else {
if (identifier.endsWith("name")) {
int namePlace = NumberUtils.toInt(TextUtil.replace(leaderboardType, "power_", "", "_name", ""));
if (namePlace > 0) {
List<SkillValue> list = plugin.getLeaderboardManager().getPowerLeaderboard(namePlace, 1);
if (list.size() > 0) {
SkillValue skillValue = list.get(0);
String name = Bukkit.getOfflinePlayer(skillValue.getId()).getName();
return name != null ? name : "?";
} else
return "";
}
} else if (identifier.endsWith("value")) {
int valuePlace = NumberUtils.toInt(TextUtil.replace(leaderboardType, "power_", "", "_value", ""));
if (valuePlace > 0) {
List<SkillValue> list = plugin.getLeaderboardManager().getPowerLeaderboard(valuePlace, 1);
if (list.size() > 0) {
SkillValue playerSkill = list.get(0);
return String.valueOf(playerSkill.getLevel());
} else
return "";
}
}
}
} else {
for (Skill skill : plugin.getSkillRegistry().getSkills()) {
if (leaderboardType.startsWith(skill.name().toLowerCase(Locale.ENGLISH) + "_")) {
int place = NumberUtils.toInt(TextUtil.replace(leaderboardType, skill.name().toLowerCase(Locale.ENGLISH) + "_", ""));
if (place > 0) {
List<SkillValue> list = plugin.getLeaderboardManager().getLeaderboard(skill, 1, 1);
if (list.size() > 0) {
SkillValue skillValue = list.get(0);
String name = Bukkit.getOfflinePlayer(skillValue.getId()).getName();
return (name != null ? name : "?") + " - " + skillValue.getLevel();
} else
return "";
} else {
if (identifier.endsWith("name")) {
int namePlace = NumberUtils.toInt(TextUtil.replace(leaderboardType, skill.name().toLowerCase(Locale.ENGLISH) + "_", "", "_name", ""));
if (namePlace > 0) {
List<SkillValue> list = plugin.getLeaderboardManager().getLeaderboard(skill, namePlace, 1);
if (list.size() > 0) {
SkillValue skillValue = list.get(0);
String name = Bukkit.getOfflinePlayer(skillValue.getId()).getName();
return name != null ? name : "?";
} else
return "";
}
} else if (identifier.endsWith("value")) {
int valuePlace = NumberUtils.toInt(TextUtil.replace(leaderboardType, skill.name().toLowerCase(Locale.ENGLISH) + "_", "", "_value", ""));
if (valuePlace > 0) {
List<SkillValue> list = plugin.getLeaderboardManager().getLeaderboard(skill, valuePlace, 1);
if (list.size() > 0) {
SkillValue skillValue = list.get(0);
return String.valueOf(skillValue.getLevel());
} else
return "";
}
}
}
}
}
}
}
if (identifier.equals("rank")) {
return String.valueOf(plugin.getLeaderboardManager().getPowerRank(player.getUniqueId()));
}
if (identifier.startsWith("rank_")) {
String skillName = TextUtil.replace(identifier, "rank_", "");
Skill skill = plugin.getSkillRegistry().getSkill(skillName);
if (skill != null) {
return String.valueOf(plugin.getLeaderboardManager().getSkillRank(skill, player.getUniqueId()));
}
}
for (String id : xpIdentifiers) {
if (identifier.startsWith(id)) {
String skillName = TextUtil.replace(identifier, id, "");
Skill skill = plugin.getSkillRegistry().getSkill(skillName);
if (skill != null) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
switch(id) {
case "xp_required_formatted_":
return BigNumber.withSuffix(plugin.getLeveler().getXpRequirements().getXpRequired(skill, playerData.getSkillLevel(skill) + 1));
case "xp_required_":
return String.valueOf(plugin.getLeveler().getXpRequirements().getXpRequired(skill, playerData.getSkillLevel(skill) + 1));
case "xp_progress_int_":
return String.valueOf(Math.round(playerData.getSkillXp(skill) / (double) (plugin.getLeveler().getXpRequirements().getXpRequired(skill, playerData.getSkillLevel(skill) + 1)) * 100));
case "xp_progress_1_":
return NumberUtil.format1(playerData.getSkillXp(skill) / (double) (plugin.getLeveler().getXpRequirements().getXpRequired(skill, playerData.getSkillLevel(skill) + 1)) * 100);
case "xp_progress_":
return String.valueOf(playerData.getSkillXp(skill) / (double) (plugin.getLeveler().getXpRequirements().getXpRequired(skill, playerData.getSkillLevel(skill) + 1)) * 100);
case "xp_int_":
return String.valueOf(Math.round(playerData.getSkillXp(skill)));
case "xp_formatted_":
return BigNumber.withSuffix(Math.round(playerData.getSkillXp(skill)));
case "xp_":
return String.valueOf(playerData.getSkillXp(skill));
}
}
}
}
}
if (identifier.startsWith("multiplier")) {
if (identifier.equals("multiplier")) {
return NumberUtil.format2(plugin.getLeveler().getMultiplier(player));
}
String skillName = TextUtil.replace(identifier, "multiplier_", "");
Skill skill = plugin.getSkillRegistry().getSkill(skillName);
if (skill != null) {
return NumberUtil.format2(plugin.getLeveler().getMultiplier(player, skill));
}
}
if (identifier.startsWith("multiplier_percent")) {
if (identifier.equals("multiplier_percent")) {
return String.valueOf(Math.round((plugin.getLeveler().getMultiplier(player) - 1) * 100));
}
String skillName = TextUtil.replace(identifier, "multiplier_percent_", "");
Skill skill = plugin.getSkillRegistry().getSkill(skillName);
if (skill != null) {
return String.valueOf(Math.round((plugin.getLeveler().getMultiplier(player, skill) - 1) * 100));
}
}
return null;
}
Aggregations