Search in sources :

Example 11 with Action

use of me.RockinChaos.itemjoin.item.ItemCommand.Action 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 12 with Action

use of me.RockinChaos.itemjoin.item.ItemCommand.Action in project ItemJoin by RockinChaos.

the class Menu method swapPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for setting the commands swap-item.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 * @param action - The action to be matched.
 */
private static void swapPane(final Player player, final ItemMap itemMap, final Action action) {
    Interface swapPane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        swapPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the executors menu."), event -> {
            executorPane(player, itemMap, action);
        }));
        for (ItemMap item : ItemUtilities.getUtilities().copyItems()) {
            if (item.getNodeLocation() != itemMap.getNodeLocation()) {
                if (itemMap.isAnimated() || itemMap.isDynamic()) {
                    setModifyMenu(true, player);
                    itemMap.getAnimationHandler().get(player).setMenu(true, 1);
                }
                swapPane.addButton(new Button(ItemHandler.addLore(item.getTempItem(), "&7", "&6---------------------------", "&7*Click to set as a swap-item.", "&9&lNode: &a" + item.getConfigName(), "&7"), event -> {
                    modifyCommands(itemMap, ItemCommand.fromString("swap-item: " + item.getConfigName(), action, itemMap, 0L, null), true);
                    commandListPane(player, itemMap, action);
                }));
            }
        }
    });
    swapPane.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) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Aggregations

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