Search in sources :

Example 91 with Interface

use of me.RockinChaos.itemjoin.utils.interfaces.Interface in project ItemJoin by RockinChaos.

the class Menu method creatingPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for Creating a NEW custom item.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void creatingPane(final Player player, final ItemMap itemMap) {
    Interface creatingPane = new Interface(false, 5, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        String slotList = "";
        String slotString = "";
        if (StringUtils.nullCheck(itemMap.getMultipleSlots().toString()) != "NONE") {
            for (String slot : itemMap.getMultipleSlots()) {
                slotString += slot + ", ";
            }
            for (String split : StringUtils.softSplit(StringUtils.nullCheck(slotString.substring(0, slotString.length())))) {
                slotList += "&a" + split + " /n ";
            }
        }
        String itemflagsList = "";
        if (StringUtils.nullCheck(itemMap.getItemFlags()) != "NONE") {
            for (String split : StringUtils.softSplit(itemMap.getItemFlags())) {
                itemflagsList += "&a" + split + " /n ";
            }
        }
        String triggersList = "";
        if (StringUtils.nullCheck(itemMap.getTriggers()) != "NONE") {
            for (String split : StringUtils.softSplit(itemMap.getTriggers())) {
                triggersList += "&a" + split + " /n ";
            }
        }
        String disabledList = "";
        if (StringUtils.nullCheck(itemMap.getDisabledWorlds().toString()) != "NONE") {
            for (String split : StringUtils.softSplit(StringUtils.nullCheck(itemMap.getDisabledWorlds().toString()))) {
                disabledList += "&a" + split + " /n ";
            }
        }
        String enabledList = "";
        if (StringUtils.nullCheck(itemMap.getEnabledWorlds().toString()) != "NONE") {
            for (String split : StringUtils.softSplit(StringUtils.nullCheck(itemMap.getEnabledWorlds().toString()))) {
                enabledList += "&a" + split + " /n ";
            }
        }
        String regionList = "";
        if (StringUtils.nullCheck(itemMap.getEnabledRegions().toString()) != "NONE") {
            for (String split : StringUtils.softSplit(StringUtils.nullCheck(itemMap.getEnabledRegions().toString()))) {
                regionList += "&a" + split + " /n ";
            }
        }
        String enchantList = "";
        if (StringUtils.nullCheck(itemMap.getEnchantments().toString()) != "NONE") {
            for (String split : StringUtils.softSplit(StringUtils.nullCheck(itemMap.getEnchantments().toString()))) {
                enchantList += "&a" + split + " /n ";
            }
        }
        String potionList = "";
        String potionString = "";
        if (StringUtils.nullCheck(itemMap.getPotionEffect().toString()) != "NONE") {
            for (PotionEffect potions : itemMap.getPotionEffect()) {
                potionString += potions.getType().getName().toUpperCase() + ":" + potions.getAmplifier() + ":" + potions.getDuration() + ", ";
            }
            for (String split : StringUtils.softSplit(StringUtils.nullCheck(potionString.substring(0, potionString.length())))) {
                potionList += "&a" + split + " /n ";
            }
        }
        String attributeList = "";
        String attributeString = "";
        if (StringUtils.nullCheck(itemMap.getAttributes().toString()) != "NONE") {
            for (String attribute : itemMap.getAttributes().keySet()) {
                attributeString += attribute + ":" + itemMap.getAttributes().get(attribute) + ", ";
            }
            for (String split : StringUtils.softSplit(StringUtils.nullCheck(attributeString.substring(0, attributeString.length())))) {
                attributeList += "&a" + split + " /n ";
            }
        }
        String patternList = "";
        String patternString = "";
        if (StringUtils.nullCheck(itemMap.getBannerPatterns().toString()) != "NONE") {
            for (Pattern patterns : itemMap.getBannerPatterns()) {
                patternString += patterns.getColor() + ":" + patterns.getPattern().name().toUpperCase() + ", ";
            }
            for (String split : StringUtils.softSplit(StringUtils.nullCheck(patternString.substring(0, patternString.length())))) {
                patternList += "&a" + split + " /n ";
            }
        }
        creatingPane.addButton(new Button(fillerPaneGItem), 4);
        creatingPane.addButton(new Button(headerStack(player, itemMap)));
        creatingPane.addButton(new Button(fillerPaneGItem), 4);
        creatingPane.addButton(new Button(ItemHandler.getItem(itemMap.getMaterial().toString() + ((itemMap.getDataValue() != null && itemMap.getDataValue() != 0) ? ":" + itemMap.getDataValue() : ""), 1, false, "&c&lMaterial", "&7", "&7*Set the material of the item.", "&9&lMATERIAL: &a" + itemMap.getMaterial().toString() + ((itemMap.getDataValue() != null && itemMap.getDataValue() != 0) ? ":" + itemMap.getDataValue() : "")), event -> {
            if (itemMap.getDynamicMaterials() != null && !itemMap.getDynamicMaterials().isEmpty()) {
                animateMaterialPane(player, itemMap);
            } else {
                materialPane(player, itemMap, 1, 0);
            }
        }));
        creatingPane.addButton(new Button(ItemHandler.getItem("GLASS", 1, false, "&c&lSlot", "&7", "&7*Set the slot that the", "&7item will be given in.", (itemMap.getMultipleSlots() != null && !itemMap.getMultipleSlots().isEmpty() ? "&9&lSlot(s): &a" + slotList : "&9&lSLOT: &a" + itemMap.getSlot().toUpperCase())), event -> switchPane(player, itemMap, 1)));
        creatingPane.addButton(new Button(ItemHandler.getItem("DIAMOND", itemMap.getCount(player), false, "&b&lCount", "&7", "&7*Set the amount of the", "&7item to be given.", "&9&lCOUNT: &a" + itemMap.getCount(player)), event -> countPane(player, itemMap)));
        creatingPane.addButton(new Button(ItemHandler.getItem("NAME_TAG", 1, false, "&b&lName", "&7", "&7*Set the name of the item.", "&9&lNAME: &f" + StringUtils.nullCheck(itemMap.getCustomName())), event -> {
            if (itemMap.getDynamicNames() != null && !itemMap.getDynamicNames().isEmpty()) {
                animatedNamePane(player, itemMap);
            } else {
                if (StringUtils.nullCheck(itemMap.getCustomName()) != "NONE") {
                    itemMap.setCustomName(null);
                    creatingPane(player, itemMap);
                } else {
                    player.closeInventory();
                    String[] placeHolders = LanguageAPI.getLang(false).newString();
                    placeHolders[16] = "NAME";
                    placeHolders[15] = "&bUltimate Sword";
                    LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                    LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
                }
            }
        }, event -> {
            itemMap.setCustomName(ChatColor.stripColor(event.getMessage()));
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "NAME";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            creatingPane(event.getPlayer(), itemMap);
        }));
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "WRITABLE_BOOK" : "386"), 1, false, "&b&lLore", "&7", "&7*Set the lore of the item.", "&9&lLORE: &f" + StringUtils.nullCheck(itemMap.getCustomLore().toString())), event -> {
            if (itemMap.getDynamicLores() != null && !itemMap.getDynamicLores().isEmpty()) {
                animatedLorePane(player, itemMap);
            } else {
                lorePane(player, itemMap);
            }
        }, event -> {
            itemMap.setCustomLore(StringUtils.split(ChatColor.stripColor(event.getMessage())));
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "LORE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            creatingPane(event.getPlayer(), itemMap);
        }));
        creatingPane.addButton(new Button(ItemHandler.setDurability(ItemHandler.getItem("DIAMOND_BOOTS", 1, false, "&e&lData", "&7", "&7*Set the damage or the", "&7custom texture of the item."), 160), event -> {
            dataPane(player, itemMap);
        }));
        creatingPane.addButton(new Button(ItemHandler.getItem("BOOK", 1, false, "&e&lCommand Settings", "&7", "&7*Define commands for the item", "&7which execute upon being", "&7interacted with."), event -> commandPane(player, itemMap)));
        creatingPane.addButton(new Button(ItemHandler.getItem("ENCHANTED_BOOK", 1, false, "&b&lEnchantments", "&7", "&7*Add enchants to make the", "&7item sparkle and powerful.", "&9&lENCHANTMENTS: &a" + (StringUtils.nullCheck(itemMap.getEnchantments().toString()) != "NONE" ? "&a" + enchantList : "NONE")), event -> enchantPane(player, itemMap)));
        creatingPane.addButton(new Button(ItemHandler.getItem("CHEST", 1, false, "&b&lItemflags", "&7", "&7*Special flags that will give", "&7the item abilities and", "&7custom features.", "&9&lITEMFLAGS: &a" + (StringUtils.nullCheck(itemMap.getItemFlags()) != "NONE" ? "&a" + itemflagsList : "NONE")), event -> flagPane(player, itemMap)));
        creatingPane.addButton(new Button(ItemHandler.getItem("REDSTONE", 1, false, "&b&lTriggers", "&7", "&7*When the players act upon these", "&7events, the item will be given.", "&9&lTRIGGERS: &a" + (StringUtils.nullCheck(itemMap.getTriggers()) != "NONE" ? "&a" + triggersList : "NONE")), event -> triggerPane(player, itemMap)));
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "REDSTONE_TORCH" : "76"), 1, false, "&b&lPermission Node", "&7", "&7*Custom permission node that", "&7will be required by a permission", "&7plugin to receive the item.", "&7&lNote: &7Do NOT include", "&7any spaces or special characters", "&9&lPERMISSION-NODE: &a" + StringUtils.nullCheck(itemMap.getPermissionNode())), event -> {
            if (StringUtils.nullCheck(itemMap.getPermissionNode()) != "NONE") {
                itemMap.setPerm(null);
                creatingPane(player, itemMap);
            } else {
                player.closeInventory();
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "CUSTOM PERMISSION";
                placeHolders[15] = "itemjoin.ultra";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
            }
        }, event -> {
            itemMap.setPerm(ChatColor.stripColor(event.getMessage()));
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "CUSTOM PERMISSION";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            creatingPane(event.getPlayer(), itemMap);
        }));
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "BEDROCK" : "7"), 1, false, "&b&lDisabled Worlds", "&7", "&7*Define the world(s) that the", "&7item will &l&nNOT&7 be given in.", "&9&lDISABLED-WORLDS: &a" + (StringUtils.nullCheck(itemMap.getDisabledWorlds().toString()) != "NONE" ? "&a" + disabledList : "NONE")), event -> worldPane(player, itemMap, 0)));
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "GRASS_BLOCK" : "2"), 1, false, "&b&lEnabled Worlds", "&7", "&7*Define the world(s) that the", "&7item will be given in.", "&9&lENABLED-WORLDS: &a" + (StringUtils.nullCheck(itemMap.getEnabledWorlds().toString()) != "NONE" ? "&a" + enabledList : "NONE")), event -> worldPane(player, itemMap, 1)));
        creatingPane.addButton(new Button(ItemHandler.getItem("GOLD_BLOCK", 1, true, "&b&lEnabled Regions", "&7", "&7*Define the region(s) that the", "&7item will be given in.", (DependAPI.getDepends(false).getGuard().guardEnabled() ? "&9&lENABLED-REGIONS: &a" + (StringUtils.nullCheck(itemMap.getEnabledRegions().toString()) != "NONE" ? "&a" + regionList : "NONE") : ""), (DependAPI.getDepends(false).getGuard().guardEnabled() ? "" : "&7"), (DependAPI.getDepends(false).getGuard().guardEnabled() ? "" : "&c&lERROR: &7WorldGuard was NOT found."), (DependAPI.getDepends(false).getGuard().guardEnabled() ? "" : "&7This button will do nothing...")), event -> {
            if (DependAPI.getDepends(false).getGuard().guardEnabled()) {
                regionPane(player, itemMap);
            }
        }));
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "STICKY_PISTON" : "29"), 1, false, "&e&lAnimation Settings", "&7", "&7*Define animations for the item", "&7Example: Custom iterations for the", "&7items name, lore, and material type"), event -> animationPane(player, itemMap)));
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "OAK_FENCE" : "FENCE"), 1, false, "&b&lLimit-Modes", "&7", "&7*Define the gamemode(s) that the", "&7item will be limited to.", "&9&lLIMIT-MODES: &a" + StringUtils.nullCheck(itemMap.getLimitModes())), event -> limitPane(player, itemMap)));
        creatingPane.addButton(new Button(ItemHandler.getItem("NETHER_STAR", 1, false, "&b&lProbability", "&7", "&7*Define the chance that the", "&7item will be given to the player.", "&7", "&c&lNOTICE:&7 Only ONE item defined with", "&7a probability value will be selected.", "&7Probability is the same as a dice roll.", "&7", "&9&lPROBABILITY: &a" + StringUtils.nullCheck(itemMap.getProbability() + "&a%")), event -> {
            if (StringUtils.nullCheck(itemMap.getProbability() + "&a%") != "NONE") {
                itemMap.setProbability(-1);
                creatingPane(player, itemMap);
            } else {
                probabilityPane(player, itemMap);
            }
        }));
        creatingPane.addButton(new Button(ItemHandler.getItem("ICE", 1, false, "&b&lUsage Cooldown", "&7", "&7*Define the cooldown for", "&7interacting with the item.", "&9&lUSE-COOLDOWN: &a" + StringUtils.nullCheck(itemMap.getInteractCooldown() + "&7")), event -> {
            if (StringUtils.nullCheck(itemMap.getInteractCooldown() + "&7") != "NONE") {
                itemMap.setInteractCooldown(0);
                creatingPane(player, itemMap);
            } else {
                usePane(player, itemMap);
            }
        }));
        creatingPane.addButton(new Button(fillerPaneGItem));
        creatingPane.addButton(new Button(ItemHandler.getItem("LAVA_BUCKET", 1, false, "&b&lConditions", "&7", "&7*Define conditions for triggers,", "&7commands, and the disposable itemflag.", "&9Enabled: &a" + ((itemMap.getTriggerConditions() != null && !itemMap.getTriggerConditions().isEmpty()) || (itemMap.getDisposableConditions() != null && !itemMap.getDisposableConditions().isEmpty()) || (itemMap.getCommandConditions() != null && !itemMap.getCommandConditions().isEmpty()) ? "YES" : "NONE")), event -> {
            conditionsPane(player, itemMap);
        }));
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "REPEATER" : "356"), 1, false, "&b&lToggle", "&7", "&7*Specify command(s) players can", "&7execute to enable or disable the", "&7custom item for themselves.", "&9Enabled: &a" + (itemMap.getToggleCommands() != null && !itemMap.getToggleCommands().isEmpty() ? "YES" : "NONE")), event -> {
            togglePane(player, itemMap);
        }));
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "CRAFTING_TABLE" : "58"), 1, false, "&b&lRecipe", "&7", "&7*Define the recipe to be", "&7able to craft this item.", "&9Enabled: &a" + (itemMap.getIngredients() != null && !itemMap.getIngredients().isEmpty() ? "YES" : "NONE")), event -> {
            recipePane(player, itemMap);
        }));
        creatingPane.addButton(new Button(fillerPaneGItem));
        creatingPane.addButton(new Button(ItemHandler.getItem("GOLD_INGOT", 1, false, "&e&lDrop Chances", "&7", "&7*Define the drop chance for receiving", "&7this item from mobs or breaking blocks."), event -> {
            dropsPane(player, itemMap);
        }));
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "COMMAND_BLOCK" : "137"), 1, false, "&c&lNBT Properties", "&7", "&7*Define specific NBT Properties", "&7to be set to the item.", "&9Enabled: &a" + (itemMap.getNBTValues() != null && !itemMap.getNBTValues().isEmpty() ? "YES" : "NONE")), event -> {
            nbtPane(player, itemMap);
        }));
        if (itemMap.getMaterial().toString().contains("MAP")) {
            creatingPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, false, "&e&lMap Image", "&7", "&7*Adds a custom map image that", "&7will be displayed when held.", "&7", "&7Place the custom map image", "&7in the MAIN ItemJoin folder.", "&7", "&7The map CAN be a GIF but", "&7must be a 128x128 pixel image.", "&9&lImage: &a" + StringUtils.nullCheck(itemMap.getMapImage())), event -> {
                if (StringUtils.nullCheck(itemMap.getMapImage()) != "NONE") {
                    itemMap.setMapImage(null);
                    creatingPane(player, itemMap);
                } else {
                    player.closeInventory();
                    String[] placeHolders = LanguageAPI.getLang(false).newString();
                    placeHolders[16] = "MAP IMAGE";
                    placeHolders[15] = "minecraft.png OR minecraft-dance.gif";
                    LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                    LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
                }
            }, event -> {
                itemMap.setMapImage(ChatColor.stripColor(event.getMessage()));
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "MAP IMAGE";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
                creatingPane(event.getPlayer(), itemMap);
            }));
        } else if (itemMap.getMaterial().toString().contains("ARROW") && !itemMap.getMaterial().toString().contains("TIPPED_ARROW")) {
            creatingPane.addButton(new Button(ItemHandler.getItem("ENDER_PEARL", 1, false, "&e&lTeleport", "&7", "&7*Set the arrow to teleport", "&7the player upon landing.", "&9&lEnabled: &a" + String.valueOf(itemMap.isTeleport()).toUpperCase()), event -> teleportPane(player, itemMap, 0)));
        } else if (itemMap.getMaterial().toString().contains("CHARGE") || itemMap.getMaterial().toString().equalsIgnoreCase("FIREWORK_STAR")) {
            Interface colorPane = new Interface(true, 6, GUIName, player);
            colorPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu"), event -> creatingPane(player, itemMap)));
            for (DyeColor color : DyeColor.values()) {
                colorPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "GRAY_DYE" : "351:8"), 1, false, "&f" + color.name(), "&7", "&7*This will be the color", "&7of your firework charge."), event -> {
                    itemMap.setChargeColor(color);
                    creatingPane(player, itemMap);
                }));
            }
            creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "PINK_DYE" : "351:9"), 1, false, "&e&lCharge Color", "&7", "&7*Set the color of", "&7the firework star.", "&9&lColor: &a" + StringUtils.nullCheck(itemMap.getChargeColor() + "")), event -> {
                if (StringUtils.nullCheck(itemMap.getChargeColor() + "") != "NONE") {
                    itemMap.setChargeColor(null);
                    creatingPane(player, itemMap);
                } else {
                    colorPane.open(player);
                }
            }));
        } else if (itemMap.getMaterial().isEdible() || itemMap.getMaterial().toString().equalsIgnoreCase("POTION")) {
            creatingPane.addButton(new Button(ItemHandler.getItem("POTION", 1, false, "&e&lEffects", "&7", "&7*Add custom effects after", "&7consuming the item.", "&9&lPotion-Effects: &a" + StringUtils.nullCheck(potionList)), event -> potionPane(player, itemMap, 0)));
        } else if (itemMap.getMaterial().toString().contains("BANNER")) {
            creatingPane.addButton(new Button(ItemHandler.getItem("CLAY_BALL", 1, false, "&e&lBanner Patterns", "&7", "&7*Set custom patterns that", "&7will appear on the item.", "&9&lBanner-Meta: &a" + StringUtils.nullCheck(patternList)), event -> bannerPane(player, itemMap)));
        } else if (!ItemHandler.getDesignatedSlot(itemMap.getMaterial()).equalsIgnoreCase("noslot") && !itemMap.getMaterial().toString().contains("LEATHER_")) {
            creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "ENCHANTED_GOLDEN_APPLE" : "322:1"), 1, false, "&a&lAttributes", "&7", "&7*Add a custom attribute to", "&7your armor or weapon.", (StringUtils.nullCheck(attributeList) != "NONE" ? "&9&lAttributes: &a" + attributeList : "")), event -> {
                attributePane(player, itemMap, false);
            }));
        } else if (itemMap.getMaterial().toString().contains("SHULKER")) {
            creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "PURPLE_SHULKER_BOX" : "229"), 1, false, "&a&lContents", "&7", "&7*Add existing custom items into", "&7the contents of this box.", "&9Enabled: &a" + (itemMap.getContents() != null && !itemMap.getContents().isEmpty() ? "YES" : "NONE")), event -> {
                Interface contentsPane = new Interface(true, 6, GUIName, player);
                SchedulerUtils.runAsync(() -> {
                    setPage(player, contentsPane, ItemUtilities.getUtilities().copyItems(), itemMap, null, 0);
                });
                contentsPane.open(player);
            }));
        } else {
            creatingPane.addButton(new Button(ItemHandler.getItem("MAGMA_CREAM", 1, false, "&e&lOther Settings", "&7", "&7*Settings that are specific", "&7to the item's material type.", (specialItem(itemMap) ? "" : "&7"), (specialItem(itemMap) ? "" : "&c&lERROR: &7A " + itemMap.getMaterial().name() + " &7is NOT"), (specialItem(itemMap) ? "" : "&7a special material type.")), event -> {
                if (specialItem(itemMap)) {
                    otherPane(player, itemMap);
                }
            }));
        }
        creatingPane.addButton(new Button(fillerPaneGItem));
        creatingPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nMain Menu", "&7", "&7*Cancel and return to the main menu.", "&7", "&c&lWARNING: &7This item has NOT been saved!"), event -> returnConfirm(player, itemMap)));
        creatingPane.addButton(new Button(fillerPaneBItem), 3);
        creatingPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "LIME_WOOL" : "WOOL:5"), 1, false, "&a&l&nSave to Config", "&7", "&7*Saves the custom item", "&7settings to the items.yml file."), event -> {
            itemMap.saveToConfig();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[3] = itemMap.getConfigName();
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.itemSaved", player, placeHolders);
            ConfigHandler.getConfig().reloadConfigs(true);
            player.closeInventory();
        }));
        creatingPane.addButton(new Button(fillerPaneBItem), 3);
        creatingPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nMain Menu", "&7", "&7*Cancel and return you to the main menu.", "&7", "&c&lWARNING: &7This item has NOT been saved!"), event -> returnConfirm(player, itemMap)));
    });
    creatingPane.open(player);
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) Pattern(org.bukkit.block.banner.Pattern) PotionEffect(org.bukkit.potion.PotionEffect) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) DyeColor(org.bukkit.DyeColor) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 92 with Interface

