Skip to content

Commit

Permalink
Fix NPE in SkillAPIAttributes editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sentropic committed Jun 25, 2023
1 parent d850c62 commit ea89b61
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import su.nightexpress.quantumrpg.QuantumRPG;
Expand Down Expand Up @@ -182,7 +183,17 @@ public Collection<SkillAPIAttribute> getAttributes() {
}

public ItemStack getAttributeIndicator(String attributeId) {
return SkillAPI.getAttributeManager().getAttribute(attributeId).getToolIcon();
AttributeManager.Attribute attribute = SkillAPI.getAttributeManager().getAttribute(attributeId);
if (attribute == null) {
ItemStack itemStack = new ItemStack(Material.DIRT);
ItemMeta meta = itemStack.getItemMeta();
if (meta != null) {
meta.setDisplayName(attributeId);
itemStack.setItemMeta(meta);
}
return itemStack;
}
return attribute.getToolIcon();
}

private Map<String,Integer> getAbilities(ItemStack item) {
Expand Down

0 comments on commit ea89b61

Please sign in to comment.