Search in sources :

Example 91 with ItemMap

use of me.RockinChaos.itemjoin.item.ItemMap 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)

Example 92 with ItemMap

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

the class Menu method designPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for selecting a Firework Type.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void designPane(final Player player, final ItemMap itemMap) {
    Interface designPane = new Interface(true, 2, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        designPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the special settings menu."), event -> otherPane(player, itemMap)));
        for (Type type : Type.values()) {
            designPane.addButton(new Button(ItemHandler.getItem("EGG", 1, false, "&f" + type.name(), "&7", "&7*This will be the type (pattern)", "&7of your firework."), event -> {
                itemMap.setFireworkType(type);
                otherPane(player, itemMap);
            }));
        }
    });
    designPane.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) PatternType(org.bukkit.block.banner.PatternType) EntityType(org.bukkit.entity.EntityType) PotionEffectType(org.bukkit.potion.PotionEffectType) Type(org.bukkit.FireworkEffect.Type) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 93 with ItemMap

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

the class Menu method durationMaterialPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for modifying animated material duration.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void durationMaterialPane(final Player player, final ItemMap itemMap, final int position, final boolean isNew, final String value) {
    Interface durationPane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        durationPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the animated menu."), event -> animateMaterialPane(player, itemMap)));
        durationPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "YELLOW_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:4"), 1, false, "&e&lCustom Duration", "&7", "&7*Click to set a custom duration", "&7value for the animation."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "ANIMATION DURATION";
            placeHolders[15] = "110";
            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()))) {
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "ANIMATION DURATION";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
                List<String> mats = itemMap.getDynamicMaterials();
                if (isNew) {
                    if (itemMap.getDynamicMaterials().isEmpty()) {
                        mats.add("<delay:" + Integer.parseInt(ChatColor.stripColor(event.getMessage())) + ">" + itemMap.getMaterial());
                    }
                    mats.add("<delay:" + Integer.parseInt(ChatColor.stripColor(event.getMessage())) + ">" + value);
                } else {
                    mats.set(position, "<delay:" + Integer.parseInt(ChatColor.stripColor(event.getMessage())) + ">" + ItemHandler.cutDelay(mats.get(position)));
                }
                itemMap.setDynamicMaterials(mats);
                if (isNew) {
                    animateMaterialPane(player, itemMap);
                } else {
                    modifyMaterialPane(player, itemMap, position);
                }
            } else {
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = ChatColor.stripColor(event.getMessage());
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.noInteger", player, placeHolders);
                durationMaterialPane(player, itemMap, position, isNew, value);
            }
        }));
        for (int i = 1; i <= 64; i++) {
            final int k = i;
            durationPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "BLUE_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:11"), k, false, "&9&lDuration: &a&l" + k + " Ticks(s)", "&7", "&7*Click to set the", "&7duration of the animation."), event -> {
                List<String> mats = itemMap.getDynamicMaterials();
                if (isNew) {
                    if (itemMap.getDynamicMaterials().isEmpty()) {
                        mats.add("<delay:" + k + ">" + itemMap.getMaterial());
                    }
                    mats.add("<delay:" + k + ">" + value);
                } else {
                    mats.set(position, "<delay:" + k + ">" + ItemHandler.cutDelay(mats.get(position)));
                }
                itemMap.setDynamicMaterials(mats);
                if (isNew) {
                    animateMaterialPane(player, itemMap);
                } else {
                    modifyMaterialPane(player, itemMap, position);
                }
            }));
        }
    });
    durationPane.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 ItemMap

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

