Search in sources :

Example 16 with ItemMap

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

the class Menu method convertStack.

/**
 * Converts the ItemStack that is attempting to be saved to a ItemMap.
 *
 * @param player - The Player saving the ItemStack.
 * @param item - The ItemStack to be saved.
 */
private static void convertStack(final Player player, final ItemStack item, final String slot) {
    ItemMap itemMap = new ItemMap("item_" + StringUtils.getPath(1), "ARBITRARY");
    itemMap.setMaterial(item.getType());
    if (!ServerUtils.hasSpecificUpdate("1_13")) {
        itemMap.setDataValue((short) LegacyAPI.getDataValue(item));
    }
    itemMap.setCount(String.valueOf(item.getAmount()));
    if (item.getType().getMaxDurability() > 30 && ItemHandler.getDurability(item) != 0 && ItemHandler.getDurability(item) != (item.getType().getMaxDurability())) {
        itemMap.setDurability(ItemHandler.getDurability(item));
    }
    if (item.hasItemMeta()) {
        if (item.getItemMeta().hasDisplayName()) {
            itemMap.setCustomName(item.getItemMeta().getDisplayName().replace("�", "&"));
        }
        if (item.getItemMeta().hasLore()) {
            List<String> newLore = new ArrayList<String>();
            for (String lore : item.getItemMeta().getLore()) {
                newLore.add(lore.replace("�", "&"));
            }
            itemMap.setCustomLore(newLore);
        }
        if (item.getItemMeta().hasEnchants()) {
            Map<String, Integer> enchantList = new HashMap<String, Integer>();
            for (Enchantment e : item.getItemMeta().getEnchants().keySet()) {
                enchantList.put(ItemHandler.getEnchantName(e).toUpperCase(), item.getItemMeta().getEnchants().get(e));
            }
            itemMap.setEnchantments(enchantList);
        }
    }
    if (StringUtils.containsIgnoreCase(item.getType().toString(), "LEATHER_")) {
        LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
        if (meta.getColor() != null) {
            itemMap.setLeatherColor(DyeColor.getByColor(meta.getColor()).name());
        }
    } else if (item.getType().toString().equalsIgnoreCase("SKULL_ITEM") || item.getType().toString().equalsIgnoreCase("PLAYER_HEAD")) {
        if (!PlayerHandler.getSkullOwner(item).equalsIgnoreCase("NULL")) {
            itemMap.setSkull(PlayerHandler.getSkullOwner(item));
        } else if (!ItemHandler.getSkullTexture(item.getItemMeta()).isEmpty()) {
            itemMap.setSkullTexture(ItemHandler.getSkullTexture(item.getItemMeta()));
        }
    } else if (itemMap.getMaterial().toString().contains("CHARGE") || itemMap.getMaterial().toString().equalsIgnoreCase("FIREWORK_STAR")) {
        itemMap.setChargeColor(DyeColor.getByFireworkColor(((FireworkEffectMeta) item.getItemMeta()).getEffect().getColors().get(0)));
    } else if (itemMap.getMaterial().toString().contains("BANNER")) {
        itemMap.setBannerPatterns(((BannerMeta) item.getItemMeta()).getPatterns());
    } else if (itemMap.getMaterial().toString().equalsIgnoreCase("FIREWORK") || itemMap.getMaterial().toString().equalsIgnoreCase("FIREWORK_ROCKET")) {
        List<DyeColor> colors = new ArrayList<DyeColor>();
        for (Color color : ((FireworkMeta) item.getItemMeta()).getEffects().get(0).getColors()) {
            colors.add(DyeColor.getByFireworkColor(color));
        }
        itemMap.setFirework(((FireworkMeta) item.getItemMeta()).getEffects().get(0));
        itemMap.setFireworkColor(colors);
        itemMap.setFireworkFlicker(((FireworkMeta) item.getItemMeta()).getEffects().get(0).hasFlicker());
        itemMap.setFireworkTrail(((FireworkMeta) item.getItemMeta()).getEffects().get(0).hasTrail());
        itemMap.setFireworkType(((FireworkMeta) item.getItemMeta()).getEffects().get(0).getType());
        itemMap.setFireworkPower(((FireworkMeta) item.getItemMeta()).getPower());
    } else if (itemMap.getMaterial() == Material.WRITTEN_BOOK) {
        itemMap.setAuthor(((BookMeta) item.getItemMeta()).getAuthor().replace("�", "&"));
        itemMap.setTitle(((BookMeta) item.getItemMeta()).getTitle().replace("�", "&"));
        if (ServerUtils.hasSpecificUpdate("1_10")) {
            itemMap.setGeneration(((BookMeta) item.getItemMeta()).getGeneration());
        }
        List<String> newPages = new ArrayList<String>();
        for (String page : ((BookMeta) item.getItemMeta()).getPages()) {
            newPages.add(page.replace("�", "&"));
        }
        itemMap.setPages(newPages);
        List<List<String>> savePages = new ArrayList<List<String>>();
        for (String page : ((BookMeta) item.getItemMeta()).getPages()) {
            List<String> pageList = new ArrayList<String>();
            for (String splitPage : page.split("\n")) {
                pageList.add(splitPage.replace("�", "&"));
            }
            savePages.add(pageList);
        }
        itemMap.setListPages(savePages);
    }
    if (slot == null) {
        switchPane(player, itemMap, 0);
    } else {
        itemMap.setSlot(slot);
        itemMap.saveToConfig();
        String[] placeHolders = LanguageAPI.getLang(false).newString();
        placeHolders[3] = (item.hasItemMeta() && item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : itemMap.getConfigName());
        LanguageAPI.getLang(false).sendLangMessage("commands.menu.itemSaved", player, placeHolders);
    }
    itemMap.renderItemStack();
}
Also used : BannerMeta(org.bukkit.inventory.meta.BannerMeta) HashMap(java.util.HashMap) Color(org.bukkit.Color) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) ArrayList(java.util.ArrayList) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) DyeColor(org.bukkit.DyeColor) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) List(java.util.List) ArrayList(java.util.ArrayList) Enchantment(org.bukkit.enchantments.Enchantment) BookMeta(org.bukkit.inventory.meta.BookMeta)

