use of com.archyx.aureliumskills.stats.Stat in project AureliumSkills by Archy-X.
the class ModifierManager method reloadPlayer.
public void reloadPlayer(Player player) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
Requirements requirements = new Requirements(plugin);
Modifiers modifiers = new Modifiers(plugin);
Multipliers multipliers = new Multipliers(plugin);
if (playerData != null) {
Set<Stat> statsToReload = new HashSet<>();
ItemStack item = player.getInventory().getItemInMainHand();
if (!(item.getType() == Material.AIR)) {
for (StatModifier modifier : modifiers.getModifiers(ModifierType.ITEM, item)) {
playerData.removeStatModifier(modifier.getName());
statsToReload.add(modifier.getStat());
}
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
playerData.removeMultiplier(multiplier.getName());
}
if (requirements.meetsRequirements(ModifierType.ITEM, item, player)) {
for (StatModifier modifier : modifiers.getModifiers(ModifierType.ITEM, item)) {
playerData.addStatModifier(modifier, false);
statsToReload.add(modifier.getStat());
}
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
playerData.addMultiplier(multiplier);
}
}
}
ItemStack itemOffHand = player.getInventory().getItemInOffHand();
if (!(itemOffHand.getType() == Material.AIR)) {
for (StatModifier modifier : modifiers.getModifiers(ModifierType.ITEM, itemOffHand)) {
playerData.removeStatModifier(modifier.getName() + ".Offhand");
statsToReload.add(modifier.getStat());
}
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, itemOffHand)) {
playerData.removeMultiplier(multiplier.getName() + ".Offhand");
}
if (requirements.meetsRequirements(ModifierType.ITEM, itemOffHand, player)) {
for (StatModifier modifier : modifiers.getModifiers(ModifierType.ITEM, itemOffHand)) {
StatModifier offHandModifier = new StatModifier(modifier.getName() + ".Offhand", modifier.getStat(), modifier.getValue());
playerData.addStatModifier(offHandModifier, false);
statsToReload.add(modifier.getStat());
}
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, itemOffHand)) {
Multiplier offHandMultiplier = new Multiplier(multiplier.getName() + ".Offhand", multiplier.getSkill(), multiplier.getValue());
playerData.addMultiplier(offHandMultiplier);
}
}
}
EntityEquipment equipment = player.getEquipment();
if (equipment != null) {
for (ItemStack armor : equipment.getArmorContents()) {
if (armor != null) {
if (!(armor.getType() == Material.AIR)) {
for (StatModifier modifier : modifiers.getModifiers(ModifierType.ARMOR, armor)) {
playerData.removeStatModifier(modifier.getName());
statsToReload.add(modifier.getStat());
}
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, armor)) {
playerData.removeMultiplier(multiplier.getName());
}
if (requirements.meetsRequirements(ModifierType.ARMOR, armor, player)) {
for (StatModifier modifier : modifiers.getModifiers(ModifierType.ARMOR, armor)) {
playerData.addStatModifier(modifier, false);
statsToReload.add(modifier.getStat());
}
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, armor)) {
playerData.addMultiplier(multiplier);
}
}
}
}
}
}
for (Stat stat : statsToReload) {
statLeveler.reloadStat(player, stat);
}
}
}
use of com.archyx.aureliumskills.stats.Stat in project AureliumSkills by Archy-X.
the class Modifiers method getLegacyModifiers.
public List<StatModifier> getLegacyModifiers(ModifierType type, NBTItem nbtItem) {
if (isNBTDisabled())
return new ArrayList<>();
List<StatModifier> modifiers = new ArrayList<>();
for (String key : nbtItem.getKeys()) {
if (key.contains("skillsmodifier-" + type.name().toLowerCase(Locale.ENGLISH) + "-")) {
String[] keySplit = key.split("-");
if (keySplit.length == 3) {
Stat stat = plugin.getStatRegistry().getStat(key.split("-")[2]);
if (stat != null) {
int value = nbtItem.getInteger(key);
modifiers.add(new StatModifier(key, stat, value));
}
} else if (keySplit.length == 4) {
Stat stat = plugin.getStatRegistry().getStat(key.split("-")[3]);
if (stat != null) {
int value = nbtItem.getInteger(key);
modifiers.add(new StatModifier(key, stat, value));
}
}
}
}
return modifiers;
}
use of com.archyx.aureliumskills.stats.Stat in project AureliumSkills by Archy-X.
the class Modifiers method removeLore.
public void removeLore(ItemStack item, Stat stat, Locale locale) {
ItemMeta meta = item.getItemMeta();
if (meta != null) {
List<String> lore = meta.getLore();
if (lore != null && lore.size() > 0)
lore.removeIf(line -> line.contains(stat.getDisplayName(locale)));
meta.setLore(lore);
}
item.setItemMeta(meta);
}
use of com.archyx.aureliumskills.stats.Stat in project AureliumSkills by Archy-X.
the class SkullItem method getItem.
public ItemStack getItem(Player player, PlayerData playerData, Locale locale) {
ItemStack item = SkullCreator.itemFromUuid(player.getUniqueId());
ItemMeta meta = item.getItemMeta();
if (meta != null) {
meta.setDisplayName(applyPlaceholders(TextUtil.replace(displayName, "{player}", player.getName()), player));
List<String> builtLore = new ArrayList<>();
for (int i = 0; i < lore.size(); i++) {
String line = lore.get(i);
Set<String> placeholders = lorePlaceholders.get(i);
for (String placeholder : placeholders) {
Stat stat = plugin.getStatRegistry().getStat(placeholder);
if (stat != null) {
line = TextUtil.replace(line, "{" + placeholder + "}", TextUtil.replace(Lang.getMessage(MenuMessage.PLAYER_STAT_ENTRY, locale), "{color}", stat.getColor(locale), "{symbol}", stat.getSymbol(locale), "{stat}", stat.getDisplayName(locale), "{level}", NumberUtil.format1(playerData.getStatLevel(stat))));
}
}
builtLore.add(line);
}
meta.setLore(ItemUtils.formatLore(applyPlaceholders(builtLore, player)));
item.setItemMeta(meta);
}
return item;
}
use of com.archyx.aureliumskills.stats.Stat in project AureliumSkills by Archy-X.
the class StatModifier method applyPlaceholders.
public static String applyPlaceholders(String input, StatModifier modifier, Locale locale) {
Stat stat = modifier.getStat();
double value = modifier.getValue();
String name = modifier.getName();
return input.replace("{color}", stat.getColor(locale)).replace("{symbol}", stat.getSymbol(locale)).replace("{stat}", stat.getDisplayName(locale)).replace("{value}", NumberUtil.format1(value)).replace("{name}", name);
}
Aggregations