use of me.RockinChaos.itemjoin.utils.interfaces.Interface in project ItemJoin by RockinChaos.

the class Menu method overwritePane.

/**
 * Opens the Pane for the Player.
 *
 * @param player - The Player to have the Pane opened.
 */
private static void overwritePane(final Player player) {
    Interface overwritePane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        overwritePane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the configuration menu."), event -> itemSettings(player)));
        List<String> enabledWorlds = new ArrayList<String>();
        String[] enabledParts = ConfigHandler.getConfig().getFile("items.yml").getString("items-Overwrite").replace(" ,  ", ",").replace(" , ", ",").replace(",  ", ",").replace(", ", ",").split(",");
        for (String enabledWorld : enabledParts) {
            if (enabledWorld.equalsIgnoreCase("ALL") || enabledWorld.equalsIgnoreCase("GLOBAL")) {
                enabledWorlds.add("ALL");
            } else {
                for (World world : Bukkit.getServer().getWorlds()) {
                    if (enabledWorld.equalsIgnoreCase(world.getName())) {
                        enabledWorlds.add(world.getName());
                    }
                }
            }
        }
        if (enabledWorlds.isEmpty() && ConfigHandler.getConfig().getFile("items.yml").getBoolean("items-Overwrite")) {
            enabledWorlds.add("ALL");
        }
        overwritePane.addButton(new Button(ItemHandler.getItem("OBSIDIAN", 1, StringUtils.containsValue(enabledWorlds, "ALL"), "&a&l&nGLOBAL", "&7", "&7*Click to enable item", "&7overwriting in &lALL WORLDS.", "&9&lENABLED: &a" + (StringUtils.containsValue(enabledWorlds, "ALL") + "").toUpperCase()), event -> {
            File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "items.yml");
            FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
            if (StringUtils.containsValue(enabledWorlds, "ALL")) {
                dataFile.set("items-Overwrite", false);
            } else {
                dataFile.set("items-Overwrite", true);
            }
            ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "items.yml");
            ConfigHandler.getConfig().softReload();
            SchedulerUtils.runLater(2L, () -> overwritePane(player));
        }));
        for (World world : Bukkit.getServer().getWorlds()) {
            String worldMaterial = (ServerUtils.hasSpecificUpdate("1_13") ? "GRASS_BLOCK" : "2");
            if (world.getEnvironment().equals(Environment.NETHER)) {
                worldMaterial = "NETHERRACK";
            } else if (world.getEnvironment().equals(Environment.THE_END)) {
                worldMaterial = (ServerUtils.hasSpecificUpdate("1_13") ? "END_STONE" : "121");
            }
            overwritePane.addButton(new Button(ItemHandler.getItem(worldMaterial, 1, StringUtils.containsValue(enabledWorlds, world.getName()), "&f&l" + world.getName(), "&7", "&7*Click to enable item", "&7overwriting in this world.", "&9&lENABLED: &a" + (StringUtils.containsValue(enabledWorlds, world.getName()) + "").toUpperCase()), event -> {
                if (StringUtils.containsValue(enabledWorlds, world.getName())) {
                    enabledWorlds.remove(world.getName());
                } else {
                    enabledWorlds.add(world.getName());
                }
                if (!enabledWorlds.isEmpty() && enabledWorlds.size() > 1) {
                    if (StringUtils.containsValue(enabledWorlds, "ALL")) {
                        enabledWorlds.remove("ALL");
                    } else if (StringUtils.containsValue(enabledWorlds, "GLOBAL")) {
                        enabledWorlds.remove("GLOBAL");
                    }
                }
                String worldList = "";
                for (String worldName : enabledWorlds) {
                    worldList += worldName + ", ";
                }
                File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "items.yml");
                FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
                if (enabledWorlds.isEmpty()) {
                    dataFile.set("items-Overwrite", false);
                } else {
                    dataFile.set("items-Overwrite", worldList.substring(0, worldList.length() - 2));
                }
                ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "items.yml");
                ConfigHandler.getConfig().softReload();
                SchedulerUtils.runLater(2L, () -> overwritePane(player));
            }));
        }
    });
    overwritePane.open(player);
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ArrayList(java.util.ArrayList) World(org.bukkit.World) File(java.io.File) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 93 with Interface