Example 17 with ItemMap

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

the class Menu method bannerPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for modifying banner items.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void bannerPane(final Player player, final ItemMap itemMap) {
    Interface bannerPane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        bannerPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> creatingPane(player, itemMap)));
        for (PatternType pattern : PatternType.values()) {
            String patternString = "NONE";
            if (StringUtils.nullCheck(itemMap.getBannerPatterns().toString()) != "NONE") {
                for (Pattern patterns : itemMap.getBannerPatterns()) {
                    if (patterns.getPattern() == pattern) {
                        patternString = patterns.getColor() + ":" + patterns.getPattern().name().toUpperCase();
                        break;
                    }
                }
            }
            final String checkPattern = patternString;
            bannerPane.addButton(new Button(ItemHandler.getItem("PAPER", 1, (checkPattern != "NONE" ? true : false), "&f" + pattern.name(), "&7", "&7*Click to add this as", "&7a banner pattern.", (checkPattern != "NONE" ? "&9&lInformation: &a" + checkPattern : "")), event -> {
                if (checkPattern != "NONE") {
                    List<Pattern> patternList = itemMap.getBannerPatterns();
                    if (StringUtils.nullCheck(itemMap.getBannerPatterns().toString()) != "NONE") {
                        for (Pattern patterns : patternList) {
                            if (patterns.getPattern() == pattern) {
                                patternList.remove(patterns);
                                itemMap.setBannerPatterns(patternList);
                                break;
                            }
                        }
                    }
                    bannerPane(player, itemMap);
                } else {
                    patternPane(player, itemMap, pattern);
                }
            }));
        }
    });
    bannerPane.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) Pattern(org.bukkit.block.banner.Pattern) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) List(java.util.List) ArrayList(java.util.ArrayList) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 18 with ItemMap

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

the class Menu method modifyLoreLinePane.

