Search in sources :

Example 1 with ItemBuilder

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);
        }
    });
}
Also used : SmartInventory(fr.minuskube.inv.SmartInventory) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) Material(org.bukkit.Material)

Example 2 with ItemBuilder

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();
        }));
    }
}
Also used : ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) ShopGroup(gg.projecteden.nexus.models.shop.Shop.ShopGroup) Gate(gg.projecteden.nexus.features.events.y2020.halloween20.quest.Gate) SmartInventory(fr.minuskube.inv.SmartInventory) Tasks(gg.projecteden.nexus.utils.Tasks) Sound(org.bukkit.Sound) Player(org.bukkit.entity.Player) Halloween20(gg.projecteden.nexus.features.events.y2020.halloween20.Halloween20) ItemStack(org.bukkit.inventory.ItemStack) Nullables.isNullOrEmpty(gg.projecteden.nexus.utils.Nullables.isNullOrEmpty) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) TickTime(gg.projecteden.utils.TimeUtils.TickTime) TransactionCause(gg.projecteden.nexus.models.banker.Transaction.TransactionCause) Halloween20User(gg.projecteden.nexus.models.halloween20.Halloween20User) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) QuestStage(gg.projecteden.nexus.features.events.y2020.halloween20.models.QuestStage) MenuUtils(gg.projecteden.nexus.features.menus.MenuUtils) SmartInvsPlugin(fr.minuskube.inv.SmartInvsPlugin) BankerService(gg.projecteden.nexus.models.banker.BankerService) Halloween20Service(gg.projecteden.nexus.models.halloween20.Halloween20Service) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) Halloween20User(gg.projecteden.nexus.models.halloween20.Halloween20User) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) Halloween20Service(gg.projecteden.nexus.models.halloween20.Halloween20Service) ItemStack(org.bukkit.inventory.ItemStack)

Example 3 with ItemBuilder

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");
}
Also used : Player(org.bukkit.entity.Player) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) SettingService(gg.projecteden.nexus.models.setting.SettingService) Setting(gg.projecteden.nexus.models.setting.Setting) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) EventHandler(org.bukkit.event.EventHandler)

Example 4 with ItemBuilder

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()));
}
Also used : ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) StringUtils(gg.projecteden.nexus.utils.StringUtils) SmartInventory(fr.minuskube.inv.SmartInventory) Tasks(gg.projecteden.nexus.utils.Tasks) Sound(org.bukkit.Sound) Player(org.bukkit.entity.Player) MinigameNightIsland(gg.projecteden.nexus.features.events.y2020.bearfair20.islands.MinigameNightIsland) BFQuests(gg.projecteden.nexus.features.events.y2020.bearfair20.quests.BFQuests) ItemStack(org.bukkit.inventory.ItemStack) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) TickTime(gg.projecteden.utils.TimeUtils.TickTime) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) MenuUtils(gg.projecteden.nexus.features.menus.MenuUtils) Nullables.isNullOrAir(gg.projecteden.nexus.utils.Nullables.isNullOrAir) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) Listener(org.bukkit.event.Listener) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) ItemStack(org.bukkit.inventory.ItemStack)

Example 5 with ItemBuilder

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);
}
Also used : MiniGolfColor(gg.projecteden.nexus.features.events.y2021.bearfair21.fairgrounds.minigolf.models.MiniGolfColor) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) MiniGolf(gg.projecteden.nexus.features.events.y2021.bearfair21.fairgrounds.minigolf.MiniGolf) MiniGolf21User(gg.projecteden.nexus.models.bearfair21.MiniGolf21User) MiniGolf21UserService(gg.projecteden.nexus.models.bearfair21.MiniGolf21UserService) StringUtils(gg.projecteden.nexus.utils.StringUtils) SmartInventory(fr.minuskube.inv.SmartInventory) Set(java.util.Set) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) MiniGolfUtils(gg.projecteden.nexus.features.events.y2021.bearfair21.fairgrounds.minigolf.MiniGolfUtils) MiniGolfColor(gg.projecteden.nexus.features.events.y2021.bearfair21.fairgrounds.minigolf.models.MiniGolfColor) List(java.util.List) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) MenuUtils(gg.projecteden.nexus.features.menus.MenuUtils) MiniGolfHole(gg.projecteden.nexus.features.events.y2021.bearfair21.fairgrounds.minigolf.models.MiniGolfHole) ClickableItem(fr.minuskube.inv.ClickableItem) ChatColor(net.md_5.bungee.api.ChatColor) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) MiniGolfHole(gg.projecteden.nexus.features.events.y2021.bearfair21.fairgrounds.minigolf.models.MiniGolfHole) ClickableItem(fr.minuskube.inv.ClickableItem) ArrayList(java.util.ArrayList)

Aggregations

ItemBuilder (gg.projecteden.nexus.utils.ItemBuilder)95 Player (org.bukkit.entity.Player)60 ClickableItem (fr.minuskube.inv.ClickableItem)58 ItemStack (org.bukkit.inventory.ItemStack)58 Material (org.bukkit.Material)53 InventoryContents (fr.minuskube.inv.content.InventoryContents)51 InventoryProvider (fr.minuskube.inv.content.InventoryProvider)38 ArrayList (java.util.ArrayList)38 MenuUtils (gg.projecteden.nexus.features.menus.MenuUtils)37 List (java.util.List)33 SmartInventory (fr.minuskube.inv.SmartInventory)30 PlayerUtils (gg.projecteden.nexus.utils.PlayerUtils)25 Getter (lombok.Getter)18 StringUtils (gg.projecteden.nexus.utils.StringUtils)16 StringUtils.camelCase (gg.projecteden.nexus.utils.StringUtils.camelCase)15 Shop (gg.projecteden.nexus.models.shop.Shop)14 ShopProvider (gg.projecteden.nexus.features.shops.providers.common.ShopProvider)12 Tasks (gg.projecteden.nexus.utils.Tasks)12 EventHandler (org.bukkit.event.EventHandler)11 Nexus (gg.projecteden.nexus.Nexus)10