the class Menu method otherPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for modifying special items.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void otherPane(final Player player, final ItemMap itemMap) {
    Interface otherPane = new Interface(false, 3, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        otherPane.addButton(new Button(fillerPaneGItem), 4);
        otherPane.addButton(new Button(headerStack(player, itemMap)));
        otherPane.addButton(new Button(fillerPaneGItem), 4);
        if (itemMap.getMaterial().toString().contains("WRITTEN_BOOK")) {
            otherPane.addButton(new Button(fillerPaneGItem), 3);
            otherPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "WRITABLE_BOOK" : "386"), 1, false, "&e&lPages", "&7", "&7*Define custom pages for the book.", "&9&lPages: &a" + (StringUtils.nullCheck(itemMap.getPages() + "") != "NONE" ? "YES" : "NONE")), event -> pagePane(player, itemMap)));
            otherPane.addButton(new Button(fillerPaneGItem));
            otherPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, false, "&a&lAuthor", "&7", "&7*Define the author of the book.", "&9&lAuthor: &a" + StringUtils.nullCheck(itemMap.getAuthor())), event -> {
                if (StringUtils.nullCheck(itemMap.getAuthor()) != "NONE") {
                    itemMap.setAuthor(null);
                    otherPane(player, itemMap);
                } else {
                    player.closeInventory();
                    String[] placeHolders = LanguageAPI.getLang(false).newString();
                    placeHolders[16] = "AUTHOR";
                    placeHolders[15] = "RockinChaos";
                    LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                    LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
                }
            }, event -> {
                itemMap.setAuthor(ChatColor.stripColor(event.getMessage()));
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "AUTHOR";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
                otherPane(event.getPlayer(), itemMap);
            }));
            otherPane.addButton(new Button(fillerPaneGItem), 3);
        } else if (itemMap.getMaterial().toString().contains("PLAYER_HEAD") || itemMap.getMaterial().toString().contains("SKULL_ITEM")) {
            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 ";
                }
            }
            otherPane.addButton(new Button(fillerPaneGItem), 2);
            otherPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "GOLDEN_HELMET" : "314"), 1, false, "&b&lSkull Owner", "&7", "&7*Define a skull owner for the", "&7head adding that persons skin.", "&7", "&7You can only define skull owner", "&7or skull texture, this will", "&7remove any skull textures.", "&9&lSkull-Owner: &a" + StringUtils.nullCheck(itemMap.getSkull())), event -> {
                if (itemMap.getDynamicOwners() != null && !itemMap.getDynamicOwners().isEmpty()) {
                    animatedSkullPane(player, itemMap, true);
                } else {
                    if (StringUtils.nullCheck(itemMap.getSkull()) != "NONE") {
                        itemMap.setSkull(null);
                        otherPane(player, itemMap);
                    } else {
                        player.closeInventory();
                        String[] placeHolders = LanguageAPI.getLang(false).newString();
                        placeHolders[16] = "SKULL OWNER";
                        placeHolders[15] = "RockinChaos";
                        LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                        LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
                    }
                }
            }, event -> {
                itemMap.setSkull(ChatColor.stripColor(event.getMessage()));
                itemMap.setSkullTexture(null);
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "SKULL OWNER";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
                otherPane(event.getPlayer(), itemMap);
            }));
            otherPane.addButton(new Button(fillerPaneGItem));
            otherPane.addButton(new Button(ItemHandler.getItem("STRING", 1, false, "&a&lSkull Texture", "&7", "&7*Add a skull texture for the", "&7head as a custom skin.", "&7", "&7You can only define skull texture", "&7or skull owner, this will", "&7remove any skull owners.", "&7", "&7Skull textures can be found", "&7at websites like &aminecraft-heads.com", "&7and the value is listed under", "&7the OTHER section.", "&9&lSkull-Texture: &a" + (StringUtils.nullCheck(itemMap.getSkullTexture()) != "NONE" ? (itemMap.getSkullTexture().length() > 40 ? itemMap.getSkullTexture().substring(0, 40) : itemMap.getSkullTexture()) : "")), event -> {
                if (itemMap.getDynamicTextures() != null && !itemMap.getDynamicTextures().isEmpty()) {
                    animatedSkullPane(player, itemMap, false);
                } else {
                    if (StringUtils.nullCheck(itemMap.getSkullTexture()) != "NONE") {
                        itemMap.setSkullTexture(null);
                        otherPane(player, itemMap);
                    } else {
                        player.closeInventory();
                        String[] placeHolders = LanguageAPI.getLang(false).newString();
                        placeHolders[16] = "SKULL TEXTURE";
                        placeHolders[15] = "eyJ0ZXh0dYMGQVlN2FjZmU3OSJ9fX0=";
                        LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                        LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
                    }
                }
            }, event -> {
                itemMap.setSkullTexture(ChatColor.stripColor(event.getMessage()));
                itemMap.setSkull(null);
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "SKULL TEXTURE";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
                otherPane(event.getPlayer(), itemMap);
            }));
            otherPane.addButton(new Button(fillerPaneGItem));
            otherPane.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, 1)));
            otherPane.addButton(new Button(fillerPaneGItem), 2);
        } else if (itemMap.getMaterial().toString().contains("TIPPED_ARROW")) {
            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 ";
                }
            }
            otherPane.addButton(new Button(fillerPaneGItem), 3);
            otherPane.addButton(new Button(ItemHandler.getItem("BLAZE_POWDER", 1, false, "&e&lEffects", "&7", "&7*Add custom effects", "&7to the arrow tip.", "&9&lTipped-Effect: &a" + StringUtils.nullCheck(potionList)), event -> potionPane(player, itemMap, 1)));
            otherPane.addButton(new Button(fillerPaneGItem));
            otherPane.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, 1)));
            otherPane.addButton(new Button(fillerPaneGItem), 3);
        } else if (itemMap.getMaterial().toString().equalsIgnoreCase("FIREWORK") || itemMap.getMaterial().toString().equalsIgnoreCase("FIREWORK_ROCKET")) {
            String colorList = "";
            if (StringUtils.nullCheck(itemMap.getFireworkColor().toString()) != "NONE") {
                for (String split : StringUtils.softSplit(StringUtils.nullCheck(itemMap.getFireworkColor().toString()))) {
                    colorList += "&a" + split + " /n ";
                }
            }
            otherPane.addButton(new Button(fillerPaneGItem), 2);
            otherPane.addButton(new Button(ItemHandler.getItem("EGG", 1, false, "&a&lType", "&7", "&7*Set the style of the explosion.", "&9&lType: &a" + StringUtils.nullCheck(itemMap.getFireworkType() + "")), event -> {
                if (StringUtils.nullCheck(itemMap.getFireworkType() + "") != "NONE") {
                    itemMap.setFireworkType(null);
                    otherPane(player, itemMap);
                } else {
                    designPane(player, itemMap);
                }
            }));
            otherPane.addButton(new Button(ItemHandler.getItem("DIAMOND", 1, itemMap.getFireworkFlicker(), "&a&lFlicker", "&7", "&7*Show the flicker effect as", "&7the firework particles dissipate", "&7after the explosion.", "&9&lENABLED: &a" + itemMap.getFireworkFlicker()), event -> {
                if (itemMap.getFireworkFlicker()) {
                    itemMap.setFireworkFlicker(false);
                } else {
                    itemMap.setFireworkFlicker(true);
                }
                otherPane(player, itemMap);
            }));
            otherPane.addButton(new Button(ItemHandler.getItem("EMERALD", 1, itemMap.getFireworkTrail(), "&a&lTrail", "&7", "&7*Show the trail (smoke) of", "&7the firework when launched.", "&9&lENABLED: &a" + itemMap.getFireworkTrail()), event -> {
                if (itemMap.getFireworkTrail()) {
                    itemMap.setFireworkTrail(false);
                } else {
                    itemMap.setFireworkTrail(true);
                }
                otherPane(player, itemMap);
            }));
            otherPane.addButton(new Button(ItemHandler.getItem("SUGAR", 1, false, "&a&lPower", "&7", "&7*Set the power (distance)", "&7that the firework travels.", "&9&lPower: &a" + StringUtils.nullCheck(itemMap.getFireworkPower() + "&7")), event -> {
                if (StringUtils.nullCheck(itemMap.getFireworkPower() + "&7") != "NONE") {
                    itemMap.setFireworkPower(0);
                    otherPane(player, itemMap);
                } else {
                    powerPane(player, itemMap);
                }
            }));
            otherPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "LIME_DYE" : "351:10"), 1, false, "&a&lColor(s)", "&7", "&7*Define the individual colors of the", "&7firework effect type.", "&9&lColor(s): &a" + (StringUtils.nullCheck(colorList) != "NONE" ? colorList : "NONE")), event -> colorPane(player, itemMap)));
            otherPane.addButton(new Button(fillerPaneGItem), 2);
        } else if (itemMap.getMaterial().toString().contains("LEATHER_")) {
            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 special settings menu."), event -> otherPane(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 leather armor."), event -> {
                    itemMap.setLeatherColor(color.name());
                    itemMap.setLeatherHex(null);
                    otherPane(player, itemMap);
                }));
            }
            otherPane.addButton(new Button(fillerPaneGItem), 3);
            otherPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "YELLOW_DYE" : "351:11"), 1, false, "&a&lDye", "&7", "&7*Add a custom color to", "&7your leather armor.", "&9&lLeather-Color: &a" + (StringUtils.nullCheck(itemMap.getLeatherColor()) != "NONE" ? StringUtils.nullCheck(itemMap.getLeatherColor()) : StringUtils.nullCheck(itemMap.getLeatherHex()))), event -> {
                if (itemMap.getLeatherColor() != null) {
                    itemMap.setLeatherColor(null);
                    otherPane(player, itemMap);
                } else {
                    colorPane.open(player);
                }
            }));
            if (!ItemHandler.getDesignatedSlot(itemMap.getMaterial()).equalsIgnoreCase("noslot")) {
                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 ";
                    }
                }
                otherPane.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, true);
                }));
            } else {
                otherPane.addButton(new Button(fillerPaneGItem));
            }
            otherPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "WRITABLE_BOOK" : "386"), 1, false, "&a&lHex Color", "&7", "&7*Add a custom hex color", "&7to your leather armor.", "&9&lLeather-Color: &a" + (StringUtils.nullCheck(itemMap.getLeatherHex()) != "NONE" ? StringUtils.nullCheck(itemMap.getLeatherHex()) : StringUtils.nullCheck(itemMap.getLeatherColor()))), event -> {
                if (itemMap.getLeatherHex() != null) {
                    itemMap.setLeatherHex(null);
                    otherPane(player, itemMap);
                } else {
                    player.closeInventory();
                    String[] placeHolders = LanguageAPI.getLang(false).newString();
                    placeHolders[16] = "HEX COLOR";
                    placeHolders[15] = "#033dfc";
                    LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                    LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
                }
            }, event -> {
                if (itemMap.getLeatherHex() == null) {
                    itemMap.setLeatherHex(ChatColor.stripColor(event.getMessage()));
                    itemMap.setLeatherColor(null);
                    String[] placeHolders = LanguageAPI.getLang(false).newString();
                    placeHolders[16] = "HEX COLOR";
                    LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
                    otherPane(event.getPlayer(), itemMap);
                }
            }));
            otherPane.addButton(new Button(fillerPaneGItem), 3);
        }
        otherPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> creatingPane(player, itemMap)));
        otherPane.addButton(new Button(fillerPaneBItem), 7);
        otherPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> creatingPane(player, itemMap)));
    });
    otherPane.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) PotionEffect(org.bukkit.potion.PotionEffect) DyeColor(org.bukkit.DyeColor) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 95 with ItemMap

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

