Search in sources :

Example 1 with Generation

use of org.bukkit.inventory.meta.BookMeta.Generation in project InteractiveChat-DiscordSRV-Addon by LOOHP.

the class DiscordItemStackUtils method getToolTip.

public static DiscordToolTip getToolTip(ItemStack item, Player player) throws Exception {
    String language = InteractiveChatDiscordSrvAddon.plugin.language;
    if (!item.getType().equals(Material.AIR) && InteractiveChat.ecoHook) {
        item = EcoHook.setEcoLores(item, player);
    }
    List<Component> prints = new ArrayList<>();
    boolean hasCustomName = true;
    if (item == null) {
        item = new ItemStack(Material.AIR);
    }
    XMaterial xMaterial = XMaterialUtils.matchXMaterial(item);
    Component itemDisplayNameComponent = ItemStackUtils.getDisplayName(item);
    prints.add(itemDisplayNameComponent);
    boolean hasMeta = item.hasItemMeta();
    if (xMaterial.equals(XMaterial.WRITTEN_BOOK) && hasMeta && item.getItemMeta() instanceof BookMeta) {
        BookMeta meta = (BookMeta) item.getItemMeta();
        String author = meta.getAuthor();
        if (author != null) {
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getBookAuthor(), language).replaceFirst("%1\\$s", author)));
        }
        Generation generation = meta.getGeneration();
        if (generation == null) {
            generation = Generation.ORIGINAL;
        }
        prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getBookGeneration(generation), language)));
    }
    if (xMaterial.equals(XMaterial.SHIELD) && (!hasMeta || (hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)))) {
        if (NBTEditor.contains(item, "BlockEntityTag")) {
            List<Pattern> patterns = Collections.emptyList();
            if (!(item.getItemMeta() instanceof BannerMeta)) {
                if (item.getItemMeta() instanceof BlockStateMeta) {
                    BlockStateMeta bmeta = (BlockStateMeta) item.getItemMeta();
                    if (bmeta.hasBlockState()) {
                        Banner bannerBlockMeta = (Banner) bmeta.getBlockState();
                        patterns = bannerBlockMeta.getPatterns();
                    }
                }
            } else {
                BannerMeta meta = (BannerMeta) item.getItemMeta();
                patterns = meta.getPatterns();
            }
            for (Pattern pattern : patterns) {
                PatternTypeWrapper type = PatternTypeWrapper.fromPatternType(pattern.getPattern());
                prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getBannerPatternName(type, pattern.getColor()), language)));
            }
        }
    }
    if (xMaterial.isOneOf(Arrays.asList("CONTAINS:Banner")) && (!hasMeta || (hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)))) {
        List<Pattern> patterns = Collections.emptyList();
        if (!(item.getItemMeta() instanceof BannerMeta)) {
            if (item.getItemMeta() instanceof BlockStateMeta) {
                BlockStateMeta bmeta = (BlockStateMeta) item.getItemMeta();
                Banner bannerBlockMeta = (Banner) bmeta.getBlockState();
                patterns = bannerBlockMeta.getPatterns();
            }
        } else {
            BannerMeta meta = (BannerMeta) item.getItemMeta();
            patterns = meta.getPatterns();
        }
        for (Pattern pattern : patterns) {
            PatternTypeWrapper type = PatternTypeWrapper.fromPatternType(pattern.getPattern());
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getBannerPatternName(type, pattern.getColor()), language)));
        }
    }
    if (xMaterial.equals(XMaterial.TROPICAL_FISH_BUCKET)) {
        List<String> translations = TranslationKeyUtils.getTropicalFishBucketName(item);
        if (translations.size() > 0) {
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + "" + ChatColor.ITALIC + LanguageUtils.getTranslation(translations.get(0), language)));
            if (translations.size() > 1) {
                prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + "" + ChatColor.ITALIC + translations.stream().skip(1).map(each -> LanguageUtils.getTranslation(each, language)).collect(Collectors.joining(", "))));
            }
        }
    }
    if (xMaterial.isOneOf(Arrays.asList("CONTAINS:Music_Disc"))) {
        prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getMusicDiscName(item), language)));
    }
    if (xMaterial.equals(XMaterial.FIREWORK_ROCKET)) {
        if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && NBTEditor.contains(item, "Fireworks", "Flight")) {
            int flight = NBTEditor.getByte(item, "Fireworks", "Flight");
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getRocketFlightDuration(), language) + " " + flight));
        }
    }
    if (xMaterial.equals(XMaterial.CROSSBOW)) {
        CrossbowMeta meta = (CrossbowMeta) item.getItemMeta();
        List<ItemStack> charged = meta.getChargedProjectiles();
        if (charged != null && !charged.isEmpty()) {
            ItemStack charge = charged.get(0);
            Component chargeItemName = getToolTip(charge, player).getComponents().get(0);
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.WHITE + LanguageUtils.getTranslation(TranslationKeyUtils.getCrossbowProjectile(), language) + " [" + InteractiveChatComponentSerializer.bungeecordApiLegacy().serialize(chargeItemName) + ChatColor.WHITE + "]"));
        }
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && FilledMapUtils.isFilledMap(item)) {
        MapMeta map = (MapMeta) item.getItemMeta();
        MapView mapView;
        int id;
        if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_13_1)) {
            mapView = map.getMapView();
            id = mapView.getId();
        } else if (InteractiveChat.version.equals(MCVersion.V1_13)) {
            short shortId = (short) bukkitMapViewClassGetIdMethod.invoke(map);
            mapView = (MapView) bukkitBukkitClassGetMapShortMethod.invoke(null, shortId);
            id = shortId;
        } else {
            short shortId = item.getDurability();
            mapView = (MapView) bukkitBukkitClassGetMapShortMethod.invoke(null, shortId);
            id = shortId;
        }
        int scale = mapView.getScale().getValue();
        if (!InteractiveChat.version.isLegacy()) {
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getFilledMapId(), language).replaceFirst("%s", id + "")));
        } else {
            prints.set(0, prints.get(0).children(Arrays.asList(LegacyComponentSerializer.legacySection().deserialize(ChatColor.WHITE + " (#" + id + ")"))));
        }
        prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getFilledMapScale(), language).replaceFirst("%s", (int) Math.pow(2, scale) + "")));
        prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getFilledMapLevel(), language).replaceFirst("%s", scale + "").replaceFirst("%s", "4")));
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && !hasMeta || (hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS))) {
        if (item.getItemMeta() instanceof PotionMeta) {
            PotionMeta meta = (PotionMeta) item.getItemMeta();
            List<PotionEffect> effects = new ArrayList<>();
            List<PotionEffect> base = PotionUtils.getBasePotionEffect(item);
            if (base != null) {
                effects.addAll(base);
            }
            effects.addAll(meta.getCustomEffects());
            if (effects.isEmpty()) {
                prints.add(LegacyComponentSerializer.legacySection().deserialize(LanguageUtils.getTranslation(TranslationKeyUtils.getNoEffect(), language)));
            } else {
                for (PotionEffect effect : effects) {
                    String key = TranslationKeyUtils.getEffect(effect.getType());
                    String translation = LanguageUtils.getTranslation(key, language);
                    String description = "";
                    if (key.equals(translation)) {
                        description += WordUtils.capitalize(effect.getType().getName().toLowerCase().replace("_", " "));
                    } else {
                        description += translation;
                    }
                    int amplifier = effect.getAmplifier();
                    String effectLevelTranslation = LanguageUtils.getTranslation(TranslationKeyUtils.getEffectLevel(amplifier), language);
                    if (effectLevelTranslation.length() > 0) {
                        description += " " + effectLevelTranslation;
                    }
                    if (!effect.getType().isInstant()) {
                        if (xMaterial.equals(XMaterial.LINGERING_POTION)) {
                            description += " (" + TimeUtils.getReadableTimeBetween(0, effect.getDuration() / 4 * 50L, ":", ChronoUnit.MINUTES, ChronoUnit.SECONDS, true) + ")";
                        } else {
                            description += " (" + TimeUtils.getReadableTimeBetween(0, effect.getDuration() * 50L, ":", ChronoUnit.MINUTES, ChronoUnit.SECONDS, true) + ")";
                        }
                    }
                    ChatColor color;
                    try {
                        color = PotionUtils.getPotionEffectChatColor(effect.getType());
                    } catch (Throwable e) {
                        color = ChatColor.BLUE;
                    }
                    prints.add(LegacyComponentSerializer.legacySection().deserialize(color + description));
                }
            }
        }
    }
    if (!hasMeta || (hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS))) {
        if (hasMeta && item.getItemMeta() instanceof EnchantmentStorageMeta) {
            for (Entry<Enchantment, Integer> entry : CustomMapUtils.sortMapByValue(((EnchantmentStorageMeta) item.getItemMeta()).getStoredEnchants()).entrySet()) {
                Enchantment ench = entry.getKey();
                int level = entry.getValue();
                String key = TranslationKeyUtils.getEnchantment(ench);
                String translation = LanguageUtils.getTranslation(key, language);
                String enchName;
                if (key.equals(translation)) {
                    enchName = WordUtils.capitalize(ench.getName().toLowerCase().replace("_", " "));
                } else {
                    enchName = translation;
                }
                if (enchName != null) {
                    prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + enchName + (ench.getMaxLevel() == 1 && level == 1 ? "" : " " + LanguageUtils.getTranslation(TranslationKeyUtils.getEnchantmentLevel(level), language))));
                }
            }
        } else {
            for (Entry<Enchantment, Integer> entry : CustomMapUtils.sortMapByValue(item.getEnchantments()).entrySet()) {
                Enchantment ench = entry.getKey();
                int level = entry.getValue();
                String key = TranslationKeyUtils.getEnchantment(ench);
                String translation = LanguageUtils.getTranslation(key, language);
                String enchName;
                if (key.equals(translation)) {
                    enchName = WordUtils.capitalize(ench.getName().toLowerCase().replace("_", " "));
                } else {
                    enchName = translation;
                }
                if (enchName != null) {
                    prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + enchName + (ench.getMaxLevel() == 1 && level == 1 ? "" : " " + LanguageUtils.getTranslation(TranslationKeyUtils.getEnchantmentLevel(level), language))));
                }
            }
        }
    }
    if (hasMeta && item.getItemMeta() instanceof LeatherArmorMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_DYE)) {
        LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
        if (NBTEditor.contains(item, "display", "color")) {
            Color color = new Color(meta.getColor().asRGB());
            String hex = ColorUtils.rgb2Hex(color).toUpperCase();
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getDyeColor(), language).replaceFirst("%s", hex)));
        }
    }
    if (hasMeta) {
        ItemMeta meta = item.getItemMeta();
        if (meta.hasLore()) {
            for (String lore : meta.getLore()) {
                prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.DARK_PURPLE + "" + ChatColor.ITALIC + lore));
            }
        }
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && hasMeta && NBTEditor.contains(item, "AttributeModifiers") && NBTEditor.getSize(item, "AttributeModifiers") > 0 && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_ATTRIBUTES)) {
        boolean useMainHand = false;
        List<Component> mainHand = new LinkedList<>();
        boolean useOffhand = false;
        List<Component> offHand = new LinkedList<>();
        boolean useFeet = false;
        List<Component> feet = new LinkedList<>();
        boolean useLegs = false;
        List<Component> legs = new LinkedList<>();
        boolean useChest = false;
        List<Component> chest = new LinkedList<>();
        boolean useHead = false;
        List<Component> head = new LinkedList<>();
        ListTag<CompoundTag> attributeList = (ListTag<CompoundTag>) new SNBTDeserializer().fromString(NBTEditor.getNBTCompound(item, "tag", "AttributeModifiers").toJson());
        for (CompoundTag attributeTag : attributeList) {
            String attributeName = attributeTag.getString("AttributeName").replace("minecraft:", "");
            double amount = attributeTag.getDouble("Amount");
            int operation = attributeTag.containsKey("Operation") ? attributeTag.getInt("Operation") : 0;
            Component attributeComponent = LegacyComponentSerializer.legacySection().deserialize((amount < 0 ? ChatColor.RED : ChatColor.BLUE) + LanguageUtils.getTranslation(TranslationKeyUtils.getAttributeModifierKey(amount, operation), language).replaceFirst("%s", ATTRIBUTE_FORMAT.format(Math.abs(amount)) + "").replaceFirst("%s", LanguageUtils.getTranslation(TranslationKeyUtils.getAttributeKey(attributeName), language)).replace("%%", "%"));
            if (attributeTag.containsKey("Slot")) {
                String slot = attributeTag.getString("Slot");
                switch(slot) {
                    case "mainhand":
                        if (amount != 0) {
                            mainHand.add(attributeComponent);
                        }
                        useMainHand = true;
                        break;
                    case "offhand":
                        if (amount != 0) {
                            offHand.add(attributeComponent);
                        }
                        useOffhand = true;
                        break;
                    case "feet":
                        if (amount != 0) {
                            feet.add(attributeComponent);
                        }
                        useFeet = true;
                        break;
                    case "legs":
                        if (amount != 0) {
                            legs.add(attributeComponent);
                        }
                        useLegs = true;
                        break;
                    case "chest":
                        if (amount != 0) {
                            chest.add(attributeComponent);
                        }
                        useChest = true;
                        break;
                    case "head":
                        if (amount != 0) {
                            head.add(attributeComponent);
                        }
                        useHead = true;
                        break;
                }
            } else {
                if (amount != 0) {
                    mainHand.add(attributeComponent);
                    offHand.add(attributeComponent);
                    feet.add(attributeComponent);
                    legs.add(attributeComponent);
                    chest.add(attributeComponent);
                    head.add(attributeComponent);
                }
                useMainHand = true;
                useOffhand = true;
                useFeet = true;
                useLegs = true;
                useChest = true;
                useHead = true;
            }
        }
        if (useMainHand) {
            prints.add(Component.empty());
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.HAND), language)));
            prints.addAll(mainHand);
        }
        if (useOffhand) {
            prints.add(Component.empty());
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.OFF_HAND), language)));
            prints.addAll(offHand);
        }
        if (useFeet) {
            prints.add(Component.empty());
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.FEET), language)));
            prints.addAll(feet);
        }
        if (useLegs) {
            prints.add(Component.empty());
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.LEGS), language)));
            prints.addAll(legs);
        }
        if (useChest) {
            prints.add(Component.empty());
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.CHEST), language)));
            prints.addAll(chest);
        }
        if (useHead) {
            prints.add(Component.empty());
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.HEAD), language)));
            prints.addAll(head);
        }
    }
    if (hasMeta && isUnbreakable(item) && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_UNBREAKABLE)) {
        prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.BLUE + LanguageUtils.getTranslation(TranslationKeyUtils.getUnbreakable(), language)));
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_DESTROYS)) {
        if (NBTEditor.contains(item, "CanDestroy") && NBTEditor.getSize(item, "CanDestroy") > 0) {
            prints.add(Component.empty());
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getCanDestroy(), language)));
            ListTag<StringTag> materialList = (ListTag<StringTag>) new SNBTDeserializer().fromString(NBTEditor.getNBTCompound(item, "tag", "CanDestroy").toJson());
            for (StringTag materialTag : materialList) {
                XMaterial parsedXMaterial = XMaterialUtils.matchXMaterial(materialTag.getValue().replace("minecraft:", "").toUpperCase());
                if (parsedXMaterial == null) {
                    prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.DARK_GRAY + WordUtils.capitalizeFully(materialTag.getValue().replace("_", " ").toLowerCase())));
                } else {
                    prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.DARK_GRAY + LanguageUtils.getTranslation(LanguageUtils.getTranslationKey(parsedXMaterial.parseItem()), language)));
                }
            }
        }
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_PLACED_ON)) {
        if (NBTEditor.contains(item, "CanPlaceOn") && NBTEditor.getSize(item, "CanPlaceOn") > 0) {
            prints.add(Component.empty());
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.GRAY + LanguageUtils.getTranslation(TranslationKeyUtils.getCanPlace(), language)));
            ListTag<StringTag> materialList = (ListTag<StringTag>) new SNBTDeserializer().fromString(NBTEditor.getNBTCompound(item, "tag", "CanPlaceOn").toJson());
            for (StringTag materialTag : materialList) {
                XMaterial parsedXMaterial = XMaterialUtils.matchXMaterial(materialTag.getValue().replace("minecraft:", "").toUpperCase());
                if (parsedXMaterial == null) {
                    prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.DARK_GRAY + WordUtils.capitalizeFully(materialTag.getValue().replace("_", " ").toLowerCase())));
                } else {
                    prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.DARK_GRAY + LanguageUtils.getTranslation(LanguageUtils.getTranslationKey(parsedXMaterial.parseItem()), language)));
                }
            }
        }
    }
    if (item.getType().getMaxDurability() > 0) {
        int durability = item.getType().getMaxDurability() - (InteractiveChat.version.isLegacy() ? item.getDurability() : ((Damageable) item.getItemMeta()).getDamage());
        int maxDur = item.getType().getMaxDurability();
        if (durability < maxDur) {
            prints.add(LegacyComponentSerializer.legacySection().deserialize(ChatColor.WHITE + LanguageUtils.getTranslation(TranslationKeyUtils.getDurability(), language).replaceFirst("%s", String.valueOf(durability)).replaceFirst("%s", String.valueOf(maxDur))));
        }
    }
    return new DiscordToolTip(prints, !hasCustomName && prints.size() <= 1);
}
Also used : StringTag(com.loohp.interactivechat.libs.net.querz.nbt.tag.StringTag) PotionEffect(org.bukkit.potion.PotionEffect) ArrayList(java.util.ArrayList) MapView(org.bukkit.map.MapView) Component(com.loohp.interactivechat.libs.net.kyori.adventure.text.Component) CrossbowMeta(org.bukkit.inventory.meta.CrossbowMeta) ItemMeta(org.bukkit.inventory.meta.ItemMeta) CompoundTag(com.loohp.interactivechat.libs.net.querz.nbt.tag.CompoundTag) Pattern(org.bukkit.block.banner.Pattern) BannerMeta(org.bukkit.inventory.meta.BannerMeta) Banner(org.bukkit.block.Banner) Color(java.awt.Color) ChatColor(net.md_5.bungee.api.ChatColor) PatternTypeWrapper(com.loohp.interactivechatdiscordsrvaddon.wrappers.PatternTypeWrapper) PotionMeta(org.bukkit.inventory.meta.PotionMeta) XMaterial(com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial) ListTag(com.loohp.interactivechat.libs.net.querz.nbt.tag.ListTag) LinkedList(java.util.LinkedList) BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) Generation(org.bukkit.inventory.meta.BookMeta.Generation) EnchantmentStorageMeta(org.bukkit.inventory.meta.EnchantmentStorageMeta) MapMeta(org.bukkit.inventory.meta.MapMeta) SNBTDeserializer(com.loohp.interactivechat.libs.net.querz.nbt.io.SNBTDeserializer) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemStack(org.bukkit.inventory.ItemStack) Enchantment(org.bukkit.enchantments.Enchantment) BookMeta(org.bukkit.inventory.meta.BookMeta) ChatColor(net.md_5.bungee.api.ChatColor)

