Search in sources :

Example 26 with Button

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

the class Menu method dropsPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for setting the drop chances.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void dropsPane(final Player player, final ItemMap itemMap) {
    Interface dropsPane = new Interface(false, 3, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        String mobs = "";
        String blocks = "";
        for (EntityType entity : itemMap.getMobsDrop().keySet()) {
            mobs += entity.name() + ", ";
        }
        for (Material material : itemMap.getBlocksDrop().keySet()) {
            blocks += material.name() + ", ";
        }
        dropsPane.addButton(new Button(fillerPaneBItem), 12);
        dropsPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "ZOMBIE_SPAWN_EGG" : "383:54"), 1, false, "&b&lMobs Drop", "&7", "&7*Define mobs that are", "&7allowed to drop the item.", (!mobs.isEmpty() ? "&9&lMobs: &a" + mobs.substring(0, mobs.length() - 2) : "")), event -> {
            mobsPane(player, itemMap);
        }));
        dropsPane.addButton(new Button(fillerPaneBItem));
        dropsPane.addButton(new Button(ItemHandler.getItem("DIAMOND_ORE", 1, false, "&b&lBlocks Drop", "&7", "&7*Define blocks that are", "&7allowed to drop the item.", (!blocks.isEmpty() ? "&9&lBlocks: &a" + blocks.substring(0, blocks.length() - 2) : "")), event -> {
            blocksPane(player, itemMap);
        }));
        dropsPane.addButton(new Button(fillerPaneBItem), 3);
        dropsPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> creatingPane(player, itemMap)));
        dropsPane.addButton(new Button(fillerPaneBItem), 7);
        dropsPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> creatingPane(player, itemMap)));
    });
    dropsPane.open(player);
}
Also used : EntityType(org.bukkit.entity.EntityType) 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) Material(org.bukkit.Material) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 27 with Button

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

the class Menu method disposableCPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for setting the disposable conditions.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void disposableCPane(final Player player, final ItemMap itemMap) {
    Interface conditionsPane = new Interface(true, 2, GUIName, player);
    conditionsPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item conditions menu."), event -> conditionsPane(player, itemMap)));
    SchedulerUtils.runAsync(() -> {
        conditionsPane.addButton(new Button(ItemHandler.getItem("NAME_TAG", 1, (StringUtils.nullCheck(itemMap.getDisposableMessage()) != "NONE"), "&c&lDisposable Fail Message", "&7", "&7*An optional message to be", "&7sent when the player does not", "&7meet the disposable conditions.", "&7", "&9&lMESSAGE: &a" + (StringUtils.nullCheck(itemMap.getDisposableMessage()) != "NONE" ? itemMap.getDisposableMessage() : "NONE")), event -> {
            if (StringUtils.nullCheck(itemMap.getDisposableMessage()) != "NONE") {
                itemMap.setDisposableMessage(null);
                disposableCPane(player, itemMap);
            } else {
                player.closeInventory();
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "DISPOSABLE FAIL MESSAGE";
                placeHolders[15] = "&cYou do not meet the conditions to dispose of this item.";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
            }
        }, event -> {
            itemMap.setDisposableMessage(ChatColor.stripColor(event.getMessage()));
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "DISPOSABLE FAIL MESSAGE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            disposableCPane(event.getPlayer(), itemMap);
        }));
        conditionsPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, true, "&b&lAdd Condition", "&7", "&7*Condition(s) that must be met", "&7in order to dispose of the item."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "FIRST VALUE";
            placeHolders[15] = "100";
            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] = "FIRST VALUE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            addConditionPane(event.getPlayer(), itemMap, null, "disposable-conditions", ChatColor.stripColor(event.getMessage()));
        }));
        for (String condition : itemMap.getDisposableConditions()) {
            conditionsPane.addButton(new Button(ItemHandler.getItem("PAPER", 1, false, "&f" + condition, "&7", "&7*Click to remove this condition."), event -> {
                List<String> conditions = itemMap.getDisposableConditions();
                conditions.remove(condition);
                itemMap.setDisposableConditions(conditions);
                disposableCPane(player, itemMap);
            }));
        }
    });
    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 28 with Button

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

