use of gg.projecteden.nexus.utils.ItemBuilder in project Nexus by ProjectEdenGG.
the class CombinationLockProvider method parseCode.
public void parseCode(Player player, InventoryContents contents) {
int[][] groups = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } };
boolean[] correct = { false, false, false };
for (int i = 0; i < groups.length; i++) {
if (!isNullOrEmpty(playerCode) && playerCode.length() == CORRECT_CODE.length())
for (int j = 0; j < groups[i].length; j++) if (playerCode.charAt(groups[i][j]) == CORRECT_CODE.charAt(groups[i][j]))
correct[i] = true;
else {
correct[i] = false;
break;
}
for (int j = 0; j < groups[i].length; j++) {
Material mat = correct[i] ? Material.LIME_STAINED_GLASS_PANE : Material.RED_STAINED_GLASS_PANE;
contents.set(4, groups[i][j], ClickableItem.empty(new ItemBuilder(mat).name(" ").build()));
}
}
Tasks.wait(TickTime.SECOND.x(5), () -> {
if (correct[0] && correct[1] && correct[2])
complete(player);
else {
SmartInventory inv = SmartInvsPlugin.manager().getInventory(player).orElse(null);
if (inv != null && inv.getProvider() == this)
Halloween20Menus.openComboLock(player);
}
});
}
use of gg.projecteden.nexus.utils.ItemBuilder in project Nexus by ProjectEdenGG.
the class CombinationLockProvider method init.
@Override
public void init(Player player, InventoryContents contents) {
contents.fill(ClickableItem.empty(new ItemBuilder(Material.YELLOW_STAINED_GLASS_PANE).name(" ").build()));
contents.fillRow(1, ClickableItem.empty(new ItemStack(Material.AIR)));
contents.fillRow(4, ClickableItem.empty(new ItemStack(Material.AIR)));
contents.set(2, 3, ClickableItem.empty(new ItemStack(Material.AIR)));
contents.set(2, 5, ClickableItem.empty(new ItemStack(Material.AIR)));
contents.set(5, 7, ClickableItem.from(new ItemBuilder(Material.LIME_WOOL).name("&aSubmit Code").build(), e -> {
parseCode(player, contents);
}));
contents.set(5, 8, ClickableItem.from(new ItemBuilder(Material.RED_WOOL).name("&cReset").build(), e -> Halloween20Menus.openComboLock(player)));
int[] numberSlots = { 9, 10, 11, 12, 13, 14, 15, 16, 17, 21, 23 };
Halloween20Service service = new Halloween20Service();
Halloween20User user = service.get(player);
for (int i = 0; i < user.getFoundComboLockNumbers().size(); i++) {
int j = i;
contents.set(numberSlots[i], ClickableItem.from(new ItemBuilder(user.getFoundComboLockNumbers().get(i).getItem()).name("&e" + user.getFoundComboLockNumbers().get(i).getNumericalValue()).build(), e -> {
if (foundIndex == 9)
return;
contents.set(numberSlots[j], ClickableItem.empty(new ItemStack(Material.AIR)));
contents.set(4, foundIndex++, ClickableItem.empty(new ItemBuilder(user.getFoundComboLockNumbers().get(j).getItem()).name("&e" + user.getFoundComboLockNumbers().get(j).getNumericalValue()).build()));
playerCode += user.getFoundComboLockNumbers().get(j).getNumericalValue();
}));
}
}
use of gg.projecteden.nexus.utils.ItemBuilder in project Nexus by ProjectEdenGG.
the class Pride20Listener method onSecretCatClick.
@EventHandler
public void onSecretCatClick(NPCRightClickEvent event) {
if (event.getNPC().getId() != 2776)
return;
Player player = event.getClicker();
SettingService service = new SettingService();
Setting setting = service.get(player, "pride20Secret");
if (setting.getBoolean()) {
CooldownService cooldownService = new CooldownService();
if (!cooldownService.check(player, "pride20Cat", TickTime.SECOND.x(10)))
return;
player.playSound(player.getLocation(), Sound.ENTITY_CAT_PURREOW, 5f, .08f);
return;
}
player.playSound(player.getLocation(), Sound.ENTITY_CAT_PURREOW, 5f, .08f);
PlayerUtils.giveItem(player, new ItemBuilder(Material.ORANGE_BANNER).pattern(DyeColor.RED, PatternType.STRIPE_TOP).pattern(DyeColor.YELLOW, PatternType.STRIPE_MIDDLE).pattern(DyeColor.LIME, PatternType.HALF_HORIZONTAL_MIRROR).pattern(DyeColor.YELLOW, PatternType.STRIPE_MIDDLE).pattern(DyeColor.BLUE, PatternType.STRIPE_BOTTOM).build());
setting.setBoolean(true);
service.save(setting);
PlayerUtils.send(player, "&eHow did you even get here? I mean.... meow");
}
use of gg.projecteden.nexus.utils.ItemBuilder in project Nexus by ProjectEdenGG.
the class ArcadeMachineMenu method init.
@Override
public void init(Player player, InventoryContents contents) {
contents.set(40, ClickableItem.from(closeItem(), e -> {
for (int i : openSlots) {
if (!contents.get(i).get().getItem().getType().equals(Material.LIGHT_GRAY_STAINED_GLASS_PANE))
PlayerUtils.giveItem(player, contents.get(i).get().getItem());
}
close(player, items);
}));
int[] blackSlots = { 1, 3, 5, 10, 12, 14, 16, 17, 27, 28, 30, 31, 32, 34, 35, 39, 41 };
for (int i : blackSlots) contents.set(i, ClickableItem.empty(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).name(" ").build()));
contents.set(36, ClickableItem.from(new ItemBuilder(Material.STONE_BUTTON).name("Power Button").build(), e -> {
process(contents);
boolean complete = true;
for (int i = 0; i < openSlots.length; i++) {
if (!contents.get(openSlots[i]).get().getItem().getType().equals(correct[i]))
complete = false;
else if (contents.get(openSlots[i]).get().getItem().getLore() != null && !contents.get(openSlots[i]).get().getItem().getLore().contains(BFQuests.itemLore))
complete = false;
}
if (!complete)
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 0.1f);
else {
complete(player);
}
}));
for (int i = 0; i < items.length; i++) {
ItemStack item = new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(" ").build();
if (items[i] != null) {
item = items[i];
for (int j : wireGroups[i]) contents.set(j, ClickableItem.empty(new ItemBuilder(Material.YELLOW_STAINED_GLASS_PANE).name(" ").build()));
}
contents.set(openSlots[i], ClickableItem.from(item, e -> {
if (e.getItem().getType().equals(Material.LIGHT_GRAY_STAINED_GLASS_PANE)) {
if (isNullOrAir(player.getItemOnCursor()))
return;
contents.set(e.getSlot(), ClickableItem.empty(player.getItemOnCursor()));
player.setItemOnCursor(null);
getItems(player, contents);
} else {
if (isNullOrAir(player.getItemOnCursor()))
contents.set(e.getSlot(), ClickableItem.empty(new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(" ").build()));
else {
contents.set(e.getSlot(), ClickableItem.empty(player.getItemOnCursor()));
player.setItemOnCursor(null);
}
getItems(player, contents);
player.setItemOnCursor(e.getItem());
}
}));
}
for (int i = 0; i < wireGroups.length; i++) for (int j : wireGroups[i]) if (contents.get(openSlots[i]).get().getItem().getType().equals(Material.LIGHT_GRAY_STAINED_GLASS_PANE))
contents.set(j, ClickableItem.empty(new ItemBuilder(Material.GLASS_PANE).name(" ").build()));
}
use of gg.projecteden.nexus.utils.ItemBuilder in project Nexus by ProjectEdenGG.
the class MiniGolfColorMenu method init.
@Override
public void init(Player player, InventoryContents contents) {
user = service.get(player);
addCloseItem(contents);
List<ClickableItem> clickableItems = new ArrayList<>();
for (MiniGolfColor miniGolfColor : MiniGolfColor.values()) {
ItemBuilder item = MiniGolf.getGolfBall().clone().customModelData(miniGolfColor.getCustomModelData());
if (miniGolfColor.equals(MiniGolfColor.RAINBOW)) {
item.name(StringUtils.Rainbow.apply(StringUtils.camelCase(miniGolfColor)));
if (!user.isRainbow()) {
Set<MiniGolfHole> userHoles = user.getHoleInOne();
StringBuilder missing = new StringBuilder();
for (MiniGolfHole hole : MiniGolfHole.getHoles()) {
if (!userHoles.contains(hole))
missing.append(hole.getHole()).append(" ");
}
item.lore("&cLocked", "", "&cMissing hole-in-ones on:", "&c" + missing.toString().trim());
}
} else
item.name(miniGolfColor.getColorType().getChatColor() + StringUtils.camelCase(miniGolfColor));
clickableItems.add(ClickableItem.from(item.build(), e -> setColor(user, miniGolfColor)));
}
paginator(player, contents, clickableItems);
}
Aggregations