Example 2 with Generation

use of org.bukkit.inventory.meta.BookMeta.Generation in project SignShop by wargamer.

the class BookItem method setGeneration.

@Override
public void setGeneration(Integer generation) {
    if (meta == null)
        return;
    else if (generation == null) {
        meta.setGeneration(null);
        return;
    }
    try {
        Generation enumGen = Generation.values()[generation];
        meta.setGeneration(enumGen);
    } catch (ArrayIndexOutOfBoundsException e) {
        SignShop.log("Book's generation is out of bounds; leaving as default (ORIGINAL)", Level.WARNING);
    }
}
Also used : Generation(org.bukkit.inventory.meta.BookMeta.Generation)

Example 3 with Generation

use of org.bukkit.inventory.meta.BookMeta.Generation in project InteractiveChat-DiscordSRV-Addon by LOOHP.

the class DiscordItemStackUtils method getDiscordDescription.

public static DiscordDescription getDiscordDescription(ItemStack item, Player player) throws Exception {
    String language = InteractiveChatDiscordSrvAddon.plugin.language;
    if (!item.getType().equals(Material.AIR) && InteractiveChat.ecoHook) {
        item = EcoHook.setEcoLores(item, player);
    }
    if (item == null) {
        item = new ItemStack(Material.AIR);
    }
    XMaterial xMaterial = XMaterialUtils.matchXMaterial(item);
    String name = PlainTextComponentSerializer.plainText().serialize(LegacyComponentSerializer.legacySection().deserialize(InteractiveChatComponentSerializer.bungeecordApiLegacy().serialize(ItemStackUtils.getDisplayName(item), language)));
    if (item.getAmount() == 1 || item == null || item.getType().equals(Material.AIR)) {
        name = InteractiveChatDiscordSrvAddon.plugin.itemDisplaySingle.replace("{Item}", ComponentStringUtils.stripColorAndConvertMagic(name)).replace("{Amount}", String.valueOf(item.getAmount()));
    } else {
        name = InteractiveChatDiscordSrvAddon.plugin.itemDisplayMultiple.replace("{Item}", ComponentStringUtils.stripColorAndConvertMagic(name)).replace("{Amount}", String.valueOf(item.getAmount()));
    }
    boolean hasMeta = item.hasItemMeta();
    StringBuilder description = new StringBuilder();
    if (xMaterial.equals(XMaterial.WRITTEN_BOOK) && hasMeta && item.getItemMeta() instanceof BookMeta) {
        BookMeta meta = (BookMeta) item.getItemMeta();
        String author = meta.getAuthor();
        if (author != null) {
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getBookAuthor(), language).replaceFirst("%1\\$s", ChatColorUtils.stripColor(author))).append("\n");
        }
        Generation generation = meta.getGeneration();
        if (generation == null) {
            generation = Generation.ORIGINAL;
        }
        description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getBookGeneration(generation), language)).append("\n");
        description.append("\n");
    }
    if (xMaterial.equals(XMaterial.SHIELD) && (!hasMeta || (hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)))) {
        if (NBTEditor.contains(item, "BlockEntityTag")) {
            List<Pattern> patterns = Collections.emptyList();
            if (!(item.getItemMeta() instanceof BannerMeta)) {
                if (item.getItemMeta() instanceof BlockStateMeta) {
                    BlockStateMeta bmeta = (BlockStateMeta) item.getItemMeta();
                    if (bmeta.hasBlockState()) {
                        Banner bannerBlockMeta = (Banner) bmeta.getBlockState();
                        patterns = bannerBlockMeta.getPatterns();
                    }
                }
            } else {
                BannerMeta meta = (BannerMeta) item.getItemMeta();
                patterns = meta.getPatterns();
            }
            for (Pattern pattern : patterns) {
                PatternTypeWrapper type = PatternTypeWrapper.fromPatternType(pattern.getPattern());
                description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getBannerPatternName(type, pattern.getColor()), language)).append("\n");
            }
        }
    }
    if (xMaterial.isOneOf(Arrays.asList("CONTAINS:Banner")) && (!hasMeta || (hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)))) {
        List<Pattern> patterns = Collections.emptyList();
        if (!(item.getItemMeta() instanceof BannerMeta)) {
            if (item.getItemMeta() instanceof BlockStateMeta) {
                BlockStateMeta bmeta = (BlockStateMeta) item.getItemMeta();
                Banner bannerBlockMeta = (Banner) bmeta.getBlockState();
                patterns = bannerBlockMeta.getPatterns();
            }
        } else {
            BannerMeta meta = (BannerMeta) item.getItemMeta();
            patterns = meta.getPatterns();
        }
        for (Pattern pattern : patterns) {
            PatternTypeWrapper type = PatternTypeWrapper.fromPatternType(pattern.getPattern());
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getBannerPatternName(type, pattern.getColor()), language)).append("\n");
        }
    }
    if (xMaterial.equals(XMaterial.TROPICAL_FISH_BUCKET)) {
        List<String> translations = TranslationKeyUtils.getTropicalFishBucketName(item);
        if (translations.size() > 0) {
            description.append(LanguageUtils.getTranslation(translations.get(0), language)).append("\n");
            if (translations.size() > 1) {
                description.append(translations.stream().skip(1).map(each -> LanguageUtils.getTranslation(each, language)).collect(Collectors.joining(", "))).append("\n");
            }
            description.append("\n");
        }
    }
    if (xMaterial.isOneOf(Arrays.asList("CONTAINS:Music_Disc"))) {
        description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getMusicDiscName(item), language)).append("\n");
    }
    if (xMaterial.equals(XMaterial.FIREWORK_ROCKET)) {
        if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && NBTEditor.contains(item, "Fireworks", "Flight")) {
            int flight = NBTEditor.getByte(item, "Fireworks", "Flight");
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getRocketFlightDuration(), language)).append(" ").append(flight).append("\n");
        }
    }
    if (xMaterial.equals(XMaterial.CROSSBOW)) {
        CrossbowMeta meta = (CrossbowMeta) item.getItemMeta();
        List<ItemStack> charged = meta.getChargedProjectiles();
        if (charged != null && !charged.isEmpty()) {
            ItemStack charge = charged.get(0);
            String chargeItemName = getDiscordDescription(charge, player).getName();
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getCrossbowProjectile(), language)).append(" [**").append(chargeItemName).append("**]\n\n");
        }
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && FilledMapUtils.isFilledMap(item)) {
        MapMeta map = (MapMeta) item.getItemMeta();
        MapView mapView;
        int id;
        if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_13_1)) {
            mapView = map.getMapView();
            id = mapView.getId();
        } else if (InteractiveChat.version.equals(MCVersion.V1_13)) {
            short shortId = (short) bukkitMapViewClassGetIdMethod.invoke(map);
            mapView = (MapView) bukkitBukkitClassGetMapShortMethod.invoke(null, shortId);
            id = shortId;
        } else {
            short shortId = item.getDurability();
            mapView = (MapView) bukkitBukkitClassGetMapShortMethod.invoke(null, shortId);
            id = shortId;
        }
        int scale = mapView.getScale().getValue();
        if (!InteractiveChat.version.isLegacy()) {
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getFilledMapId(), language).replaceFirst("%s", id + "")).append("\n");
        } else {
            name += " (#" + id + ")";
        }
        description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getFilledMapScale(), language).replaceFirst("%s", (int) Math.pow(2, scale) + "")).append("\n");
        description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getFilledMapLevel(), language).replaceFirst("%s", scale + "").replaceFirst("%s", "4")).append("\n");
        description.append("\n");
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && !hasMeta || (hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS))) {
        if (item.getItemMeta() instanceof PotionMeta) {
            PotionMeta meta = (PotionMeta) item.getItemMeta();
            List<PotionEffect> effects = new ArrayList<>();
            List<PotionEffect> base = PotionUtils.getBasePotionEffect(item);
            if (base != null) {
                effects.addAll(base);
            }
            effects.addAll(meta.getCustomEffects());
            if (effects.isEmpty()) {
                description.append("**").append(LanguageUtils.getTranslation(TranslationKeyUtils.getNoEffect(), language)).append("**\n");
            } else {
                for (PotionEffect effect : effects) {
                    String key = TranslationKeyUtils.getEffect(effect.getType());
                    String translation = LanguageUtils.getTranslation(key, language);
                    if (key.equals(translation)) {
                        description.append("**").append(WordUtils.capitalize(effect.getType().getName().toLowerCase().replace("_", " ")));
                    } else {
                        description.append("**").append(translation);
                    }
                    int amplifier = effect.getAmplifier();
                    String effectLevelTranslation = LanguageUtils.getTranslation(TranslationKeyUtils.getEffectLevel(amplifier), language);
                    if (effectLevelTranslation.length() > 0) {
                        description.append(" ").append(effectLevelTranslation);
                    }
                    if (!effect.getType().isInstant()) {
                        if (xMaterial.equals(XMaterial.LINGERING_POTION)) {
                            description.append(" (").append(TimeUtils.getReadableTimeBetween(0, effect.getDuration() / 4 * 50L, ":", ChronoUnit.MINUTES, ChronoUnit.SECONDS, true)).append(")");
                        } else {
                            description.append(" (").append(TimeUtils.getReadableTimeBetween(0, effect.getDuration() * 50L, ":", ChronoUnit.MINUTES, ChronoUnit.SECONDS, true)).append(")");
                        }
                    }
                    description.append("**\n");
                }
            }
            if (!description.toString().equals("")) {
                description.append("\n");
            }
        }
    }
    if (!hasMeta || (hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS))) {
        if (hasMeta && item.getItemMeta() instanceof EnchantmentStorageMeta) {
            for (Entry<Enchantment, Integer> entry : CustomMapUtils.sortMapByValue(((EnchantmentStorageMeta) item.getItemMeta()).getStoredEnchants()).entrySet()) {
                Enchantment ench = entry.getKey();
                int level = entry.getValue();
                String key = TranslationKeyUtils.getEnchantment(ench);
                String translation = LanguageUtils.getTranslation(key, language);
                String enchName;
                if (key.equals(translation)) {
                    enchName = WordUtils.capitalize(ench.getName().toLowerCase().replace("_", " "));
                } else {
                    enchName = translation;
                }
                if (enchName != null) {
                    description.append("**").append(enchName).append(ench.getMaxLevel() == 1 && level == 1 ? "" : " " + LanguageUtils.getTranslation(TranslationKeyUtils.getEnchantmentLevel(level), language)).append("**\n");
                }
            }
        } else {
            for (Entry<Enchantment, Integer> entry : CustomMapUtils.sortMapByValue(item.getEnchantments()).entrySet()) {
                Enchantment ench = entry.getKey();
                int level = entry.getValue();
                String key = TranslationKeyUtils.getEnchantment(ench);
                String translation = LanguageUtils.getTranslation(key, language);
                String enchName;
                if (key.equals(translation)) {
                    enchName = WordUtils.capitalize(ench.getName().toLowerCase().replace("_", " "));
                } else {
                    enchName = translation;
                }
                if (enchName != null) {
                    description.append("**").append(enchName).append(ench.getMaxLevel() == 1 && level == 1 ? "" : " " + LanguageUtils.getTranslation(TranslationKeyUtils.getEnchantmentLevel(level), language)).append("**\n");
                }
            }
        }
    }
    if (hasMeta && item.getItemMeta() instanceof LeatherArmorMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_DYE)) {
        LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
        if (NBTEditor.contains(item, "display", "color")) {
            if (!description.toString().equals("")) {
                description.append("\n");
            }
            Color color = new Color(meta.getColor().asRGB());
            String hex = ColorUtils.rgb2Hex(color).toUpperCase();
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getDyeColor(), language).replaceFirst("%s", hex)).append("\n");
        }
    }
    if (hasMeta) {
        ItemMeta meta = item.getItemMeta();
        if (meta.hasLore()) {
            if (!description.toString().equals("")) {
                description.append("\n");
            }
            String lore = String.join("\n", meta.getLore());
            if (DiscordSRV.config().getBoolean("Experiment_MCDiscordReserializer_ToDiscord")) {
                if (InteractiveChatDiscordSrvAddon.plugin.escapeDiscordMarkdownInItems) {
                    lore = lore.replaceAll(DiscordDataRegistry.getMarkdownSpecialPattern(), "\\\\$1");
                }
                lore = DiscordSerializer.INSTANCE.serialize(ComponentStringUtils.toDiscordSRVComponent(LEGACY_SERIALIZER.deserialize(lore)));
            } else {
                lore = ComponentStringUtils.stripColorAndConvertMagic(String.join("\n", meta.getLore()));
                if (InteractiveChatDiscordSrvAddon.plugin.escapeDiscordMarkdownInItems) {
                    lore = lore.replaceAll(DiscordDataRegistry.getMarkdownSpecialPattern(), "\\\\$1");
                }
            }
            description.append(lore).append("\n");
        }
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && hasMeta && NBTEditor.contains(item, "AttributeModifiers") && NBTEditor.getSize(item, "AttributeModifiers") > 0 && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_ATTRIBUTES)) {
        boolean useMainHand = false;
        List<String> mainHand = new LinkedList<>();
        boolean useOffhand = false;
        List<String> offHand = new LinkedList<>();
        boolean useFeet = false;
        List<String> feet = new LinkedList<>();
        boolean useLegs = false;
        List<String> legs = new LinkedList<>();
        boolean useChest = false;
        List<String> chest = new LinkedList<>();
        boolean useHead = false;
        List<String> head = new LinkedList<>();
        ListTag<CompoundTag> attributeList = (ListTag<CompoundTag>) new SNBTDeserializer().fromString(NBTEditor.getNBTCompound(item, "tag", "AttributeModifiers").toJson());
        for (CompoundTag attributeTag : attributeList) {
            String attributeName = attributeTag.getString("AttributeName").replace("minecraft:", "");
            double amount = attributeTag.getDouble("Amount");
            int operation = attributeTag.containsKey("Operation") ? attributeTag.getInt("Operation") : 0;
            String attributeComponent = LanguageUtils.getTranslation(TranslationKeyUtils.getAttributeModifierKey(amount, operation), language).replaceFirst("%s", ATTRIBUTE_FORMAT.format(Math.abs(amount)) + "").replaceFirst("%s", LanguageUtils.getTranslation(TranslationKeyUtils.getAttributeKey(attributeName), language)).replace("%%", "%");
            if (attributeTag.containsKey("Slot")) {
                String slot = attributeTag.getString("Slot");
                switch(slot) {
                    case "mainhand":
                        if (amount != 0) {
                            mainHand.add(attributeComponent);
                        }
                        useMainHand = true;
                        break;
                    case "offhand":
                        if (amount != 0) {
                            offHand.add(attributeComponent);
                        }
                        useOffhand = true;
                        break;
                    case "feet":
                        if (amount != 0) {
                            feet.add(attributeComponent);
                        }
                        useFeet = true;
                        break;
                    case "legs":
                        if (amount != 0) {
                            legs.add(attributeComponent);
                        }
                        useLegs = true;
                        break;
                    case "chest":
                        if (amount != 0) {
                            chest.add(attributeComponent);
                        }
                        useChest = true;
                        break;
                    case "head":
                        if (amount != 0) {
                            head.add(attributeComponent);
                        }
                        useHead = true;
                        break;
                }
            } else {
                if (amount != 0) {
                    mainHand.add(attributeComponent);
                    offHand.add(attributeComponent);
                    feet.add(attributeComponent);
                    legs.add(attributeComponent);
                    chest.add(attributeComponent);
                    head.add(attributeComponent);
                }
                useMainHand = true;
                useOffhand = true;
                useFeet = true;
                useLegs = true;
                useChest = true;
                useHead = true;
            }
        }
        if (useMainHand) {
            description.append("\n");
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.HAND), language)).append("\n");
            for (String each : mainHand) {
                description.append(each).append("\n");
            }
        }
        if (useOffhand) {
            description.append("\n");
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.OFF_HAND), language)).append("\n");
            for (String each : offHand) {
                description.append(each).append("\n");
            }
        }
        if (useFeet) {
            description.append("\n");
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.FEET), language)).append("\n");
            for (String each : feet) {
                description.append(each).append("\n");
            }
        }
        if (useLegs) {
            description.append("\n");
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.LEGS), language)).append("\n");
            for (String each : legs) {
                description.append(each).append("\n");
            }
        }
        if (useChest) {
            description.append("\n");
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.CHEST), language)).append("\n");
            for (String each : chest) {
                description.append(each).append("\n");
            }
        }
        if (useHead) {
            description.append("\n");
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getModifierSlotKey(EquipmentSlot.HEAD), language)).append("\n");
            for (String each : head) {
                description.append(each).append("\n");
            }
        }
    }
    if (hasMeta && isUnbreakable(item) && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_UNBREAKABLE)) {
        if (!description.toString().equals("")) {
            description.append("\n");
        }
        description.append("**").append(LanguageUtils.getTranslation(TranslationKeyUtils.getUnbreakable(), language)).append("**\n");
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_DESTROYS)) {
        if (NBTEditor.contains(item, "CanDestroy") && NBTEditor.getSize(item, "CanDestroy") > 0) {
            description.append("\n");
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getCanDestroy(), language)).append("\n");
            ListTag<StringTag> materialList = (ListTag<StringTag>) new SNBTDeserializer().fromString(NBTEditor.getNBTCompound(item, "tag", "CanDestroy").toJson());
            for (StringTag materialTag : materialList) {
                XMaterial parsedXMaterial = XMaterialUtils.matchXMaterial(materialTag.getValue().replace("minecraft:", "").toUpperCase());
                if (parsedXMaterial == null) {
                    description.append(WordUtils.capitalizeFully(materialTag.getValue().replace("_", " ").toLowerCase())).append("\n");
                } else {
                    description.append(LanguageUtils.getTranslation(LanguageUtils.getTranslationKey(parsedXMaterial.parseItem()), language)).append("\n");
                }
            }
        }
    }
    if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_12) && hasMeta && !item.getItemMeta().hasItemFlag(ItemFlag.HIDE_PLACED_ON)) {
        if (NBTEditor.contains(item, "CanPlaceOn") && NBTEditor.getSize(item, "CanPlaceOn") > 0) {
            description.append("\n");
            description.append(LanguageUtils.getTranslation(TranslationKeyUtils.getCanPlace(), language)).append("\n");
            ListTag<StringTag> materialList = (ListTag<StringTag>) new SNBTDeserializer().fromString(NBTEditor.getNBTCompound(item, "tag", "CanPlaceOn").toJson());
            for (StringTag materialTag : materialList) {
                XMaterial parsedXMaterial = XMaterialUtils.matchXMaterial(materialTag.getValue().replace("minecraft:", "").toUpperCase());
                if (parsedXMaterial == null) {
                    description.append(WordUtils.capitalizeFully(materialTag.getValue().replace("_", " ").toLowerCase())).append("\n");
                } else {
                    description.append(LanguageUtils.getTranslation(LanguageUtils.getTranslationKey(parsedXMaterial.parseItem()), language)).append("\n");
                }
            }
        }
    }
    if (item.getType().getMaxDurability() > 0) {
        int durability = item.getType().getMaxDurability() - (InteractiveChat.version.isLegacy() ? item.getDurability() : ((Damageable) item.getItemMeta()).getDamage());
        int maxDur = item.getType().getMaxDurability();
        if (durability < maxDur) {
            if (!description.toString().equals("")) {
                description.append("\n");
            }
            description.append("**").append(LanguageUtils.getTranslation(TranslationKeyUtils.getDurability(), language).replaceFirst("%s", String.valueOf(durability)).replaceFirst("%s", String.valueOf(maxDur))).append("**\n");
        }
    }
    return new DiscordDescription(name, description.toString().trim().isEmpty() ? null : description.toString());
}
Also used : ItemFlag(org.bukkit.inventory.ItemFlag) Color(java.awt.Color) Arrays(java.util.Arrays) Enchantment(org.bukkit.enchantments.Enchantment) Player(org.bukkit.entity.Player) InteractiveChatComponentSerializer(com.loohp.interactivechat.utils.InteractiveChatComponentSerializer) SNBTDeserializer(com.loohp.interactivechat.libs.net.querz.nbt.io.SNBTDeserializer) Method(java.lang.reflect.Method) XMaterial(com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) Bukkit(org.bukkit.Bukkit) MapMeta(org.bukkit.inventory.meta.MapMeta) XMaterialUtils(com.loohp.interactivechat.utils.XMaterialUtils) PatternTypeWrapper(com.loohp.interactivechatdiscordsrvaddon.wrappers.PatternTypeWrapper) Collectors(java.util.stream.Collectors) ItemStack(org.bukkit.inventory.ItemStack) InteractiveChat(com.loohp.interactivechat.InteractiveChat) DiscordSerializer(github.scarsz.discordsrv.dependencies.mcdiscordreserializer.discord.DiscordSerializer) Damageable(org.bukkit.inventory.meta.Damageable) List(java.util.List) CompoundTag(com.loohp.interactivechat.libs.net.querz.nbt.tag.CompoundTag) ListTag(com.loohp.interactivechat.libs.net.querz.nbt.tag.ListTag) Stream(java.util.stream.Stream) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) Entry(java.util.Map.Entry) Optional(java.util.Optional) NBTEditor(com.loohp.interactivechat.libs.io.github.bananapuncher714.nbteditor.NBTEditor) CrossbowMeta(org.bukkit.inventory.meta.CrossbowMeta) EnchantmentStorageMeta(org.bukkit.inventory.meta.EnchantmentStorageMeta) FilledMapUtils(com.loohp.interactivechat.utils.FilledMapUtils) MCVersion(com.loohp.interactivechat.utils.MCVersion) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) StringTag(com.loohp.interactivechat.libs.net.querz.nbt.tag.StringTag) BannerMeta(org.bukkit.inventory.meta.BannerMeta) Generation(org.bukkit.inventory.meta.BookMeta.Generation) InteractiveChatDiscordSrvAddon(com.loohp.interactivechatdiscordsrvaddon.InteractiveChatDiscordSrvAddon) ArrayList(java.util.ArrayList) PlainTextComponentSerializer(com.loohp.interactivechat.libs.net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer) DiscordSRV(github.scarsz.discordsrv.DiscordSRV) Banner(org.bukkit.block.Banner) WordUtils(com.loohp.interactivechat.libs.org.apache.commons.text.WordUtils) LanguageUtils(com.loohp.interactivechat.utils.LanguageUtils) PotionMeta(org.bukkit.inventory.meta.PotionMeta) MapView(org.bukkit.map.MapView) LinkedList(java.util.LinkedList) ItemStackUtils(com.loohp.interactivechat.utils.ItemStackUtils) ChatColor(net.md_5.bungee.api.ChatColor) ColorUtils(com.loohp.interactivechat.utils.ColorUtils) Component(com.loohp.interactivechat.libs.net.kyori.adventure.text.Component) DecimalFormat(java.text.DecimalFormat) RarityUtils(com.loohp.interactivechat.utils.RarityUtils) EcoHook(com.loohp.interactivechat.hooks.ecoenchants.EcoHook) PotionEffect(org.bukkit.potion.PotionEffect) DiscordDataRegistry(com.loohp.interactivechatdiscordsrvaddon.registry.DiscordDataRegistry) ChronoUnit(java.time.temporal.ChronoUnit) ChatColorUtils(com.loohp.interactivechat.utils.ChatColorUtils) Collections(java.util.Collections) LegacyComponentSerializer(com.loohp.interactivechat.libs.net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer) StringTag(com.loohp.interactivechat.libs.net.querz.nbt.tag.StringTag) PotionEffect(org.bukkit.potion.PotionEffect) ArrayList(java.util.ArrayList) MapView(org.bukkit.map.MapView) CrossbowMeta(org.bukkit.inventory.meta.CrossbowMeta) ItemMeta(org.bukkit.inventory.meta.ItemMeta) CompoundTag(com.loohp.interactivechat.libs.net.querz.nbt.tag.CompoundTag) Pattern(org.bukkit.block.banner.Pattern) BannerMeta(org.bukkit.inventory.meta.BannerMeta) Banner(org.bukkit.block.Banner) Color(java.awt.Color) ChatColor(net.md_5.bungee.api.ChatColor) PatternTypeWrapper(com.loohp.interactivechatdiscordsrvaddon.wrappers.PatternTypeWrapper) PotionMeta(org.bukkit.inventory.meta.PotionMeta) XMaterial(com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial) ListTag(com.loohp.interactivechat.libs.net.querz.nbt.tag.ListTag) LinkedList(java.util.LinkedList) BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) Generation(org.bukkit.inventory.meta.BookMeta.Generation) EnchantmentStorageMeta(org.bukkit.inventory.meta.EnchantmentStorageMeta) MapMeta(org.bukkit.inventory.meta.MapMeta) SNBTDeserializer(com.loohp.interactivechat.libs.net.querz.nbt.io.SNBTDeserializer) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemStack(org.bukkit.inventory.ItemStack) Enchantment(org.bukkit.enchantments.Enchantment) BookMeta(org.bukkit.inventory.meta.BookMeta)

