Added a "selected" item that replicates the skill that is selected in skill list GUI.

This commit is contained in:
Ka0rX 2023-04-16 18:15:24 +01:00
parent afe3eec3fb
commit a1e817f22c

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmocore.gui;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem;
import me.ulrich.clans.manager.I;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.SoundEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
@ -88,6 +89,8 @@ public class SkillList extends EditableInventory {
}
};
}
if(function.equals("selected"))
return new SelectedItem(config);
return new SimplePlaceholderItem(config);
}
@ -96,6 +99,30 @@ public class SkillList extends EditableInventory {
return new SkillViewerInventory(data, this);
}
public class SelectedItem extends InventoryItem<SkillViewerInventory> {
public SelectedItem(ConfigurationSection config) {
super(config);
}
@Override
public ItemStack display(SkillViewerInventory inv, int n) {
ItemStack item =super.display(inv, n);
if(inv.selected== null)
return new ItemStack(Material.AIR);
if (inv.selected != null) {
item.setType(inv.selected.getSkill().getIcon().getType());
}
return item;
}
@Override
public Placeholders getPlaceholders(SkillViewerInventory inv, int n) {
Placeholders holders= new Placeholders();
holders.register("selected", inv.selected.getSkill().getName());
return holders;
}
}
public class LevelItem extends InventoryItem<SkillViewerInventory> {
private final int offset;