Added placeholder for skill modifiers relative to ticket #829.

This commit is contained in:
Ka0rX 2023-05-13 11:46:29 +01:00
parent 15a8e6e796
commit 0627c73378

View File

@ -12,6 +12,7 @@ import net.Indyuce.mmocore.api.quest.PlayerQuests;
import net.Indyuce.mmocore.experience.PlayerProfessions;
import net.Indyuce.mmocore.experience.Profession;
import net.Indyuce.mmocore.party.AbstractParty;
import net.Indyuce.mmocore.skill.ClassSkill;
import net.Indyuce.mmocore.skill.RegisteredSkill;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -72,15 +73,19 @@ public class RPGPlaceholders extends PlaceholderExpansion {
String id = identifier.substring(12);
RegisteredSkill skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(id), "Could not find skill with ID '" + id + "'");
return String.valueOf(playerData.getSkillLevel(skill));
}
else if(identifier.startsWith("mmocore_attribute_points_spent_")){
String attributeId=identifier.substring(31);
PlayerAttributes.AttributeInstance attributeInstance=Objects.requireNonNull(playerData.getAttributes().getInstance(attributeId),"Could not find attribute with ID '"+attributeId+"'");
} else if (identifier.startsWith("skill_modifier_")) {
String[] ids = identifier.substring(15).split(":");
String modifierId = ids[0];
String skillId = ids[1];
RegisteredSkill skill = Objects.requireNonNull(MMOCore.plugin.skillManager.getSkill(skillId), "Could not find skill with ID '" + skillId + "'");
ClassSkill classSkill = playerData.getProfess().getSkill(skill);
double value = classSkill.toCastable(playerData).getModifier(modifierId);
return MythicLib.plugin.getMMOConfig().decimal.format(value);
} else if (identifier.startsWith("mmocore_attribute_points_spent_")) {
String attributeId = identifier.substring(31);
PlayerAttributes.AttributeInstance attributeInstance = Objects.requireNonNull(playerData.getAttributes().getInstance(attributeId), "Could not find attribute with ID '" + attributeId + "'");
return String.valueOf(attributeInstance.getSpent());
}
else if (identifier.equals("level_percent")) {
} else if (identifier.equals("level_percent")) {
double current = playerData.getExperience(), next = playerData.getLevelUpExperience();
return MythicLib.plugin.getMMOConfig().decimal.format(current / next * 100);
} else if (identifier.equals("health"))
@ -139,9 +144,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
else if (identifier.startsWith("party_count")) {
final @Nullable AbstractParty party = playerData.getParty();
return party == null ? "0" : String.valueOf(party.countMembers());
}
else if (identifier.startsWith("party_member_")) {
} else if (identifier.startsWith("party_member_")) {
final int n = Integer.parseInt(identifier.substring(13)) - 1;
final @Nullable AbstractParty party = playerData.getParty();
if (party == null) return ERROR_PLACEHOLDER;
@ -149,24 +152,18 @@ public class RPGPlaceholders extends PlaceholderExpansion {
final @Nullable PlayerData member = party.getMember(n);
if (member == null) return ERROR_PLACEHOLDER;
return member.getPlayer().getName();
}
else if (identifier.equals("online_friends")) {
} else if (identifier.equals("online_friends")) {
int count = 0;
for (UUID friendId : playerData.getFriends())
if (Bukkit.getPlayer(friendId) != null) count++;
return String.valueOf(count);
}
else if (identifier.startsWith("online_friend_")) {
} else if (identifier.startsWith("online_friend_")) {
final int n = Integer.parseInt(identifier.substring(14)) - 1;
if (n >= playerData.getFriends().size()) return ERROR_PLACEHOLDER;
final @Nullable Player friend = Bukkit.getPlayer(playerData.getFriends().get(n));
if (friend == null) return ERROR_PLACEHOLDER;
return friend.getName();
}
else if (identifier.startsWith("profession_"))
} else if (identifier.startsWith("profession_"))
return String
.valueOf(playerData.getCollectionSkills().getLevel(identifier.substring(11).replace(" ", "-").replace("_", "-").toLowerCase()));
@ -202,15 +199,11 @@ public class RPGPlaceholders extends PlaceholderExpansion {
String format = identifier.substring(15).toLowerCase().replace("_", "-").replace(" ", "-");
Profession profession = format.equals("main") ? null : MMOCore.plugin.professionManager.get(format);
return MythicLib.plugin.getMMOConfig().decimal.format(MMOCore.plugin.boosterManager.getMultiplier(profession) * 100);
}
else if (identifier.startsWith("exp_boost_")) {
} else if (identifier.startsWith("exp_boost_")) {
String format = identifier.substring(10).toLowerCase().replace("_", "-").replace(" ", "-");
Profession profession = format.equals("main") ? null : MMOCore.plugin.professionManager.get(format);
return MythicLib.plugin.getMMOConfig().decimal.format((MMOCore.plugin.boosterManager.getMultiplier(profession) - 1) * 100);
}
else if (identifier.equals("stamina"))
} else if (identifier.equals("stamina"))
return MythicLib.plugin.getMMOConfig().decimal.format(playerData.getStamina());
else if (identifier.equals("stamina_bar")) {
@ -221,14 +214,10 @@ public class RPGPlaceholders extends PlaceholderExpansion {
: ratio >= j - .5 ? MMOCore.plugin.configManager.staminaHalf : MMOCore.plugin.configManager.staminaEmpty)
.append(AltChar.listSquare);
return format.toString();
}
else if (identifier.startsWith("stat_")) {
} else if (identifier.startsWith("stat_")) {
final String stat = UtilityMethods.enumName(identifier.substring(5));
return StatManager.format(stat, playerData.getMMOPlayerData());
}
else if (identifier.equals("stellium"))
} else if (identifier.equals("stellium"))
return MythicLib.plugin.getMMOConfig().decimal.format(playerData.getStellium());
else if (identifier.equals("stellium_bar")) {
@ -237,25 +226,17 @@ public class RPGPlaceholders extends PlaceholderExpansion {
for (double j = 1; j < 20; j++)
format.append(ratio >= j ? ChatColor.BLUE : ratio >= j - .5 ? ChatColor.AQUA : ChatColor.WHITE).append(AltChar.listSquare);
return format.toString();
}
else if (identifier.equals("quest")) {
} else if (identifier.equals("quest")) {
PlayerQuests data = playerData.getQuestData();
return data.hasCurrent() ? data.getCurrent().getQuest().getName() : "None";
}
else if (identifier.equals("quest_progress")) {
} else if (identifier.equals("quest_progress")) {
PlayerQuests data = playerData.getQuestData();
return data.hasCurrent() ? MythicLib.plugin.getMMOConfig().decimal
.format( (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100L) : "0";
}
else if (identifier.equals("quest_objective")) {
.format((double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100L) : "0";
} else if (identifier.equals("quest_objective")) {
PlayerQuests data = playerData.getQuestData();
return data.hasCurrent() ? data.getCurrent().getFormattedLore() : "None";
}
else if (identifier.startsWith("guild_")) {
} else if (identifier.startsWith("guild_")) {
String placeholder = identifier.substring(6);
if (playerData.getGuild() == null)
return "";