9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2026-01-04 15:41:45 +00:00

More placeholders

This commit is contained in:
Fisher2911
2022-02-17 17:05:41 -05:00
parent c75182d118
commit eec995a7f3
2 changed files with 20 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -264,6 +265,12 @@ public class ArmorItem extends GuiItem {
return new ArmorItem(this);
}
public String getItemName() {
final ItemMeta itemMeta = this.getItemStack(true).getItemMeta();
if (itemMeta == null) return this.id;
return itemMeta.getDisplayName();
}
public enum Type {
HAT(EquipmentSlot.HEAD),

View File

@@ -67,19 +67,30 @@ public class PAPIExpansion extends PlaceholderExpansion {
}
// %hmccosmetics_current_type%
if (parts[0].equals("current")) {
if (parts[0].startsWith("current")) {
final boolean formatted = parts[0].contains("formatted");
if (parts.length >= 2) {
final String typeStr = getId(parts, 1);
try {
final ArmorItem.Type type = ArmorItem.Type.valueOf(typeStr.toUpperCase());
for (final ArmorItem item : user.getPlayerArmor().getArmorItems()) {
if (item.getType().equals(type)) return item.getId();
if (item.getType().equals(type)) {
if (formatted) {
return item.getItemName();
}
return item.getId();
}
}
return Translation.translate(Translation.NONE);
} catch (final IllegalArgumentException exception) {
return null;
}
}
return null;
}
if (parts[0].equals("wardrobe-enabled")) {
return Translation.translate(String.valueOf(user.getWardrobe().isActive()));
}
return null;