Search in sources :

Example 1 with SlotIterator

use of gg.projecteden.nexus.features.menus.api.content.SlotIterator in project Nexus by ProjectEdenGG.

the class AdventMenu method init.

@Override
public void init() {
    int row = 1;
    int column = Pugmas21.EPOCH.getDayOfWeek().getValue() + 1;
    final SlotIterator slotIterator = innerSlotIterator(contents, SlotPos.of(row, column));
    for (int day = 1; day <= 25; day++) {
        final int _day = day;
        final LocalDate date = Pugmas21.EPOCH.plusDays(_day - 1);
        final Icon icon = getIcon(date);
        final ItemBuilder item = new ItemBuilder(icon.getItem(_day));
        ClickableItem clickableItem = ClickableItem.empty(item.build());
        if (user.advent().hasFound(_day)) {
            item.lore("", "&aShow Waypoint");
            clickableItem = ClickableItem.of(item.build(), e -> {
                player.closeInventory();
                Advent.glow(user, _day);
            });
        }
        slotIterator.next().set(clickableItem);
    }
    updateTask(player, contents);
}
Also used : ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) AdventPresent(gg.projecteden.nexus.models.pugmas21.Advent21Config.AdventPresent) NonNull(lombok.NonNull) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Tasks(gg.projecteden.nexus.utils.Tasks) InventoryContents(gg.projecteden.nexus.features.menus.api.content.InventoryContents) Player(org.bukkit.entity.Player) ClickableItem(gg.projecteden.nexus.features.menus.api.ClickableItem) SlotIterator(gg.projecteden.nexus.features.menus.api.content.SlotIterator) IteratableEnum(gg.projecteden.utils.EnumUtils.IteratableEnum) Advent21Config(gg.projecteden.nexus.models.pugmas21.Advent21Config) Pugmas21User(gg.projecteden.nexus.models.pugmas21.Pugmas21User) SlotPos(gg.projecteden.nexus.features.menus.api.content.SlotPos) LocalDate(java.time.LocalDate) InventoryProvider(gg.projecteden.nexus.features.menus.api.content.InventoryProvider) StringUtils.colorize(gg.projecteden.nexus.utils.StringUtils.colorize) Pugmas21(gg.projecteden.nexus.features.events.y2021.pugmas21.Pugmas21) AllArgsConstructor(lombok.AllArgsConstructor) NotNull(org.jetbrains.annotations.NotNull) Material(org.bukkit.Material) MenuUtils.innerSlotIterator(gg.projecteden.nexus.features.menus.MenuUtils.innerSlotIterator) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) SlotIterator(gg.projecteden.nexus.features.menus.api.content.SlotIterator) MenuUtils.innerSlotIterator(gg.projecteden.nexus.features.menus.MenuUtils.innerSlotIterator) ClickableItem(gg.projecteden.nexus.features.menus.api.ClickableItem) LocalDate(java.time.LocalDate)

Example 2 with SlotIterator

use of gg.projecteden.nexus.features.menus.api.content.SlotIterator in project Nexus by ProjectEdenGG.

the class MenuUtils method innerSlotIterator.

public static SlotIterator innerSlotIterator(InventoryContents contents, SlotPos start) {
    final SlotIterator slotIterator = contents.newIterator(Type.HORIZONTAL, start);
    final int rows = contents.inventory().getRows();
    for (int i = 0; i < rows * COLUMNS; i++) if (i < COLUMNS || i % COLUMNS == 0 || (i + 1) % COLUMNS == 0 || i >= (rows - 1) * COLUMNS)
        slotIterator.blacklist(i);
    return slotIterator;
}
Also used : SlotIterator(gg.projecteden.nexus.features.menus.api.content.SlotIterator)

Aggregations

SlotIterator (gg.projecteden.nexus.features.menus.api.content.SlotIterator)2 Pugmas21 (gg.projecteden.nexus.features.events.y2021.pugmas21.Pugmas21)1 MenuUtils.innerSlotIterator (gg.projecteden.nexus.features.menus.MenuUtils.innerSlotIterator)1 ClickableItem (gg.projecteden.nexus.features.menus.api.ClickableItem)1 InventoryContents (gg.projecteden.nexus.features.menus.api.content.InventoryContents)1 InventoryProvider (gg.projecteden.nexus.features.menus.api.content.InventoryProvider)1 SlotPos (gg.projecteden.nexus.features.menus.api.content.SlotPos)1 Advent21Config (gg.projecteden.nexus.models.pugmas21.Advent21Config)1 AdventPresent (gg.projecteden.nexus.models.pugmas21.Advent21Config.AdventPresent)1 Pugmas21User (gg.projecteden.nexus.models.pugmas21.Pugmas21User)1 ItemBuilder (gg.projecteden.nexus.utils.ItemBuilder)1 StringUtils.colorize (gg.projecteden.nexus.utils.StringUtils.colorize)1 Tasks (gg.projecteden.nexus.utils.Tasks)1 IteratableEnum (gg.projecteden.utils.EnumUtils.IteratableEnum)1 LocalDate (java.time.LocalDate)1 AllArgsConstructor (lombok.AllArgsConstructor)1 NonNull (lombok.NonNull)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 Material (org.bukkit.Material)1 Player (org.bukkit.entity.Player)1