use of gg.projecteden.nexus.features.menus.SignMenuFactory.ARROWS in project Nexus by ProjectEdenGG.
the class TrustProvider method init.
@Override
public void init(Player player, InventoryContents contents) {
if (back == null)
addCloseItem(contents);
else
addBackItem(contents, e -> back.run());
List<ClickableItem> items = new ArrayList<>();
trust.getAll().stream().map(PlayerUtils::getPlayer).sorted(Comparator.comparing(Nickname::of)).collect(Collectors.toList()).forEach(_player -> {
if (filterType.get() != null)
if (!trust.trusts(filterType.get(), _player))
return;
ItemBuilder builder = new ItemBuilder(Material.PLAYER_HEAD).skullOwner(_player).name("&e" + Nickname.of(_player));
for (Trust.Type type : Trust.Type.values()) {
// TODO Decorations
if (type.equals(Type.DECORATIONS) && !Rank.of(player).isStaff())
continue;
if (trust.trusts(type, _player))
builder.lore("&a" + type.camelCase());
else
builder.lore("&c" + type.camelCase());
}
builder.lore("").lore("&fClick to edit");
items.add(ClickableItem.from(builder.build(), e -> TrustPlayerProvider.open(player, _player)));
});
paginator(player, contents, items);
ItemBuilder add = new ItemBuilder(Material.LIME_CONCRETE_POWDER).name("&aAdd Trust");
contents.set(0, 8, ClickableItem.from(add.build(), e -> Nexus.getSignMenuFactory().lines("", ARROWS, "Enter a", "player's name").prefix(Features.get(TrustFeature.class).getPrefix()).response(lines -> {
if (lines[0].length() > 0) {
OfflinePlayer trusted = PlayerUtils.getPlayer(lines[0]);
TrustPlayerProvider.open(player, trusted);
} else
openMenu(player);
}).open(player)));
Trust.Type previous = filterType.get() == null ? Type.values()[0].previousWithLoop() : filterType.get().previous();
Trust.Type current = filterType.get();
Trust.Type next = filterType.get() == null ? Type.values()[0] : filterType.get().next();
if (current == previous)
previous = null;
if (current == next)
next = null;
ItemBuilder item = new ItemBuilder(Material.HOPPER).name("&6Filter by:").lore("&7⬇ " + (previous == null ? "All" : previous.camelCase())).lore("&e⬇ " + (current == null ? "All" : current.camelCase())).lore("&7⬇ " + (next == null ? "All" : next.camelCase()));
Trust.Type finalNext = next;
contents.set(contents.inventory().getRows() - 1, 4, ClickableItem.from(item.build(), e -> {
filterType.set(finalNext);
refresh();
}));
}
use of gg.projecteden.nexus.features.menus.SignMenuFactory.ARROWS in project Nexus by ProjectEdenGG.
the class EditProductProvider method init.
@Override
public void init(Player player, InventoryContents contents) {
super.init(player, contents);
contents.set(0, 4, ClickableItem.from(product.getItemWithOwnLore().build(), e -> new ExchangeConfigProvider(this, product).open(player)));
if (product.getExchangeType() == ExchangeType.BUY) {
ItemBuilder builder = new ItemBuilder(Material.GOLD_INGOT).name("&6Edit Stock").lore("&7Enter the dollar amount you are").lore("&7willing to spend on this item, or").lore("&7enter -1 to allow unlimited purchases").loreize(false);
contents.set(1, 4, ClickableItem.from(builder.build(), e -> Nexus.getSignMenuFactory().lines("", ARROWS, "Enter an amount", "or -1 for no limit").prefix(Shops.PREFIX).onError(() -> open(player)).response(lines -> {
if (lines[0].length() > 0) {
String input = lines[0].replaceAll("[^\\d.-]+", "");
if (!Utils.isDouble(input))
throw new InvalidInputException("Could not parse &e" + lines[0] + " &cas a dollar amount");
double stock = new BigDecimal(input).setScale(2, RoundingMode.HALF_UP).doubleValue();
if (!(stock == -1 || stock >= 0))
throw new InvalidInputException("Stock must be -1 (unlimited), or $0 or greater");
product.setStock(stock);
service.save(product.getShop());
}
open(player);
}).open(player)));
} else {
contents.set(1, 3, ClickableItem.from(new ItemBuilder(Material.LIME_CONCRETE_POWDER).name("&6Add Stock").lore("&f", "&7Right click to add in bulk").build(), e -> {
if (isRightClick(e)) {
player.closeInventory();
ShopCommand.getInteractStockMap().put(player.getUniqueId(), product);
PlayerUtils.send(player, new JsonBuilder(Shops.PREFIX + "Right click any container (ie chest, shulker box, etc) to stock &e" + pretty(product.getItem()) + "&3. &eClick here to end").command("/shop cancelInteractStock"));
} else {
new AddStockProvider(this, product).open(player);
}
}));
contents.set(1, 5, ClickableItem.from(nameItem(Material.RED_CONCRETE_POWDER, "&6Remove Stock"), e -> new RemoveStockProvider(this, product).open(player)));
}
ItemBuilder purchasable = new ItemBuilder(Material.WHITE_STAINED_GLASS);
if (product.isPurchasable())
purchasable.name("&aPurchasable").lore("&7Click to &cdisable &7purchases").lore("&7Item will still show in your shop,").lore("&7but players cannot purchase it.").lore("&7Can be used for shop organization").loreize(false);
else
purchasable.name("&cNot purchasable").lore("&7Click to &aenable &7purchases");
ItemBuilder enabled = new ItemBuilder(Material.LEVER);
if (product.isEnabled())
enabled.name("&aEnabled").lore("&7Click to &cdisable&7, hiding").lore("&7the item from public view");
else
enabled.name("&cDisabled").lore("&7Click to &aenable&7, allowing others").lore("&7to view and purchase the item");
contents.set(3, 2, ClickableItem.from(purchasable.build(), e -> {
product.setPurchasable(!product.isPurchasable());
service.save(product.getShop());
open(player);
}));
contents.set(3, 4, ClickableItem.from(enabled.build(), e -> {
product.setEnabled(!product.isEnabled());
service.save(product.getShop());
open(player);
}));
contents.set(3, 6, ClickableItem.from(new ItemBuilder(Material.LAVA_BUCKET).name("&cDelete").build(), e -> ConfirmationMenu.builder().onConfirm(e2 -> {
Shop shop = service.get(player);
shop.removeProduct(product);
service.save(shop);
previousMenu.open(player);
}).onCancel(e2 -> open(player)).open(player)));
}
use of gg.projecteden.nexus.features.menus.SignMenuFactory.ARROWS in project Nexus by ProjectEdenGG.
the class ExchangeConfigProvider method addItemSelector.
public void addItemSelector(Player player, InventoryContents contents, int row, AtomicReference<ItemStack> itemStack, boolean allowEditItem) {
ItemStack placeholder = new ItemBuilder(Material.BLACK_STAINED_GLASS).name("&ePlace your item here").lore("&7or click to search for an item").build();
if (!allowEditItem)
contents.set(row, 4, ClickableItem.empty(itemStack.get()));
else {
Consumer<ItemClickData> action = e -> {
((InventoryClickEvent) e.getEvent()).setCancelled(true);
if (!isNullOrAir(player.getItemOnCursor())) {
try {
ItemStack item = player.getItemOnCursor();
if (new ItemBuilder(item).isNot(ItemSetting.TRADEABLE))
throw new InvalidInputException("You can not trade that item in shops");
itemStack.set(item);
PlayerUtils.giveItem(player, itemStack.get().clone());
player.setItemOnCursor(null);
open(player);
} catch (Exception ex) {
PlayerUtils.send(player, Shops.PREFIX + "&c" + ex.getMessage());
open(player);
}
} else if (contents.get(row, 4).isPresent() && contents.get(row, 4).get().getItem().equals(placeholder)) {
Nexus.getSignMenuFactory().lines("", ARROWS, "Enter a", "search term").prefix(Shops.PREFIX).onError(() -> open(player)).response(lines -> {
if (lines[0].length() > 0) {
Function<Material, Boolean> filter = material -> material.name().toLowerCase().contains(lines[0].toLowerCase());
new ItemSearchProvider(this, filter, onChoose -> {
itemStack.set(new ItemStack(onChoose.getItem().getType()));
open(player);
}).open(player);
} else
open(player);
}).open(player);
} else {
itemStack.set(null);
open(player);
}
};
if (itemStack.get() != null)
contents.set(row, 4, ClickableItem.from(itemStack.get(), action));
else
contents.set(row, 4, ClickableItem.from(placeholder, action));
}
if (contents.get(row, 4).isPresent() && contents.get(row, 4).get().getItem() != null && contents.get(row, 4).get().getItem().equals(placeholder)) {
contents.set(row, 2, ClickableItem.empty(less8));
contents.set(row, 3, ClickableItem.empty(less1));
contents.set(row, 5, ClickableItem.empty(more1));
contents.set(row, 6, ClickableItem.empty(more8));
} else {
contents.set(row, 2, ClickableItem.from(less8, e2 -> contents.get(row, 4).ifPresent(i -> {
ItemStack item = i.getItem();
item.setAmount(Math.max(1, Math.min(item.getType().getMaxStackSize(), item.getAmount() == 64 ? 56 : item.getAmount() - 8)));
open(player);
})));
contents.set(row, 3, ClickableItem.from(less1, e2 -> contents.get(row, 4).ifPresent(i -> {
ItemStack item = i.getItem();
item.setAmount(Math.max(1, Math.min(item.getType().getMaxStackSize(), item.getAmount() - 1)));
open(player);
})));
contents.set(row, 5, ClickableItem.from(more1, e2 -> contents.get(row, 4).ifPresent(i -> {
ItemStack item = i.getItem();
item.setAmount(Math.min(64, Math.min(item.getType().getMaxStackSize(), item.getAmount() + 1)));
open(player);
})));
contents.set(row, 6, ClickableItem.from(more8, e2 -> contents.get(row, 4).ifPresent(i -> {
ItemStack item = i.getItem();
item.setAmount(Math.min(64, Math.min(item.getType().getMaxStackSize(), item.getAmount() == 1 ? 8 : item.getAmount() + 8)));
open(player);
})));
}
}
Aggregations