001package net.tnemc.item.example;
002
003import net.kyori.adventure.text.minimessage.MiniMessage;
004import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
005import net.tnemc.item.bukkit.BukkitItemStack;
006import net.tnemc.item.bukkit.platform.BukkitItemPlatform;
007import net.tnemc.item.example.command.TNILCountCommand;
008import net.tnemc.item.example.command.TNILGiveCommand;
009import net.tnemc.item.example.command.TNILTakeCommand;
010import org.bukkit.Bukkit;
011import org.bukkit.plugin.java.JavaPlugin;
012import net.tnemc.item.example.listeners.PlayerJoinListener;
013
014import java.util.Arrays;
015
016public class Example extends JavaPlugin {
017
018  private static Example instance;
019
020  BukkitItemPlatform platform;
021  BukkitItemStack item;
022  BukkitItemStack nexoItem;
023
024  @Override
025  public void onEnable() {
026
027    this.platform = BukkitItemPlatform.instance();
028    this.item = this.build();
029    this.nexoItem = this.buildNexo();
030    instance = this;
031
032    Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(), this);
033
034    getCommand("tnilcount").setExecutor(new TNILCountCommand());
035    getCommand("tniltake").setExecutor(new TNILTakeCommand());
036    getCommand("tnilgive").setExecutor(new TNILGiveCommand());
037  }
038
039  @Override
040  public void onDisable() {
041    super.onDisable();
042  }
043
044  private BukkitItemStack build() {
045    return this.platform.createStack("gold_ingot")
046            .amount(10)
047            .itemName(MiniMessage.miniMessage().deserialize("<gold>Test"))
048            .lore(Arrays.asList(
049                    MiniMessage.miniMessage().deserialize("<gradient:#5e4fa2:#f79459>This is a test item from the new TNIL library"),
050                    MiniMessage.miniMessage().deserialize("<gradient:#5e4fa2:#f79459>This currency item can only be stacked to 10")
051                               ))
052            .maxStackSize(10);
053  }
054
055  private BukkitItemStack buildNexo() {
056    return this.platform.createStack("paper")
057            .setProviderItemID("forest_axe")
058            .setItemProvider("nexo");
059  }
060
061  public BukkitItemPlatform getPlatform() {
062    return platform;
063  }
064
065  public BukkitItemStack getItem() {
066    return item;
067  }
068
069  public BukkitItemStack getNexoItem() {
070    return nexoItem;
071  }
072
073  public static Example instance() {
074    return instance;
075  }
076}