Aggregations

XMaterial (com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial)2 Component (com.loohp.interactivechat.libs.net.kyori.adventure.text.Component)2 SNBTDeserializer (com.loohp.interactivechat.libs.net.querz.nbt.io.SNBTDeserializer)2 CompoundTag (com.loohp.interactivechat.libs.net.querz.nbt.tag.CompoundTag)2 ListTag (com.loohp.interactivechat.libs.net.querz.nbt.tag.ListTag)2 StringTag (com.loohp.interactivechat.libs.net.querz.nbt.tag.StringTag)2 PatternTypeWrapper (com.loohp.interactivechatdiscordsrvaddon.wrappers.PatternTypeWrapper)2 Color (java.awt.Color)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 ChatColor (net.md_5.bungee.api.ChatColor)2 Generation (org.bukkit.inventory.meta.BookMeta.Generation)2 InteractiveChat (com.loohp.interactivechat.InteractiveChat)1 EcoHook (com.loohp.interactivechat.hooks.ecoenchants.EcoHook)1 NBTEditor (com.loohp.interactivechat.libs.io.github.bananapuncher714.nbteditor.NBTEditor)1 LegacyComponentSerializer (com.loohp.interactivechat.libs.net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer)1 PlainTextComponentSerializer (com.loohp.interactivechat.libs.net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer)1 WordUtils (com.loohp.interactivechat.libs.org.apache.commons.text.WordUtils)1 ChatColorUtils (com.loohp.interactivechat.utils.ChatColorUtils)1 ColorUtils (com.loohp.interactivechat.utils.ColorUtils)1