Skip to content

Commit

Permalink
feat: make item creation parse placeholderapi
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaffa48 committed Jan 24, 2025
1 parent d377696 commit 784e217
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/com/muhammaddaffa/mdlib/utils/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import com.cryptomorin.xseries.profiles.builder.XSkull;
import com.cryptomorin.xseries.profiles.objects.ProfileInputType;
import com.cryptomorin.xseries.profiles.objects.Profileable;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment;
Expand Down Expand Up @@ -311,6 +309,12 @@ public static ItemBuilder fromConfig(ConfigurationSection section, @Nullable Pla
materialString = placeholder.translate(materialString);
}

if (isPlaceholderAPI()) {
materialString = PlaceholderAPI.setPlaceholders(null, materialString);
displayName = PlaceholderAPI.setPlaceholders(null, displayName);
lore = PlaceholderAPI.setPlaceholders(null, lore);
}

// start building the itemstack
ItemBuilder builder;
if (materialString.contains(";")) {
Expand Down Expand Up @@ -380,6 +384,10 @@ public ItemStack build() {
return this.item;
}

private static boolean isPlaceholderAPI() {
return Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
}

private static boolean isValidItemFlag(String flag) {
try {
ItemFlag.valueOf(flag.toUpperCase());
Expand Down

0 comments on commit 784e217

Please sign in to comment.