the class Placement method onCountLock.

/**
 * Refills the custom item to its original stack size when placing the item.
 *
 * @param event - PlayerInteractEvent
 */
@EventHandler(ignoreCancelled = false)
private void onCountLock(PlayerInteractEvent event) {
    final ItemStack item = (event.getItem() != null ? event.getItem().clone() : event.getItem());
    final Player player = event.getPlayer();
    final int slot = player.getInventory().getHeldItemSlot();
    if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK && !PlayerHandler.isCreativeMode(player)) {
        if (!ItemUtilities.getUtilities().isAllowed(player, item, "count-lock")) {
            ItemMap itemMap = ItemUtilities.getUtilities().getItemMap(item, null, player.getWorld());
            item.setAmount(itemMap.getCount(player));
            SchedulerUtils.run(() -> {
                if (StringUtils.containsIgnoreCase(item.getType().name(), "WATER") || StringUtils.containsIgnoreCase(item.getType().name(), "LAVA") || item.getType().name().equalsIgnoreCase("BUCKET") || StringUtils.containsIgnoreCase(item.getType().name(), "POTION")) {
                    if (player.getInventory().getHeldItemSlot() == slot) {
                        PlayerHandler.setMainHandItem(player, item);
                    } else if (PlayerHandler.isCraftingInv(player.getOpenInventory())) {
                        player.getInventory().setItem(slot, item);
                    }
                } else if (itemMap != null) {
                    if (PlayerHandler.getHandItem(player) == null || PlayerHandler.getHandItem(player).getAmount() <= 1) {
                        if (ServerUtils.hasSpecificUpdate("1_9")) {
                            if (event.getHand().equals(EquipmentSlot.HAND)) {
                                if (player.getInventory().getHeldItemSlot() == slot) {
                                    PlayerHandler.setMainHandItem(player, item);
                                } else if (PlayerHandler.isCraftingInv(player.getOpenInventory())) {
                                    player.getInventory().setItem(slot, item);
                                }
                            } else if (event.getHand().equals(EquipmentSlot.OFF_HAND)) {
                                PlayerHandler.setOffHandItem(player, item);
                            }
                        } else {
                            if (player.getInventory().getHeldItemSlot() == slot) {
                                PlayerHandler.setMainHandItem(player, item);
                            } else if (PlayerHandler.isCraftingInv(player.getOpenInventory())) {
                                player.getInventory().setItem(slot, item);
                            }
                        }
                    } else if (itemMap.isSimilar(PlayerHandler.getHandItem(player))) {
                        PlayerHandler.getHandItem(player).setAmount(itemMap.getCount(player));
                    }
                }
            });
        }
    }
}
Also used : Player(org.bukkit.entity.Player) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ItemMap (me.RockinChaos.itemjoin.item.ItemMap)140 Player (org.bukkit.entity.Player)124 ItemStack (org.bukkit.inventory.ItemStack)116 ArrayList (java.util.ArrayList)102 World (org.bukkit.World)96 PotionEffect (org.bukkit.potion.PotionEffect)95 HashMap (java.util.HashMap)94 List (java.util.List)94 ItemCommand (me.RockinChaos.itemjoin.item.ItemCommand)92 ChatColor (org.bukkit.ChatColor)92 Color (org.bukkit.Color)92 DyeColor (org.bukkit.DyeColor)92 Material (org.bukkit.Material)92 GameProfile (com.mojang.authlib.GameProfile)91 Property (com.mojang.authlib.properties.Property)91 File (java.io.File)91 Field (java.lang.reflect.Field)91 DecimalFormat (java.text.DecimalFormat)91 Map (java.util.Map)91 UUID (java.util.UUID)91