Added rarity placeholders

This commit is contained in:
BuildTools 2020-11-13 12:27:57 +00:00
parent fede492f11
commit 1e8d93269e
2 changed files with 30 additions and 0 deletions

View File

@ -149,6 +149,12 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Regist
}
private void updatePlaceholders() {
PlaceholderManager.registerPlaceholder(
new PlaceholderEntry(this.getPermissionName() + "_" + "enabled", (player) -> {
return String.valueOf(this.isEnabled());
})
);
if(this.getConfig().config.get(EcoEnchants.CONFIG_LOCATION + "chance-per-level") != null) {
PlaceholderManager.registerPlaceholder(
new PlaceholderEntry(this.getPermissionName() + "_" + "chance_per_level", (player) -> {

View File

@ -1,6 +1,9 @@
package com.willfp.ecoenchants.enchantments.meta;
import com.willfp.ecoenchants.config.ConfigManager;
import com.willfp.ecoenchants.integrations.placeholder.PlaceholderEntry;
import com.willfp.ecoenchants.integrations.placeholder.PlaceholderManager;
import com.willfp.ecoenchants.util.NumberUtils;
import com.willfp.ecoenchants.util.StringUtils;
import com.willfp.ecoenchants.util.interfaces.Registerable;
@ -44,6 +47,27 @@ public class EnchantmentRarity implements Registerable {
Optional<EnchantmentRarity> matching = rarities.stream().filter(rarity -> rarity.getName().equalsIgnoreCase(name)).findFirst();
matching.ifPresent(rarities::remove);
PlaceholderManager.registerPlaceholder(new PlaceholderEntry(
"rarity_" + this.getName() + "_probability",
(player) -> NumberUtils.format(this.probability)
));
PlaceholderManager.registerPlaceholder(new PlaceholderEntry(
"rarity_" + this.getName() + "_minlevel",
(player) -> NumberUtils.format(this.minimumLevel)
));
PlaceholderManager.registerPlaceholder(new PlaceholderEntry(
"rarity_" + this.getName() + "_villagerprobability",
(player) -> NumberUtils.format(this.villagerProbability)
));
PlaceholderManager.registerPlaceholder(new PlaceholderEntry(
"rarity_" + this.getName() + "_lootprobability",
(player) -> NumberUtils.format(this.lootProbability)
));
PlaceholderManager.registerPlaceholder(new PlaceholderEntry(
"rarity_" + this.getName() + "_color",
(player) -> this.customColor
));
rarities.add(this);
}