the class Menu method flagPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for modifying an items itemflags.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void flagPane(final Player player, final ItemMap itemMap) {
    Interface flagPane = new Interface(true, 5, GUIName, player);
    flagPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> {
        setItemFlags(itemMap);
        creatingPane(player, itemMap);
    }));
    SchedulerUtils.runAsync(() -> {
        flagPane.addButton(new Button(ItemHandler.getItem("DIAMOND", 1, itemMap.isOpBypass(), "&a&l&nAllowOpBypass", "&7", "&a&lTrue&f:&7 Allows players who are OP to", "&7bypass any itemflags that add", "&7restrictions for this item.", "&7", "&c&lFalse&f:&7 Players who are OP will be", "&7restricted by itemflags that add", "&7restrictions for this item.", "&7", "&9&lENABLED: &a" + (itemMap.isOpBypass() + "").toUpperCase()), event -> {
            if (itemMap.isOpBypass()) {
                itemMap.setOpBypass(false);
            } else {
                itemMap.setOpBypass(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem(itemMap.isCreativeBypass() ? (ServerUtils.hasSpecificUpdate("1_13") ? "ENCHANTED_GOLDEN_APPLE" : "322:1") : "GOLDEN_APPLE", 1, itemMap.isCreativeBypass(), "&a&l&nCreativeBypass", "&7", "&a&lTrue&f:&7 Allows players who are in Creative", "&7to bypass any itemflags that add", "&7restrictions for this item.", "&7", "&c&lFalse&f:&7 Players who are in Creative will", "&7be restricted by itemflags that add", "&7restrictions for this item.", "&7", "&9&lENABLED: &a" + (itemMap.isCreativeBypass() + "").toUpperCase()), event -> {
            if (itemMap.isCreativeBypass()) {
                itemMap.setCreativeBypass(false);
            } else {
                itemMap.setCreativeBypass(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "LAPIS_LAZULI" : "351:4"), 1, itemMap.isGlowing(), "&a&l&nGlowing", "&7", "&a&lTrue&f:&7 The item will glow as if it was enchanted!", "&7", "&c&lFalse&f:&7 The item will not glow.", "&7", "&9&lENABLED: &a" + (itemMap.isGlowing() + "").toUpperCase()), event -> {
            if (itemMap.isGlowing()) {
                itemMap.setGlowing(false);
            } else {
                itemMap.setGlowing(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "DIAMOND_SHOVEL" : "277"), 7, itemMap.isStackable(), "&a&l&nStackable", "&7", "&a&lTrue&f:&7 The item will be stackable with itself!", "&7", "&c&lFalse&f:&7 The item stack only if it did in vanilla.", "&7", "&9&lENABLED: &a" + (itemMap.isStackable() + "").toUpperCase()), event -> {
            if (itemMap.isStackable()) {
                itemMap.setStackable(false);
            } else {
                itemMap.setStackable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "POPPY" : "38"), 1, itemMap.isInventoryClose(), "&a&l&nInventory Close", "&7", "&a&lTrue&f:&7 Closes the players current", "&7inventory when clicking the item.", "&7", "&c&lFalse&f:&7 The current inventory will not", "&7be closed when clicking the item.", "&7", "&9&lENABLED: &a" + (itemMap.isInventoryClose() + "").toUpperCase()), event -> {
            if (itemMap.isInventoryClose()) {
                itemMap.setCloseInventory(false);
            } else {
                itemMap.setCloseInventory(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("REDSTONE", 1, itemMap.isAutoRemove(), "&a&l&nAuto Remove", "&7", "&a&lTrue&f:&7 Automatically removes the", "&7item from the players inventory", "&7when entering or joining a", "&7world that is not defined", "&7under the enabled-worlds.", "&7", "&c&lFalse&f:&7 The player will keep the", "&7item when entering or joining", "&7an undefined world.", "&7", "&9&lENABLED: &a" + (itemMap.isAutoRemove() + "").toUpperCase()), event -> {
            if (itemMap.isAutoRemove()) {
                itemMap.setAutoRemove(false);
            } else {
                itemMap.setAutoRemove(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "WRITABLE_BOOK" : "386"), 1, itemMap.isOverwritable(), "&a&l&nOverwrite", "&7", "&a&lTrue&f: &7Allows the item to overwrite", "&7any existing items in the defined slot.", "&7", "&c&lFalse&f:&7 The item will not overwrite other items.", "&7When the slot is full it", "&7will fail to give the item, unless", "&7the give-next or move-next flag is set to &a&lTrue&7.", "&7", "&9&lENABLED: &a" + (itemMap.isOverwritable() + "").toUpperCase()), event -> {
            if (itemMap.isOverwritable()) {
                itemMap.setOverwritable(false);
            } else {
                itemMap.setOverwritable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("CACTUS", 1, itemMap.isDisposable(), "&a&l&nDisposable", "&7", "&a&lTrue&f:&7 If the item has a command", "&7defined, running the command", "&7will remove x1 of the item.", "&7", "&c&lFalse&f:&7 Running item commands will", "&7not lower the items count.", "&7", "&9&lENABLED: &a" + (itemMap.isDisposable() + "").toUpperCase()), event -> {
            if (itemMap.isDisposable()) {
                itemMap.setDisposable(false);
            } else {
                itemMap.setDisposable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "WOODEN_SWORD" : "268"), 1, itemMap.isVanilla(), "&a&l&nVanilla", "&7", "&a&lTrue&f:&7 The item will be given as a default no-name item.", "&cNOTE: &7Itemflags and commands will NOT work", "&7unless the vanilla-status or vanilla-control", "&7itemflags are defined.", "&7", "&c&lFalse&f:&7 The item will be given", "&7as an custom item, allowing all", "&7ItemJoin properties to continue working.", "&7", "&9&lENABLED: &a" + (itemMap.isVanilla() + "").toUpperCase()), event -> {
            if (itemMap.isVanilla()) {
                itemMap.setVanilla(false);
            } else {
                itemMap.setVanilla(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("LEATHER_HELMET", 1, itemMap.isVanillaStatus(), "&a&l&nVanilla Status", "&7", "&a&lTrue&f: &7Allows the Vanilla itemflag to retain", "&7ItemJoin properties without", "&7making it only a ItemJoin specific item.", "&cNOTE: &7Useful for trying to implement", "&7ItemJoin items into other plugins.", "&7", "&c&lFalse&f:&7 The item will be given", "&7as a custom item, allowing all", "&7ItemJoin properties to continue working.", "&7", "&9&lENABLED: &a" + (itemMap.isVanillaStatus() + "").toUpperCase()), event -> {
            if (itemMap.isVanillaStatus()) {
                itemMap.setVanillaStatus(false);
            } else {
                itemMap.setVanillaStatus(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "WOODEN_PICKAXE" : "270"), 1, itemMap.isVanillaControl(), "&a&l&nVanilla Control", "&7", "&a&lTrue&f: &7Allows the Vanilla itemflag to retain", "&7the use of commands and itemflags.", "&7", "&c&lFalse&f:&7 The item will be given", "&7as an custom item, allowing all", "&7ItemJoin properties to continue working.", "&7", "&9&lENABLED: &a" + (itemMap.isVanillaControl() + "").toUpperCase()), event -> {
            if (itemMap.isVanillaControl()) {
                itemMap.setVanillaControl(false);
            } else {
                itemMap.setVanillaControl(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("PAPER", 1, itemMap.isIpLimted(), "&a&l&nIP Limit", "&7", "&a&lTrue&f:&7 The item will be tied to the players IP.", "&7No other players using the same IP will receive the item.", "&7Useful to prevent item duplication.", "&7", "&c&lFalse&f:&7 The item will not be tied to a players IP.", "&7Other player accounts using the same IP will receive the item.", "&7", "&9&lENABLED: &a" + (itemMap.isIpLimted() + "").toUpperCase()), event -> {
            if (itemMap.isIpLimted()) {
                itemMap.setIpLimited(false);
            } else {
                itemMap.setIpLimited(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem(itemMap.isUnbreakable() ? "ENCHANTED_BOOK" : "BOOK", 1, itemMap.isUnbreakable(), "&a&l&nUnbreakable", "&7", "&a&lTrue&f:&7 Allows the item to be unbreakable or INDESTRUCTIBLE!", "&7", "&c&lFalse&f:&7 The item will be damageable when being used.", "&7", "&7This flag only takes effect on items which have durability.", "&7", "&9&lENABLED: &a" + (itemMap.isUnbreakable() + "").toUpperCase()), event -> {
            if (itemMap.isUnbreakable()) {
                itemMap.setUnbreakable(false);
            } else {
                itemMap.setUnbreakable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "FILLED_MAP" : "358"), 1, itemMap.isFlagsInfo(), "&a&l&nHide Flags", "&7", "&a&lTrue&f: &7Hides all information tags from the item", "&7such as firework colors, damage values, enchants, etc.", "&7", "&c&lFalse&f:&7 The item will have information tags visible.", "&7", "&9&lENABLED: &a" + (itemMap.isFlagsInfo() + "").toUpperCase()), event -> {
            if (itemMap.isFlagsInfo()) {
                itemMap.setFlagsInfo(false);
            } else {
                itemMap.setFlagsInfo(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "ENDER_EYE" : "381"), 1, itemMap.isAttributesInfo(), "&a&l&nHide Attributes", "&7", "&a&lTrue&f: &7Hides all attribute tags from the item", "&7such damage values, attack speed, hit points, etc.", "&7Typically this is the information that", "&7starts with (When in Main Hand:).", "&7", "&c&lFalse&f:&7 The item will have information tags visible.", "&7", "&9&lENABLED: &a" + (itemMap.isAttributesInfo() + "").toUpperCase()), event -> {
            if (itemMap.isAttributesInfo()) {
                itemMap.setAttributesInfo(false);
            } else {
                itemMap.setAttributesInfo(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("IRON_SWORD", 1, itemMap.isDurabilityBar(), "&a&l&nHide Durability", "&7", "&a&lTrue&f:&7 The durability bar of the damageable ", "&7item will be hidden.", "&cNOTE: &7Items with this flag will still break,", "&7unless the unbreakable flag is set to &a&lTrue&7.", "&7", "&c&lFalse&f:&7 The durability bar of the", "&7damageable item will be shown as normal.", "&7", "&9&lENABLED: &a" + (itemMap.isDurabilityBar() + "").toUpperCase()), event -> {
            if (itemMap.isDurabilityBar()) {
                itemMap.setDurabilityBar(false);
            } else {
                itemMap.setDurabilityBar(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("COBBLESTONE", 1, itemMap.isPlaceable(), "&a&l&nPlacement", "&7", "&a&lTrue&f: &7Prevents the item from being", "&7placed on the ground,", "&7in any item-frames, and entities.", "&7", "&c&lFalse&f: &7Item will be able to be placed.", "&7", "&9&lENABLED: &a" + (itemMap.isPlaceable() + "").toUpperCase()), event -> {
            if (itemMap.isPlaceable()) {
                itemMap.setPlaceable(false);
            } else {
                itemMap.setPlaceable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("BEDROCK", 1, itemMap.isMovement(), "&a&l&nInventory Modify", "&7", "&a&lTrue&f: &7Prevents the item from being", "&7moved or switched to other slots", "&7and blocks placement in item-frames.", "&7", "&c&lFalse&f:&7 Allows the item to be moved", "&7freely inside the players inventory.", "&7", "&9&lENABLED: &a" + (itemMap.isMovement() + "").toUpperCase()), event -> {
            if (itemMap.isMovement()) {
                itemMap.setMovement(false);
            } else {
                itemMap.setMovement(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("DIAMOND_HELMET", 1, itemMap.isEquip(), "&a&l&nCancel Equip", "&7", "&a&lTrue&f: &7Prevents the item from being", "&7moved or switched to armor slots.", "&7", "&c&lFalse&f:&7 Allows the item to be moved", "&7freely inside the players inventory.", "&7", "&9&lENABLED: &a" + (itemMap.isEquip() + "").toUpperCase()), event -> {
            if (itemMap.isEquip()) {
                itemMap.setEquip(false);
            } else {
                itemMap.setEquip(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("NAME_TAG", 1, itemMap.isDynamic(), "&a&l&nDynamic", "&7", "&a&lTrue&f: &7Allows the item to dynamically", "&7update every 100 ticks", "&7Useful for updating placeholders.", "&7", "&c&lFalse&f: &7Item will not update its name, lore, etc.", "&7", "&9&lENABLED: &a" + (itemMap.isDynamic() + "").toUpperCase()), event -> {
            if (itemMap.isDynamic()) {
                itemMap.setDynamic(false);
            } else {
                itemMap.setDynamic(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("EGG", 1, itemMap.isAnimated(), "&a&l&nAnimate", "&7", "&a&lTrue&f: &7Allows the item to animate between", "&7its different iterations defined", "&7under the animations tab.", "&7", "&c&lFalse&f: &7Item will not animate.", "&7", "&9&lENABLED: &a" + (itemMap.isAnimated() + "").toUpperCase()), event -> {
            if (itemMap.isAnimated()) {
                itemMap.setAnimate(false);
            } else {
                itemMap.setAnimate(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "CHEST_MINECART" : "342"), 1, itemMap.isItemStore(), "&a&l&nItem Store", "&7", "&a&lTrue&f:&7 Prevents the storage of the item in any containers.", "&7Such as chests, armor stands, anvils, etc.", "&7", "&c&lFalse&f:&7 The item can be stored in containers.", "&7", "&9&lENABLED: &a" + (itemMap.isItemStore() + "").toUpperCase()), event -> {
            if (itemMap.isItemStore()) {
                itemMap.setItemStore(false);
            } else {
                itemMap.setItemStore(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "OAK_DOOR" : (ServerUtils.hasSpecificUpdate("1_8") ? "324" : "64")), 1, itemMap.isCountLock(), "&a&l&nCount Lock", "&7", "&a&lTrue&f:&7 The item can be used indefinitely.", "&7Useful to give a player infinite apples.", "&cNOTE: &7This will overwrite the disposable flag.", "&7", "&c&lFalse&f:&7 The item will be removed from the inventory on use.", "&7", "&9&lENABLED: &a" + (itemMap.isCountLock() + "").toUpperCase()), event -> {
            if (itemMap.isCountLock()) {
                itemMap.setCountLock(false);
            } else {
                itemMap.setCountLock(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("CHEST", 1, itemMap.isDeathKeepable(), "&a&l&nDeath Keep", "&7", "&a&lTrue&f:&7 On death, the item will remain", "&7in players inventory on respawn.", "&7", "&c&lFalse&f:&7 On death, the item will be dropped", "&7at the death location as normal.", "&7", "&9&lENABLED: &a" + (itemMap.isDeathKeepable() + "").toUpperCase()), event -> {
            if (itemMap.isDeathKeepable()) {
                itemMap.setDeathKeepable(false);
            } else {
                itemMap.setDeathKeepable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("BONE", 1, itemMap.isDeathDroppable(), "&a&l&nDeath Drops", "&7", "&a&lTrue&f:&7 On death, the item will be removed", "&7from the players inventory.", "&7", "&c&lFalse&f:&7 On death, the item will be dropped", "&7at the death location as normal.", "&7", "&9&lENABLED: &a" + (itemMap.isDeathDroppable() + "").toUpperCase()), event -> {
            if (itemMap.isDeathDroppable()) {
                itemMap.setDeathDroppable(false);
            } else {
                itemMap.setDeathDroppable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("HOPPER", 1, itemMap.isSelfDroppable(), "&a&l&nSelf Drops", "&7", "&a&lTrue&f: &7Prevents the item from being dropped", "&7by the player, returns it back to their inventory.", "&7", "&c&lFalse&f: &7Allows the item to be dropped.", "&7", "&9&lENABLED: &a" + (itemMap.isSelfDroppable() + "").toUpperCase()), event -> {
            if (itemMap.isSelfDroppable()) {
                itemMap.setSelfDroppable(false);
            } else {
                itemMap.setSelfDroppable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("FURNACE", 1, itemMap.isItemModify(), "&a&l&nItem Modifiable", "&7", "&a&lTrue&f: &7Blocks the item from being", "&7repaired or enchanted in-game.", "&7", "&c&lFalse&f: &7Allows items to", "&7be repaired and enchanted.", "&7", "&9&lENABLED: &a" + (itemMap.isItemModify() + "").toUpperCase()), event -> {
            if (itemMap.isItemModify()) {
                itemMap.setItemModify(false);
            } else {
                itemMap.setItemModify(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("ANVIL", 1, itemMap.isItemRepairable(), "&a&l&nItem Repairable", "&7", "&a&lTrue&f: &7Blocks the item from being", "&7used in an anvil or repaired.", "&7", "&c&lFalse&f: &7Allows the item to be repaired.", "&7", "&9&lENABLED: &a" + (itemMap.isItemRepairable() + "").toUpperCase()), event -> {
            if (itemMap.isItemRepairable()) {
                itemMap.setItemRepairable(false);
            } else {
                itemMap.setItemRepairable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "CRAFTING_TABLE" : "58"), 1, itemMap.isItemCraftable(), "&a&l&nItem Craftable", "&7", "&a&lTrue&f: &7Blocks the item from being", "&7used in a crafting recipe.", "&7", "&c&lFalse&f: &7Item will be usable in", "&7a crafting recipe.", "&7", "&9&lENABLED: &a" + (itemMap.isItemCraftable() + "").toUpperCase()), event -> {
            if (itemMap.isItemCraftable()) {
                itemMap.setItemCraftable(false);
            } else {
                itemMap.setItemCraftable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("BOW", 1, itemMap.isCancelEvents(), "&a&l&nCancel Events", "&7", "&a&lTrue&f: &7Prevents almost any event from executing", "&7when right-clicking the item.", "&7", "&c&lFalse&f: &7Allows item events to be executed freely.", "&7", "&9&lENABLED: &a" + (itemMap.isCancelEvents() + "").toUpperCase()), event -> {
            if (itemMap.isCancelEvents()) {
                itemMap.setCancelEvents(false);
            } else {
                itemMap.setCancelEvents(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "WHEAT_SEEDS" : "295"), 1, itemMap.isAlwaysGive(), "&a&l&nAlways Give", "&7", "&a&lTrue&f: &7Gives the item every time the player", "&7performs one of the triggers actions.", "&7regardless of already having the item.", "&7", "&cNOTE: &7Don't use this if you want only ONE instance of the item.", "&7", "&c&lFalse&f: &7Normal item restrictions will apply.", "&7", "&9&lENABLED: &a" + (itemMap.isAlwaysGive() + "").toUpperCase()), event -> {
            if (itemMap.isAlwaysGive()) {
                itemMap.setAlwaysGive(false);
            } else {
                itemMap.setAlwaysGive(true);
            }
            flagPane(player, itemMap);
        }));
        if (itemMap.getMaterial().toString().contains("TIPPED_ARROW") || itemMap.getMaterial().toString().contains("ARROW")) {
            flagPane.addButton(new Button(ItemHandler.getItem("ENDER_PEARL", 1, itemMap.isTeleport(), "&a&l&nTeleport", "&7", "&a&lTrue&f: &7Teleports the Player to the location", "&7that the arrow landed.", "&cNOTE: &7This only works if the arrow is fired by a Bow.", "&9&lENABLED: &a" + (itemMap.isTeleport() + "").toUpperCase()), event -> {
                if (itemMap.isTeleport()) {
                    itemMap.setTeleport(false);
                } else {
                    itemMap.setTeleport(true);
                }
                flagPane(player, itemMap);
            }));
        } else {
            flagPane.addButton(new Button(fillerPaneBItem));
        }
        flagPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "ENCHANTING_TABLE" : "116"), 1, itemMap.isItemChangable(), "&a&l&nAllow Modifications", "&7", "&a&lTrue&f: &7Allows the players to modify the item", "&7while retaining all properties.", "&7", "&c&lFalse&f: &7Item will not be modifiable.", "&7", "&9&lENABLED: &a" + (itemMap.isItemChangable() + "").toUpperCase()), event -> {
            if (itemMap.isItemChangable()) {
                itemMap.setItemChangable(false);
            } else {
                itemMap.setItemChangable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("ITEM_FRAME", 1, itemMap.isGiveNext(), "&a&l&nGive Next", "&7", "&a&lTrue&f: &7Gives the item to the next available slot", "&7only if the defined slot already has an existing item.", "&cNOTE: &7The overwrite flag will not work.", "&7", "&c&lFalse&f:&7 The item will be only given in the defined slot.", "&7If an item is already in the slot the", "&7item wont be given, unless the overwrite", "&7flag is set to &l&aTrue&7.", "&7", "&9&lENABLED: &a" + (itemMap.isGiveNext() + "").toUpperCase()), event -> {
            if (itemMap.isGiveNext()) {
                itemMap.setGiveNext(false);
            } else {
                itemMap.setGiveNext(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("MINECART", 1, itemMap.isMoveNext(), "&a&l&nMove Next", "&7", "&a&lTrue&f: &7Moves the existing item to the next available slot", "&7only if the defined slot already has an existing item.", "&cNOTE: &7The overwrite flag will not work.", "&7", "&c&lFalse&f: &7The item will be only given in the defined slot.", "&7If an item is already in the slot the", "&7item wont be given, unless the overwrite", "&7flag is set to &l&aTrue&7.", "&7", "&9&lENABLED: &a" + (itemMap.isMoveNext() + "").toUpperCase()), event -> {
            if (itemMap.isMoveNext()) {
                itemMap.setMoveNext(false);
            } else {
                itemMap.setMoveNext(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("DIAMOND_SWORD", 1, itemMap.isDropFull(), "&a&l&nDrop Full", "&7", "&a&lTrue&f: &7Drops the item on the ground if", "&7the players inventory is full.", "&7", "&c&lFalse&f: &7Fails to give the item", "&7if the players inventory is full.", "&7", "&9&lENABLED: &a" + (itemMap.isDropFull() + "").toUpperCase()), event -> {
            if (itemMap.isDropFull()) {
                itemMap.setDropFull(false);
            } else {
                itemMap.setDropFull(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(ItemHandler.getItem("SUGAR", 1, itemMap.isSelectable(), "&a&l&nSelectable", "&7", "&a&lTrue&f: &7Prevents the item from being", "&7held in the players hand.", "&7", "&c&lFalse&f: &7Allows the item to be selected.", "&7", "&9&lENABLED: &a" + (itemMap.isSelectable() + "").toUpperCase()), event -> {
            if (itemMap.isSelectable()) {
                itemMap.setSelectable(false);
            } else {
                itemMap.setSelectable(true);
            }
            flagPane(player, itemMap);
        }));
        flagPane.addButton(new Button(fillerPaneBItem), 35);
    });
    flagPane.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)

Example 29 with Button

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

the class Menu method sequencePane.

/**
 * Opens the Pane for the Player.
 * This Pane is for setting an items command sequence.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void sequencePane(final Player player, final ItemMap itemMap, final int stage) {
    Interface sequencePane = new Interface(false, 2, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        if (stage == 4) {
            sequencePane.addButton(new Button(fillerPaneGItem));
        }
        sequencePane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "CLOCK" : "347"), 1, false, "&a&lSequential", "&7", "&7*Executes the command lines", "&7in order from top to bottom."), event -> {
            if (stage == 4) {
                File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
                FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
                dataFile.set("Active-Commands.commands-sequence", "SEQUENTIAL");
                ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
                ConfigHandler.getConfig().softReload();
                SchedulerUtils.runLater(2L, () -> activeCommands(player));
            } else {
                itemMap.setCommandSequence(CommandSequence.SEQUENTIAL);
                commandPane(player, itemMap);
            }
        }));
        sequencePane.addButton(new Button(fillerPaneGItem));
        sequencePane.addButton(new Button(ItemHandler.getItem("DIAMOND", 1, false, "&a&lRandom Single", "&7", "&7*Executes one of the command lines", "&7randomly with equal values."), event -> {
            if (stage == 4) {
                File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
                FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
                dataFile.set("Active-Commands.commands-sequence", "RANDOM_SINGLE");
                ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
                ConfigHandler.getConfig().softReload();
                SchedulerUtils.runLater(2L, () -> activeCommands(player));
            } else {
                itemMap.setCommandSequence(CommandSequence.RANDOM_SINGLE);
                commandPane(player, itemMap);
            }
        }));
        sequencePane.addButton(new Button(fillerPaneGItem));
        sequencePane.addButton(new Button(ItemHandler.getItem("PAPER", 1, false, "&a&lRandom List", "&7", "&7*Randomly selects from a list", "&7of commands to execute."), event -> {
            if (stage == 4) {
                File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
                FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
                dataFile.set("Active-Commands.commands-sequence", "RANDOM_LIST");
                ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
                ConfigHandler.getConfig().softReload();
                SchedulerUtils.runLater(2L, () -> activeCommands(player));
            } else {
                itemMap.setCommandSequence(CommandSequence.RANDOM_LIST);
                commandPane(player, itemMap);
            }
        }));
        sequencePane.addButton(new Button(fillerPaneGItem));
        sequencePane.addButton(new Button(ItemHandler.getItem("EMERALD", 1, false, "&a&lRandom", "&7", "&7*Executes each command line in a", "&7random order with equal values."), event -> {
            if (stage == 4) {
                File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
                FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
                dataFile.set("Active-Commands.commands-sequence", "RANDOM");
                ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
                ConfigHandler.getConfig().softReload();
                SchedulerUtils.runLater(2L, () -> activeCommands(player));
            } else {
                itemMap.setCommandSequence(CommandSequence.RANDOM);
                commandPane(player, itemMap);
            }
        }));
        sequencePane.addButton(new Button(fillerPaneGItem));
        if (stage != 4) {
            sequencePane.addButton(new Button(ItemHandler.getItem("CHEST", 1, false, "&a&lRemain", "&7", "&7*Executes each command only if", "&7the item exists in the player", "&7inventory at the time of executing", "&7a delayed command line.", "&7The commands will be sent in", "&7order from top to bottom."), event -> {
                itemMap.setCommandSequence(CommandSequence.REMAIN);
                commandPane(player, itemMap);
            }));
        }
        if (stage == 4) {
            sequencePane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the active commands menu."), event -> activeCommands(player)));
        } else {
            sequencePane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item commands menu."), event -> commandPane(player, itemMap)));
        }
        sequencePane.addButton(new Button(fillerPaneBItem), 7);
        if (stage == 4) {
            sequencePane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the active commands menu."), event -> activeCommands(player)));
        } else {
            sequencePane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item commands menu."), event -> commandPane(player, itemMap)));
        }
    });
    sequencePane.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) File(java.io.File) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 30 with Button

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

the class Menu method commandPane.

// ============================================== //
// ItemCommand Menus        	       //
// ============================================== //
/**
 * Opens the Pane for the Player.
 * This Pane is for modifying an items commands.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void commandPane(final Player player, final ItemMap itemMap) {
    Interface commandPane = new Interface(false, 3, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        commandPane.addButton(new Button(fillerPaneGItem), 4);
        commandPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "WRITABLE_BOOK" : "386"), 1, false, "&e&lCommands", "&7", "&7*Click to define the custom command lines", "&7for the item and click type.", "&7", "&9&lCommands: &a" + (itemMap.getCommands().length != 0 ? "YES" : "NONE")), event -> actionPane(player, itemMap)));
        commandPane.addButton(new Button(fillerPaneGItem), 4);
        commandPane.addButton(new Button(ItemHandler.getItem("REDSTONE", 1, false, "&a&lParticle", "&7", "&7*Custom particle(s) that will be", "&7displayed when the commands", "&7are successfully executed.", "&9&lCOMMANDS-PARTICLE: &a" + StringUtils.nullCheck(itemMap.getCommandParticle() + "")), event -> {
            if (StringUtils.nullCheck(itemMap.getCommandParticle() + "") != "NONE") {
                itemMap.setCommandParticle(null);
                commandPane(player, itemMap);
            } else {
                particlePane(player, itemMap, 3);
            }
        }));
        commandPane.addButton(new Button(ItemHandler.getItem("EMERALD", 1, false, "&a&lItem Cost", "&7", "&7*Material that will", "&7be charged upon successfully", "&7executing the commands.", "&9&lCOMMANDS-ITEM: &a" + (StringUtils.nullCheck(itemMap.getItemCost()))), event -> {
            if (StringUtils.nullCheck(itemMap.getItemCost()) != "NONE") {
                itemMap.setItemCost(null);
                commandPane(player, itemMap);
            } else {
                materialPane(player, itemMap, 2, 0);
            }
        }));
        commandPane.addButton(new Button(ItemHandler.getItem("DIAMOND", 1, false, "&a&lCost", "&7", "&7*Amount that the player will", "&7be charged upon successfully", "&7executing the commands.", "&9&lCOMMANDS-COST: &a" + (StringUtils.nullCheck(itemMap.getCommandCost() + "&7"))), event -> {
            if (StringUtils.nullCheck(itemMap.getCommandCost() + "&7") != "NONE") {
                itemMap.setCommandCost(0);
                commandPane(player, itemMap);
            } else {
                costPane(player, itemMap);
            }
        }));
        commandPane.addButton(new Button(ItemHandler.getItem("STONE_BUTTON", 1, false, "&a&lReceive", "&7", "&7*The number of times the", "&7commands will execute when", "&7receiving the custom item.", "&cNOTE: &7Only functions with", "&7the on-receive command action.", "&9&lCOMMANDS-RECEIVE: &a" + (StringUtils.nullCheck(itemMap.getCommandReceive() + "&7"))), event -> {
            if (StringUtils.nullCheck(itemMap.getCommandReceive() + "&7") != "NONE") {
                itemMap.setCommandReceive(0);
                commandPane(player, itemMap);
            } else {
                receivePane(player, itemMap);
            }
        }));
        commandPane.addButton(new Button(ItemHandler.getItem("ICE", 1, false, "&a&lCooldown", "&7", "&7*The time that the commands will", "&7be on cooldown for.", "&7", "&9&lCOMMANDS-COOLDOWN: &a" + StringUtils.nullCheck(itemMap.getCommandCooldown() + "&7") + (StringUtils.nullCheck(itemMap.getCommandCooldown() + "&7") != "NONE" ? "&a second(s)" : "")), event -> {
            if (StringUtils.nullCheck(itemMap.getCommandCooldown() + "&7") != "NONE") {
                itemMap.setCommandCooldown(0);
                commandPane(player, itemMap);
            } else {
                cooldownPane(player, itemMap);
            }
        }));
        commandPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "OAK_SIGN" : "323"), 1, false, "&a&lCooldown Message", "&7", "&7*Optional cooldown message", "&7to be displayed when", "&7the items commands are", "&7on cooldown.", "&9&lCOOLDOWN-MESSAGE: &a" + StringUtils.nullCheck(itemMap.getCooldownMessage())), event -> {
            if (StringUtils.nullCheck(itemMap.getCooldownMessage()) != "NONE") {
                itemMap.setCooldownMessage(null);
                commandPane(player, itemMap);
            } else {
                player.closeInventory();
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "COOLDOWN MESSAGE";
                placeHolders[15] = "&cThis item is on cooldown for &a%timeleft% &cseconds..";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
            }
        }, event -> {
            itemMap.setCooldownMessage(ChatColor.stripColor(event.getMessage()));
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "COOLDOWN MESSAGE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            commandPane(event.getPlayer(), itemMap);
        }));
        commandPane.addButton(new Button(ItemHandler.getItem("JUKEBOX", 1, false, "&a&lSound", "&7", "&7*The sound that will be", "&7played after a successful", "&7command execution.", "&9&lCOMMANDS-SOUND: &a" + StringUtils.nullCheck(itemMap.getCommandSound() + ""), "&9&lVOLUME: &a" + ((StringUtils.nullCheck(itemMap.getCommandSound() + "") != "NONE") ? itemMap.getCommandVolume() : "0"), "&9&lPITCH: &a" + ((StringUtils.nullCheck(itemMap.getCommandSound() + "") != "NONE") ? itemMap.getCommandPitch() : "0")), event -> {
            if (StringUtils.nullCheck(itemMap.getCommandSound() + "") != "NONE") {
                itemMap.setCommandSound(null);
                commandPane(player, itemMap);
            } else {
                soundPane(player, itemMap, 3);
            }
        }));
        commandPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "REPEATER" : "356"), 1, false, "&a&lSequence", "&7", "&7*The order that the command lines", "&7will be executed in.", "&9&lCOMMANDS-SEQUENCE: &a" + StringUtils.nullCheck(itemMap.getCommandSequence() + "")), event -> {
            if (StringUtils.nullCheck(itemMap.getCommandSequence() + "") != "NONE") {
                itemMap.setCommandSequence(null);
                commandPane(player, itemMap);
            } else {
                sequencePane(player, itemMap, 0);
            }
        }));
        commandPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "LAVA_BUCKET" : "327"), 1, false, "&a&lWarmup", "&7", "&7*The time it will take before", "&7the commands are executed.", "&7Player movement will cancel the", "&7pending commands execution.", "&7", "&9&lCOMMANDS-WARMUP: &a" + StringUtils.nullCheck(itemMap.getWarmDelay() + "&7") + (StringUtils.nullCheck(itemMap.getWarmDelay() + "&7") != "NONE" ? "&a second(s)" : "")), event -> {
            if (StringUtils.nullCheck(itemMap.getWarmDelay() + "&7") != "NONE") {
                itemMap.setWarmDelay(0);
                commandPane(player, itemMap);
            } else {
                warmPane(player, itemMap);
            }
        }));
        commandPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> creatingPane(player, itemMap)));
        commandPane.addButton(new Button(fillerPaneBItem), 7);
        commandPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> creatingPane(player, itemMap)));
    });
    commandPane.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

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 SchedulerUtils (me.RockinChaos.itemjoin.utils.SchedulerUtils)108