use of me.RockinChaos.itemjoin.utils.interfaces.Interface in project ItemJoin by RockinChaos.

the class Menu method addConditionPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for adding the item condition.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 * @param condition - The condition currently being modified.
 */
private static void addConditionPane(final Player player, final ItemMap itemMap, final Action commandAction, final String condition1, final String value1) {
    Interface conditionsPane = new Interface(false, 2, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        conditionsPane.addButton(new Button(fillerPaneBItem));
        conditionsPane.addButton(new Button(ItemHandler.getItem("MINECART", 1, false, "&b&lEQUAL", "&7", "&7*The first value must be", "&7EQUAL to the second value", "&7for the condition to be met."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "SECOND VALUE";
            placeHolders[15] = "400";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "SECOND VALUE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            List<String> conditions = (condition1.equalsIgnoreCase("disposable-conditions") ? itemMap.getDisposableConditions() : condition1.equalsIgnoreCase("trigger-conditions") ? itemMap.getTriggerConditions() : itemMap.getCommandConditions().get(condition1) != null ? itemMap.getCommandConditions().get(condition1) : new ArrayList<String>());
            conditions.add(value1 + ":" + "EQUAL" + ":" + ChatColor.stripColor(event.getMessage()));
            if (condition1.equalsIgnoreCase("disposable-conditions")) {
                itemMap.setDisposableConditions(conditions);
                disposableCPane(player, itemMap);
            } else if (condition1.equalsIgnoreCase("trigger-conditions")) {
                itemMap.setTriggerConditions(conditions);
                triggerCPane(player, itemMap);
            } else {
                Map<String, List<String>> conditions2 = itemMap.getCommandConditions();
                conditions2.put(condition1.replace("-conditions", ""), conditions);
                itemMap.setCommandConditions(conditions2);
                commandCPane(player, itemMap, commandAction);
            }
        }));
        conditionsPane.addButton(new Button(fillerPaneBItem));
        conditionsPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "OAK_FENCE" : "85"), 1, false, "&b&lNOTEQUAL", "&7", "&7*The first value must be", "&7NOTEQUAL to the second value", "&7for the condition to be met."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "SECOND VALUE";
            placeHolders[15] = "400";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "SECOND VALUE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            List<String> conditions = (condition1.equalsIgnoreCase("disposable-conditions") ? itemMap.getDisposableConditions() : condition1.equalsIgnoreCase("trigger-conditions") ? itemMap.getTriggerConditions() : itemMap.getCommandConditions().get(condition1) != null ? itemMap.getCommandConditions().get(condition1) : new ArrayList<String>());
            conditions.add(value1 + ":" + "NOTEQUAL" + ":" + ChatColor.stripColor(event.getMessage()));
            if (condition1.equalsIgnoreCase("disposable-conditions")) {
                itemMap.setDisposableConditions(conditions);
                disposableCPane(player, itemMap);
            } else if (condition1.equalsIgnoreCase("trigger-conditions")) {
                itemMap.setTriggerConditions(conditions);
                triggerCPane(player, itemMap);
            } else {
                Map<String, List<String>> conditions2 = itemMap.getCommandConditions();
                conditions2.put(condition1.replace("-conditions", ""), conditions);
                itemMap.setCommandConditions(conditions2);
                commandCPane(player, itemMap, commandAction);
            }
        }));
        conditionsPane.addButton(new Button(fillerPaneBItem));
        conditionsPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "OAK_STAIRS" : "53"), 1, false, "&b&lOVER", "&7", "&7*The first value must be", "&7OVER the second value", "&7for the condition to be met.", "&7", "&c&l&nNOTE:&7 This only works if both", "&7values referenced are integers."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "SECOND VALUE";
            placeHolders[15] = "400";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "SECOND VALUE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            List<String> conditions = (condition1.equalsIgnoreCase("disposable-conditions") ? itemMap.getDisposableConditions() : condition1.equalsIgnoreCase("trigger-conditions") ? itemMap.getTriggerConditions() : itemMap.getCommandConditions().get(condition1) != null ? itemMap.getCommandConditions().get(condition1) : new ArrayList<String>());
            conditions.add(value1 + ":" + "OVER" + ":" + ChatColor.stripColor(event.getMessage()));
            if (condition1.equalsIgnoreCase("disposable-conditions")) {
                itemMap.setDisposableConditions(conditions);
                disposableCPane(player, itemMap);
            } else if (condition1.equalsIgnoreCase("trigger-conditions")) {
                itemMap.setTriggerConditions(conditions);
                triggerCPane(player, itemMap);
            } else {
                Map<String, List<String>> conditions2 = itemMap.getCommandConditions();
                conditions2.put(condition1.replace("-conditions", ""), conditions);
                itemMap.setCommandConditions(conditions2);
                commandCPane(player, itemMap, commandAction);
            }
        }));
        conditionsPane.addButton(new Button(fillerPaneBItem));
        conditionsPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "OAK_BOAT" : "333"), 1, false, "&b&lUNDER", "&7", "&7*The first value must be", "&7UNDER to the second value", "&7for the condition to be met.", "&7", "&c&l&nNOTE:&7 This only works if both", "&7values referenced are integers."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "SECOND VALUE";
            placeHolders[15] = "400";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "SECOND VALUE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            List<String> conditions = (condition1.equalsIgnoreCase("disposable-conditions") ? itemMap.getDisposableConditions() : condition1.equalsIgnoreCase("trigger-conditions") ? itemMap.getTriggerConditions() : itemMap.getCommandConditions().get(condition1) != null ? itemMap.getCommandConditions().get(condition1) : new ArrayList<String>());
            conditions.add(value1 + ":" + "UNDER" + ":" + ChatColor.stripColor(event.getMessage()));
            if (condition1.equalsIgnoreCase("disposable-conditions")) {
                itemMap.setDisposableConditions(conditions);
                disposableCPane(player, itemMap);
            } else if (condition1.equalsIgnoreCase("trigger-conditions")) {
                itemMap.setTriggerConditions(conditions);
                triggerCPane(player, itemMap);
            } else {
                Map<String, List<String>> conditions2 = itemMap.getCommandConditions();
                conditions2.put(condition1.replace("-conditions", ""), conditions);
                itemMap.setCommandConditions(conditions2);
                commandCPane(player, itemMap, commandAction);
            }
        }));
        conditionsPane.addButton(new Button(fillerPaneBItem));
        conditionsPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the " + condition1.replace("-", " ").replace(".", "") + " condition menu."), event -> {
            if (condition1.equalsIgnoreCase("disposable-conditions")) {
                disposableCPane(player, itemMap);
            } else if (condition1.equalsIgnoreCase("trigger-conditions")) {
                triggerCPane(player, itemMap);
            } else {
                commandCPane(player, itemMap, commandAction);
            }
        }));
        conditionsPane.addButton(new Button(fillerPaneBItem), 7);
        conditionsPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the " + condition1.replace("-", " ").replace(".", "") + " condition menu."), event -> {
            if (condition1.equalsIgnoreCase("disposable-conditions")) {
                disposableCPane(player, itemMap);
            } else if (condition1.equalsIgnoreCase("trigger-conditions")) {
                triggerCPane(player, itemMap);
            } else {
                commandCPane(player, itemMap, commandAction);
            }
        }));
    });
    conditionsPane.open(player);
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) List(java.util.List) ArrayList(java.util.ArrayList) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 94 with Interface

