Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.1 kB
2
Indexable
Never
private List<UpgradeItem> setItemsAndFindTraps(Player player, Team team, GUI gui) {
        List<UpgradeItem> itemTraps = new ArrayList<>();
        for (UpgradeItem upgradeItem : BedWars.plugin.upgradeConfig.upgradeItems.values()) {

            if (!upgradeItem.tier.get(0).trapActions.isEmpty()) {
                for (Trap trap : team.trapActions) {
                    if (trap.trapActionList.equals(upgradeItem.tier.get(0).trapActions)) {
                        itemTraps.add(upgradeItem);
                    }
                }
            }

            if (!team.tiers.containsKey(upgradeItem)) {
                team.tiers.put(upgradeItem, 0);
            }
            if (team.tiers.get(upgradeItem) == upgradeItem.tier.size()) {
                ItemStack clonedItem = upgradeItem.maxTier == null ? upgradeItem.tier.get(team.tiers.get(upgradeItem) - 1).displayItem.clone() : upgradeItem.maxTier.displayItem;
                checkItem(player, clonedItem, upgradeItem, team.tiers.get(upgradeItem) - 1, team, true);
                if (!upgradeItem.tier.get(0).trapActions.isEmpty()) {
                    checkItem(player, clonedItem, upgradeItem, team.tiers.get(upgradeItem) - 1, team, team.trapActions.size() >= BedWars.plugin.upgradeConfig.trap_queue_limit);
                    List<String> lores = clonedItem.getItemMeta().getLore();
                    lores = StringUtils.replaceHolder(lores, "{-}", "", false);
                    lores = StringUtils.replaceHolder(lores, "{price}", Integer.toString((int) Math.pow(BedWars.plugin.upgradeConfig.trap_multiple_price, team.trapActions.size())), false);
                    ItemMeta meta = clonedItem.getItemMeta();
                    meta.setLore(lores);
                    clonedItem.setItemMeta(meta);
                } else {
                    checkItem(player, clonedItem, upgradeItem, team.tiers.get(upgradeItem) - 1, team, true);
                }
                gui.setItem(upgradeItem.slot, clonedItem);
                continue;
            }

            ItemStack clonedItem = upgradeItem.tier.get(team.tiers.get(upgradeItem)).displayItem.clone();

            if (!upgradeItem.tier.get(0).trapActions.isEmpty()) {

                List<String> lores = clonedItem.getItemMeta().getLore();

                lores = StringUtils.replaceHolder(lores, "{-}", "", false);
                lores = StringUtils.replaceHolder(lores, "{price}", Integer.toString((int) Math.pow(BedWars.plugin.upgradeConfig.trap_multiple_price, team.trapActions.size())), false);

                ItemMeta meta = clonedItem.getItemMeta();
                meta.setLore(lores);
                clonedItem.setItemMeta(meta);

                checkItem(player, clonedItem, upgradeItem, team.tiers.get(upgradeItem), team, team.trapActions.size() >= BedWars.plugin.upgradeConfig.trap_queue_limit);
            } else {
                checkItem(player, clonedItem, upgradeItem, team.tiers.get(upgradeItem), team, false);
            }
            gui.setItem(upgradeItem.slot, clonedItem);
        }
        return itemTraps;
    }