/**
 * Opens the Pane for the Player.
 * This Pane is for modifying a specific lore line.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void modifyLoreLinePane(final Player player, final ItemMap itemMap, final int position) {
    Interface modifyLorePane = new Interface(false, 2, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        modifyLorePane.addButton(new Button(fillerPaneGItem), 3);
        modifyLorePane.addButton(new Button(ItemHandler.getItem("WRITABLE_BOOK", 1, false, "&e&l&nModify", "&7", "&7*Change the lore line.", "&9&lLore: &a" + itemMap.getCustomLore().get(position)), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "LORE LINE";
            placeHolders[15] = "&bThis is a new lore line.";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            List<String> lore = itemMap.getCustomLore();
            lore.set(position, ChatColor.stripColor(event.getMessage()));
            itemMap.setCustomLore(lore);
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "LORE LINE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            modifyLoreLinePane(event.getPlayer(), itemMap, position);
        }));
        modifyLorePane.addButton(new Button(fillerPaneGItem));
        modifyLorePane.addButton(new Button(ItemHandler.getItem("REDSTONE", 1, false, "&c&l&nDelete", "&7", "&7*Delete this lore line."), event -> {
            List<String> lore = itemMap.getCustomLore();
            lore.remove(position);
            itemMap.setCustomLore(lore);
            lorePane(player, itemMap);
        }));
        modifyLorePane.addButton(new Button(fillerPaneGItem), 3);
        modifyLorePane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> lorePane(player, itemMap)));
        modifyLorePane.addButton(new Button(fillerPaneBItem), 7);
        modifyLorePane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> lorePane(player, itemMap)));
    });
    modifyLorePane.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 19 with ItemMap

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

the class Menu method soundPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for setting an items command sound.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void soundPane(final Player player, final ItemMap itemMap, final int stage) {
    Interface soundPane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        if (stage != 3) {
            soundPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the teleport menu."), event -> teleportPane(player, itemMap, stage)));
        } else {
            soundPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item commands menu."), event -> commandPane(player, itemMap)));
        }
        for (Sound sound : Sound.values()) {
            if (stage != 3) {
                soundPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "MUSIC_DISC_MELLOHI" : "2262"), 1, false, "&f" + sound.name(), "&7", "&7*Click to set the", "&7teleport-sound of the item."), event -> {
                    itemMap.setTeleportSound(sound.name());
                    soundVolumePane(player, itemMap, stage);
                }));
            } else {
                soundPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "MUSIC_DISC_MELLOHI" : "2262"), 1, false, "&f" + sound.name(), "&7", "&7*Click to set the", "&7commands-sound of the item."), event -> {
                    itemMap.setCommandSound(sound);
                    soundVolumePane(player, itemMap, stage);
                }));
            }
        }
    });
    soundPane.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) Sound(org.bukkit.Sound) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 20 with ItemMap

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

the class Menu method mobsPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for setting the mobs drop chances.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void mobsPane(final Player player, final ItemMap itemMap) {
    Interface dropsPane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        dropsPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the drop chances menu."), event -> dropsPane(player, itemMap)));
        for (EntityType entity : EntityType.values()) {
            if (itemMap.getMobsDrop().containsKey(entity) && entity.isAlive()) {
                dropsPane.addButton(new Button(ItemHandler.getItem("EGG", 1, (itemMap.getMobsDrop().containsKey(entity)), "&f" + entity.name(), "&7", "&7*Click to add this as", "&7a banner pattern.", (itemMap.getMobsDrop().containsKey(entity) ? "&9&lChance: &a" + itemMap.getMobsDrop().get(entity) : "")), event -> {
                    if (itemMap.getMobsDrop().containsKey(entity)) {
                        Map<EntityType, Double> mobsDrop = itemMap.getMobsDrop();
                        mobsDrop.remove(entity);
                        itemMap.setMobsDrop(mobsDrop);
                        mobsPane(player, itemMap);
                    } else {
                        chancePane(player, itemMap, entity, null);
                    }
                }));
            }
        }
        for (EntityType entity : EntityType.values()) {
            if (!itemMap.getMobsDrop().containsKey(entity) && entity.isAlive()) {
                dropsPane.addButton(new Button(ItemHandler.getItem("EGG", 1, (itemMap.getMobsDrop().containsKey(entity)), "&f" + entity.name(), "&7", "&7*Click to add this as", "&7a banner pattern.", (itemMap.getMobsDrop().containsKey(entity) ? "&9&lChance: &a" + itemMap.getMobsDrop().get(entity) : "")), event -> {
                    if (itemMap.getMobsDrop().containsKey(entity)) {
                        Map<EntityType, Double> mobsDrop = itemMap.getMobsDrop();
                        mobsDrop.remove(entity);
                        itemMap.setMobsDrop(mobsDrop);
                        mobsPane(player, itemMap);
                    } else {
                        chancePane(player, itemMap, entity, null);
                    }
                }));
            }
        }
    });
    dropsPane.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) EntityType(org.bukkit.entity.EntityType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) Map(java.util.Map) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) HashMap(java.util.HashMap) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

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