use of me.RockinChaos.itemjoin.utils.interfaces.Interface in project ItemJoin by RockinChaos.

the class Menu method setButton.

// ===================================================================================================================================================================================================================
// ============================================== //
// Menu Utilities        	       //
// ============================================== //
/**
 * Adds a button to the PagedPane.
 *
 * @param player - The Player.
 * @param itemMap - The ItemMap currently being modified.
 * @param pagedPane - The PagedPane.
 */
private static void setButton(final Player player, final ItemMap itemMap, final Interface modifyPane, final ItemMap contents, final ItemMap refMap, final int k) {
    final ItemStack item = itemMap.getTempItem().clone();
    if (item.getType() == Material.AIR) {
        item.setType(fillerPaneItem.getType());
    }
    if (itemMap.isAnimated() || itemMap.isDynamic()) {
        setModifyMenu(true, player);
        itemMap.getAnimationHandler().get(player).setMenu(true, 0);
    }
    String lore = (contents == null && refMap == null ? "&7*Click to modify this custom item." : refMap != null ? "&7*Click to set this custom item as an ingredient." : "&7*Click to add into the contents of " + contents.getConfigName() + ".");
    String space = (contents == null ? "&6---------------------------" : "&6----------------------------------");
    modifyPane.addButton(new Button(ItemHandler.addLore(item, "&7", space, lore, "&9&lNode: &a" + itemMap.getConfigName(), "&7", (contents != null ? "&9&lENABLED: " + (contents.getContents().contains(itemMap.getConfigName()) ? "&aYES" : "&aNO") : "")), event -> {
        if (refMap != null) {
            setIngredients(player, refMap, itemMap.getConfigName(), k);
        } else if (contents == null) {
            choicePane(player, itemMap, item);
        } else {
            List<String> contentList = contents.getContents();
            if (contents.getContents().contains(itemMap.getConfigName())) {
                contentList.remove(itemMap.getConfigName());
            } else {
                contentList.add(itemMap.getConfigName());
            }
            contents.setContents(contentList);
            Interface contentsPane = new Interface(true, 6, GUIName, player);
            SchedulerUtils.runAsync(() -> {
                setPage(player, contentsPane, ItemUtilities.getUtilities().copyItems(), contents, refMap, k);
            });
            contentsPane.open(player);
        }
    }));
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemStack(org.bukkit.inventory.ItemStack) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 95 with Interface

use of me.RockinChaos.itemjoin.utils.interfaces.Interface in project ItemJoin by RockinChaos.

the class Menu method lifePane.

/**
 * Opens the Pane for the Player.
 * This Pane is for setting the life time of the commands firework particle.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void lifePane(final Player player, final ItemMap itemMap, final String particle, final int stage) {
    Interface lifePane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        lifePane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the particle menu."), event -> {
            particlePane(player, itemMap, 3);
        }));
        lifePane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "YELLOW_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:4"), 1, false, "&e&lCustom LifeTime", "&7", "&7*Click to set a lifetime (duration)", "&7value for particle effect."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "PARTICLE LIFETIME";
            placeHolders[15] = "170";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            if (StringUtils.isInt(ChatColor.stripColor(event.getMessage()))) {
                if (stage == 0) {
                    itemMap.setCommandParticle(particle + ":" + ChatColor.stripColor(event.getMessage()));
                } else {
                    explosionPane(player, itemMap, particle, Integer.parseInt(ChatColor.stripColor(event.getMessage())));
                }
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "PARTICLE LIFETIME";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            } else {
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = ChatColor.stripColor(event.getMessage());
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.noInteger", player, placeHolders);
                particlePane(event.getPlayer(), itemMap, 3);
            }
        }));
        for (int i = 1; i <= 64; i++) {
            final int k = i;
            lifePane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "CYAN_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:9"), k, false, "&9&lLifeTime: &a&l" + k + " Tick(s)", "&7", "&7*Click to set the lifetime", "&7(duration) of the particle effect."), event -> {
                if (stage == 0) {
                    itemMap.setCommandParticle(particle + ":" + k);
                    commandPane(player, itemMap);
                } else {
                    explosionPane(player, itemMap, particle, k);
                }
            }));
        }
    });
    lifePane.open(player);
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Aggregations

Interface (me.RockinChaos.itemjoin.utils.interfaces.Interface)110 GameProfile (com.mojang.authlib.GameProfile)108 Property (com.mojang.authlib.properties.Property)108 File (java.io.File)108 Field (java.lang.reflect.Field)108 DecimalFormat (java.text.DecimalFormat)108 ArrayList (java.util.ArrayList)108 HashMap (java.util.HashMap)108 List (java.util.List)108 Map (java.util.Map)108 UUID (java.util.UUID)108 ItemJoin (me.RockinChaos.itemjoin.ItemJoin)108 ConfigHandler (me.RockinChaos.itemjoin.handlers.ConfigHandler)108 ItemHandler (me.RockinChaos.itemjoin.handlers.ItemHandler)108 PlayerHandler (me.RockinChaos.itemjoin.handlers.PlayerHandler)108 ItemCommand (me.RockinChaos.itemjoin.item.ItemCommand)108 Action (me.RockinChaos.itemjoin.item.ItemCommand.Action)108 CommandSequence (me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence)108 ItemMap (me.RockinChaos.itemjoin.item.ItemMap)108 ItemUtilities (me.RockinChaos.itemjoin.item.ItemUtilities)108