use of com.archyx.aureliumskills.menu.templates.InProgressTemplate in project AureliumSkills by Archy-X.
the class LevelProgressionMenu method init.
@Override
public void init(Player player, InventoryContents contents) {
int currentLevel = playerData.getSkillLevel(skill);
// Fill item
if (options.isFillEnabled()) {
contents.fill(ClickableItem.empty(options.getFillItem()));
}
SkillItem skillItem = (SkillItem) options.getItem(ItemType.SKILL);
contents.set(skillItem.getPos(), ClickableItem.empty(skillItem.getItem(skill, playerData, player, locale)));
BackItem backItem = (BackItem) options.getItem(ItemType.BACK);
contents.set(backItem.getPos(), ClickableItem.of(backItem.getItem(player, locale), e -> SkillsMenu.getInventory(player, plugin).open(player)));
CloseItem closeItem = (CloseItem) options.getItem(ItemType.CLOSE);
contents.set(closeItem.getPos(), ClickableItem.of(closeItem.getItem(player, locale), e -> player.closeInventory()));
RankItem rankItem = (RankItem) options.getItem(ItemType.RANK);
contents.set(rankItem.getPos(), ClickableItem.empty(rankItem.getItem(skill, player, locale)));
Pagination pagination = contents.pagination();
ClickableItem[] items = new ClickableItem[36 * pages];
if (options.isFillEnabled() && options.getFillItem() != null) {
for (int i = 0; i < items.length; i++) {
items[i] = ClickableItem.empty(options.getFillItem());
}
}
UnlockedTemplate unlocked = (UnlockedTemplate) options.getTemplate(TemplateType.UNLOCKED);
InProgressTemplate inProgress = (InProgressTemplate) options.getTemplate(TemplateType.IN_PROGRESS);
LockedTemplate locked = (LockedTemplate) options.getTemplate(TemplateType.LOCKED);
for (int i = pagination.getPage() * 24; i < pagination.getPage() * 24 + 24; i++) {
if (i + 2 <= OptionL.getMaxLevel(skill)) {
if (i + 2 <= currentLevel) {
items[track.get(i)] = ClickableItem.empty(unlocked.getItem(skill, i + 2, player, locale));
} else if (i + 2 == currentLevel + 1) {
items[track.get(i)] = ClickableItem.empty(inProgress.getItem(skill, playerData, i + 2, player, locale));
} else {
items[track.get(i)] = ClickableItem.empty(locked.getItem(skill, i + 2, player, locale));
}
} else {
if (options.isFillEnabled() && options.getFillItem() != null) {
items[track.get(i)] = ClickableItem.empty(options.getFillItem());
} else {
items[track.get(i)] = ClickableItem.empty(new ItemStack(Material.AIR));
}
}
}
pagination.setItems(items);
pagination.setItemsPerPage(36);
int a = 0;
for (int i = 9; i < 45; i++) {
int row = i / 9;
int column = i % 9;
contents.set(row, column, pagination.getPageItems()[a]);
a++;
}
NextPageItem nextPageItem = (NextPageItem) options.getItem(ItemType.NEXT_PAGE);
if (pagination.getPage() + 1 < pages) {
contents.set(nextPageItem.getPos(), ClickableItem.of(nextPageItem.getItem(player, locale), e -> {
int page = pagination.next().getPage();
SmartInventory inventory = getInventory(player, skill, page, plugin);
if (inventory != null) {
inventory.open(player, page);
}
}));
}
PreviousPageItem previousPageItem = (PreviousPageItem) options.getItem(ItemType.PREVIOUS_PAGE);
if (pagination.getPage() - 1 >= 0) {
contents.set(previousPageItem.getPos(), ClickableItem.of(previousPageItem.getItem(player, locale), e -> {
int previous = pagination.previous().getPage();
SmartInventory inventory = getInventory(player, skill, previous, plugin);
if (inventory != null) {
inventory.open(player, previous);
}
}));
}
}
Aggregations