mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-29 01:05:40 +01:00
Added the possibilty to have force a specific item to appear when a skill is bound to a slot for the skill UI.
This commit is contained in:
parent
1607b0f773
commit
40b59e4b70
@ -172,12 +172,17 @@ public class SkillList extends EditableInventory {
|
|||||||
|
|
||||||
public class SlotItem extends InventoryItem<SkillViewerInventory> {
|
public class SlotItem extends InventoryItem<SkillViewerInventory> {
|
||||||
private final String none;
|
private final String none;
|
||||||
private final int emptyCMD;
|
@Nullable
|
||||||
|
private final Material filledItem;
|
||||||
|
private final int filledCMD;
|
||||||
|
|
||||||
public SlotItem(ConfigurationSection config) {
|
public SlotItem(ConfigurationSection config) {
|
||||||
super(config);
|
super(config);
|
||||||
none = MythicLib.plugin.parseColors(config.getString("no-skill"));
|
none = MythicLib.plugin.parseColors(config.getString("no-skill"));
|
||||||
emptyCMD = config.getInt("empty-custom-model-data", getModelData());
|
|
||||||
|
filledItem = config.contains("filled-item") ? Material
|
||||||
|
.valueOf(config.getString("filled-item").toUpperCase().replace("-", "_").replace(" ", "_")) : null;
|
||||||
|
filledCMD = config.getInt("filled-custom-model-data", getModelData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -187,13 +192,21 @@ public class SkillList extends EditableInventory {
|
|||||||
return new ItemStack(Material.AIR);
|
return new ItemStack(Material.AIR);
|
||||||
|
|
||||||
final @Nullable ClassSkill boundSkill = inv.getPlayerData().getBoundSkill(n + 1);
|
final @Nullable ClassSkill boundSkill = inv.getPlayerData().getBoundSkill(n + 1);
|
||||||
final ItemStack item = super.display(inv, n);
|
ItemStack item;
|
||||||
|
if (boundSkill == null)
|
||||||
|
item = super.display(inv, n);
|
||||||
|
else if (filledItem == null)
|
||||||
|
item = boundSkill.getSkill().getIcon();
|
||||||
|
else {
|
||||||
|
item = new ItemStack(filledItem);
|
||||||
|
if (MythicLib.plugin.getVersion().isStrictlyHigher(1, 13)) {
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
meta.setCustomModelData(filledCMD);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
Placeholders holders = getPlaceholders(inv, n);
|
Placeholders holders = getPlaceholders(inv, n);
|
||||||
|
|
||||||
// Same material as skill
|
|
||||||
if (boundSkill != null)
|
|
||||||
item.setType(boundSkill.getSkill().getIcon().getType());
|
|
||||||
|
|
||||||
final ItemMeta meta = item.getItemMeta();
|
final ItemMeta meta = item.getItemMeta();
|
||||||
meta.setDisplayName(MMOCore.plugin.placeholderParser.parse(inv.getPlayerData().getPlayer(), skillSlot.getName()));
|
meta.setDisplayName(MMOCore.plugin.placeholderParser.parse(inv.getPlayerData().getPlayer(), skillSlot.getName()));
|
||||||
|
|
||||||
@ -217,9 +230,6 @@ public class SkillList extends EditableInventory {
|
|||||||
for (int j = 0; j < lore.size(); j++)
|
for (int j = 0; j < lore.size(); j++)
|
||||||
lore.set(j, ChatColor.GRAY + holders.apply(inv.getPlayer(), lore.get(j)));
|
lore.set(j, ChatColor.GRAY + holders.apply(inv.getPlayer(), lore.get(j)));
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
// Same CMD as skill icon
|
|
||||||
if (boundSkill != null && boundSkill.getSkill().getIcon().hasItemMeta() && boundSkill.getSkill().getIcon().getItemMeta().hasCustomModelData())
|
|
||||||
meta.setCustomModelData(boundSkill.getSkill().getIcon().getItemMeta().getCustomModelData());
|
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
return item;
|
return item;
|
||||||
|
@ -53,6 +53,11 @@ items:
|
|||||||
|
|
||||||
name: '&aSkill Slot {slot}'
|
name: '&aSkill Slot {slot}'
|
||||||
no-skill: '&cNone'
|
no-skill: '&cNone'
|
||||||
|
|
||||||
|
#If this is filled, the item shown in the GUI when a slot is filled will be the item specified here.
|
||||||
|
#Else it will be the display item of the bound skill.
|
||||||
|
#filled-item:
|
||||||
|
#filled-custom-model-data:
|
||||||
lore:
|
lore:
|
||||||
- '&7Current Skill: &6{skill}'
|
- '&7Current Skill: &6{skill}'
|
||||||
- ''
|
- ''
|
||||||
|
Loading…
Reference in New Issue
Block a user