Search in sources :

Example 6 with ItemCommand

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

the class APIUtils method getCommands.

/**
 * Fetches commands that are defined for the custom item.
 *
 * @param itemNode - that is the custom items config node.
 * @return List of commands for the custom item.
 */
public List<String> getCommands(String itemNode) {
    ItemMap itemMap = this.getMap(null, null, itemNode);
    List<String> commands = new ArrayList<String>();
    if (itemMap != null && itemMap.getCommands() != null && itemMap.getCommands().length > 0) {
        for (ItemCommand command : itemMap.getCommands()) {
            commands.add(command.getRawCommand());
        }
        return commands;
    }
    return null;
}
Also used : ItemMap(me.RockinChaos.itemjoin.item.ItemMap) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ArrayList(java.util.ArrayList)

Example 7 with ItemCommand

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

the class Menu method orderPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for modifying an items list of commands.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 * @param action - The action to be matched.
 * @param command - The ItemCommand instance being modified.
 * @param orderNumber - The current number that dictates the ItemCommands "place in line".
 */
private static void orderPane(final Player player, final ItemMap itemMap, final Action action, final ItemCommand command, final int orderNumber) {
    Interface orderPane = new Interface(true, 2, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        orderPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the command modify menu."), event -> {
            modifyCommandsPane(player, itemMap, action, command, orderNumber);
        }));
        for (int i = 1; i <= getCommandSize(itemMap, action); i++) {
            final int k = i;
            orderPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "LIGHT_BLUE_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:3"), k, false, "&9&lOrder Number: &a&l" + k, "&7", "&7*Click to set the order", "&7number of the command."), event -> {
                List<ItemCommand> arrayCommands = new ArrayList<ItemCommand>();
                int l = 0;
                for (ItemCommand Command : itemMap.getCommands()) {
                    if (Command.matchAction(action)) {
                        if ((l + 1) == k) {
                            arrayCommands.add(command);
                        }
                        l++;
                    }
                    if (!Command.equals(command)) {
                        arrayCommands.add(Command);
                    }
                }
                final ItemCommand[] commands = new ItemCommand[arrayCommands.size()];
                for (int j = 0; j < arrayCommands.size(); ++j) {
                    commands[j] = arrayCommands.get(j);
                }
                itemMap.setCommands(commands);
                commandListPane(player, itemMap, action);
            }));
        }
    });
    orderPane.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) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) List(java.util.List) ArrayList(java.util.ArrayList) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 8 with ItemCommand

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

the class Menu method commandListPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for modifying an items list of commands.
 *
 * @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 commandListPane(final Player player, final ItemMap itemMap, final Action action) {
    Interface commandListPane = new Interface(true, 2, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        commandListPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the click type menu."), event -> {
            actionPane(player, itemMap);
        }));
        commandListPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, true, "&e&lNew Line", "&7", "&7*Add a new command to be executed", "&7by &9&l" + action.name()), event -> {
            executorPane(player, itemMap, action);
        }));
        ItemCommand[] commandList = itemMap.getCommands();
        int l = 1;
        for (ItemCommand command : commandList) {
            if (command.matchAction(action)) {
                final int k = l;
                commandListPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, false, "&f" + command.getRawCommand(), "&7", "&7*Click to &lmodify &7this command.", "&9&lOrder Number: &a" + k), event -> {
                    modifyCommandsPane(player, itemMap, action, command, k);
                }));
                l++;
            }
        }
    });
    commandListPane.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) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Aggregations

ItemCommand (me.RockinChaos.itemjoin.item.ItemCommand)8 ArrayList (java.util.ArrayList)6 GameProfile (com.mojang.authlib.GameProfile)5 Property (com.mojang.authlib.properties.Property)5 Field (java.lang.reflect.Field)5 ItemMap (me.RockinChaos.itemjoin.item.ItemMap)5 HeadDatabaseAPI (me.arcaniax.hdb.api.HeadDatabaseAPI)5 Material (org.bukkit.Material)5 Pattern (org.bukkit.block.banner.Pattern)5 File (java.io.File)4 DecimalFormat (java.text.DecimalFormat)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 UUID (java.util.UUID)4 ItemJoin (me.RockinChaos.itemjoin.ItemJoin)4 ConfigHandler (me.RockinChaos.itemjoin.handlers.ConfigHandler)4 ItemHandler (me.RockinChaos.itemjoin.handlers.ItemHandler)4 PlayerHandler (me.RockinChaos.itemjoin.handlers.PlayerHandler)4 Action (me.RockinChaos.itemjoin.item.ItemCommand.Action)4