Search in sources :

Example 1 with XMaterial

use of com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial 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 XMaterial

use of com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial in project InteractiveChat-DiscordSRV-Addon by LOOHP.

the class ImageGeneration method getRawItemImage.

private static BufferedImage getRawItemImage(ItemStack item, OfflineICPlayer player) throws IOException {
    InteractiveChatDiscordSrvAddon.plugin.imageCounter.incrementAndGet();
    Debug.debug("ImageGeneration creating raw item stack image " + (item == null ? "null" : ItemNBTUtils.getNMSItemStackJson(item)));
    XMaterial xMaterial = XMaterialUtils.matchXMaterial(item);
    int amount = item.getAmount();
    String key = ModelUtils.getItemModelKey(xMaterial);
    ItemStackProcessResult processResult = ItemRenderUtils.processItemForRendering(player, item);
    boolean requiresEnchantmentGlint = processResult.requiresEnchantmentGlint();
    Map<ModelOverrideType, Float> predicates = processResult.getPredicates();
    Map<String, TextureResource> providedTextures = processResult.getProvidedTextures();
    TintIndexData tintIndexData = processResult.getTintIndexData();
    String directLocation = processResult.getDirectLocation();
    BufferedImage itemImage;
    RenderResult renderResult = InteractiveChatDiscordSrvAddon.plugin.modelRenderer.render(32, 32, resourceManager.get(), version.get().isOld(), directLocation == null ? ResourceRegistry.ITEM_MODEL_LOCATION + key : directLocation, ModelDisplayPosition.GUI, predicates, providedTextures, tintIndexData, requiresEnchantmentGlint);
    if (renderResult.isSuccessful()) {
        itemImage = renderResult.getImage();
    } else {
        Debug.debug("ImageGeneration creating missing Image for material " + xMaterial);
        itemImage = TextureManager.getMissingImage(32, 32);
    }
    if (item.getType().getMaxDurability() > 0) {
        int durability = item.getType().getMaxDurability() - (version.get().isLegacy() ? item.getDurability() : ((Damageable) item.getItemMeta()).getDamage());
        int maxDur = item.getType().getMaxDurability();
        double percentage = ((double) durability / (double) maxDur);
        if (percentage < 1) {
            int hue = (int) (125 * percentage);
            int length = (int) (26 * percentage);
            Color color = Color.getHSBColor((float) hue / 360, 1, 1);
            Graphics2D g4 = itemImage.createGraphics();
            g4.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
            g4.setColor(Color.BLACK);
            g4.fillPolygon(new int[] { 4, 30, 30, 4 }, new int[] { 26, 26, 30, 30 }, 4);
            g4.setColor(color);
            g4.fillPolygon(new int[] { 4, 4 + length, 4 + length, 4 }, new int[] { 26, 26, 28, 28 }, 4);
            g4.dispose();
        }
    }
    if (amount != 1) {
        BufferedImage newItemImage = new BufferedImage(40, 40, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g4 = newItemImage.createGraphics();
        g4.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
        g4.drawImage(itemImage, 0, 0, null);
        Component component = Component.text(amount);
        if (amount <= 0) {
            component = component.color(NamedTextColor.RED);
        }
        newItemImage = ImageUtils.printComponentRightAligned(resourceManager.get(), newItemImage, component, InteractiveChatDiscordSrvAddon.plugin.language, version.get().isLegacyRGB(), 33, 17, 16, ITEM_AMOUNT_TEXT_DARKEN_FACTOR);
        g4.dispose();
        itemImage = newItemImage;
    }
    return itemImage;
}
Also used : TextureResource(com.loohp.interactivechatdiscordsrvaddon.resources.textures.TextureResource) GeneratedTextureResource(com.loohp.interactivechatdiscordsrvaddon.resources.textures.GeneratedTextureResource) ItemStackProcessResult(com.loohp.interactivechatdiscordsrvaddon.utils.ItemRenderUtils.ItemStackProcessResult) Color(java.awt.Color) TextColor(com.loohp.interactivechat.libs.net.kyori.adventure.text.format.TextColor) NamedTextColor(com.loohp.interactivechat.libs.net.kyori.adventure.text.format.NamedTextColor) RenderResult(com.loohp.interactivechatdiscordsrvaddon.resources.ModelRenderer.RenderResult) XMaterial(com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial) TintIndexData(com.loohp.interactivechatdiscordsrvaddon.utils.TintUtils.TintIndexData) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) ModelOverrideType(com.loohp.interactivechatdiscordsrvaddon.resources.models.ModelOverride.ModelOverrideType) Component(com.loohp.interactivechat.libs.net.kyori.adventure.text.Component)

Example 3 with XMaterial

use of com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial in project InteractiveChat-DiscordSRV-Addon by LOOHP.

the class ImageGeneration method getFullBodyImage.

private static BufferedImage getFullBodyImage(OfflineICPlayer player, ItemStack helmet, ItemStack chestplate, ItemStack leggings, ItemStack boots) throws IOException {
    InteractiveChatDiscordSrvAddon.plugin.imageCounter.incrementAndGet();
    Debug.debug("ImageGeneration creating puppet image of " + player.getName());
    BufferedImage skin = null;
    boolean slim = false;
    BufferedImage cape;
    try {
        JSONObject json;
        ICPlayer icPlayer = player.getPlayer();
        if (icPlayer != null && icPlayer.isLocal()) {
            json = (JSONObject) new JSONParser().parse(SkinUtils.getSkinJsonFromProfile(((ICPlayer) player).getLocalPlayer()));
        } else {
            json = (JSONObject) new JSONParser().parse(new String(Base64.getDecoder().decode(((JSONObject) ((JSONArray) HTTPRequestUtils.getJSONResponse(PLAYER_INFO_URL.replace("%s", player.getUniqueId().toString())).get("properties")).get(0)).get("value").toString())));
        }
        if (json == null) {
            cape = null;
        } else {
            try {
                if (((JSONObject) json.get("textures")).containsKey("CAPE")) {
                    String url = (String) ((JSONObject) ((JSONObject) json.get("textures")).get("CAPE")).get("url");
                    Cache<?> cache = Cache.getCache(player.getUniqueId().toString() + url + PLAYER_CAPE_CACHE_KEY);
                    if (cache == null) {
                        cape = ImageUtils.downloadImage(url);
                        Cache.putCache(player.getUniqueId().toString() + url + PLAYER_CAPE_CACHE_KEY, cape, InteractiveChatDiscordSrvAddon.plugin.cacheTimeout);
                    } else {
                        cape = (BufferedImage) cache.getObject();
                    }
                } else {
                    String url = OPTIFINE_CAPE_URL.replaceAll("%s", CustomStringUtils.escapeReplaceAllMetaCharacters(player.getName()));
                    Cache<?> cache = Cache.getCache(player.getUniqueId().toString() + url + PLAYER_CAPE_CACHE_KEY);
                    if (cache == null) {
                        try {
                            cape = ImageUtils.downloadImage(url);
                            Cache.putCache(player.getUniqueId().toString() + url + PLAYER_CAPE_CACHE_KEY, cape, InteractiveChatDiscordSrvAddon.plugin.cacheTimeout);
                        } catch (Throwable ignore) {
                            cape = null;
                        }
                    } else {
                        cape = (BufferedImage) cache.getObject();
                    }
                }
            } catch (Throwable e) {
                cape = null;
            }
            try {
                String value = (String) ((JSONObject) ((JSONObject) json.get("textures")).get("SKIN")).get("url");
                if (((JSONObject) ((JSONObject) json.get("textures")).get("SKIN")).containsKey("metadata")) {
                    slim = ((JSONObject) ((JSONObject) ((JSONObject) json.get("textures")).get("SKIN")).get("metadata")).get("model").toString().equals("slim");
                }
                Cache<?> cache = Cache.getCache(player.getUniqueId().toString() + value + PLAYER_SKIN_CACHE_KEY);
                if (cache == null) {
                    skin = ImageUtils.downloadImage(value);
                    Cache.putCache(player.getUniqueId().toString() + value + PLAYER_SKIN_CACHE_KEY, skin, InteractiveChatDiscordSrvAddon.plugin.cacheTimeout);
                } else {
                    skin = (BufferedImage) cache.getObject();
                }
                skin = ImageUtils.copyImage(skin);
            } catch (Throwable e1) {
            }
        }
    } catch (Exception e) {
        cape = null;
    }
    if (skin == null) {
        if (slim) {
            skin = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ENTITY_TEXTURE_LOCATION + "alex").getTexture();
        } else {
            skin = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ENTITY_TEXTURE_LOCATION + "steve").getTexture();
        }
    }
    BufferedImage elytraImage = null;
    BufferedImage image = new BufferedImage(556, 748, BufferedImage.TYPE_INT_ARGB);
    Map<String, TextureResource> providedTextures = new HashMap<>();
    Map<PlayerModelItemPosition, PlayerModelItem> modelItems = new HashMap<>();
    providedTextures.put(ResourceRegistry.SKIN_FULL_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(ModelUtils.convertToModernSkinTexture(skin)));
    if (ItemStackUtils.isWearable(leggings)) {
        XMaterial type = XMaterialUtils.matchXMaterial(leggings);
        BufferedImage leggingsImage = null;
        switch(type) {
            case LEATHER_LEGGINGS:
                leggingsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "leather_layer_2").getTexture();
                LeatherArmorMeta meta = (LeatherArmorMeta) leggings.getItemMeta();
                Color color = new Color(meta.getColor().asRGB());
                BufferedImage armorOverlay = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "leather_layer_2_overlay").getTexture();
                BufferedImage colorOverlay = ImageUtils.changeColorTo(ImageUtils.copyImage(leggingsImage), color);
                leggingsImage = ImageUtils.multiply(leggingsImage, colorOverlay);
                Graphics2D g2 = leggingsImage.createGraphics();
                g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
                g2.drawImage(armorOverlay, 0, 0, null);
                g2.dispose();
                break;
            case CHAINMAIL_LEGGINGS:
                leggingsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "chainmail_layer_2").getTexture();
                break;
            case GOLDEN_LEGGINGS:
                leggingsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "gold_layer_2").getTexture();
                break;
            case IRON_LEGGINGS:
                leggingsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "iron_layer_2").getTexture();
                break;
            case DIAMOND_LEGGINGS:
                leggingsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "diamond_layer_2").getTexture();
                break;
            case NETHERITE_LEGGINGS:
                leggingsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "netherite_layer_2").getTexture();
                break;
            default:
                break;
        }
        if (leggingsImage != null) {
            if (leggings.getEnchantments().size() > 0) {
                leggingsImage = getEnchantedImage(leggingsImage);
            }
            providedTextures.put(ResourceRegistry.LEGGINGS_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(leggingsImage));
        }
    }
    if (ItemStackUtils.isWearable(boots)) {
        XMaterial type = XMaterialUtils.matchXMaterial(boots);
        BufferedImage bootsImage = null;
        switch(type) {
            case LEATHER_BOOTS:
                bootsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "leather_layer_1").getTexture();
                LeatherArmorMeta meta = (LeatherArmorMeta) boots.getItemMeta();
                Color color = new Color(meta.getColor().asRGB());
                BufferedImage armorOverlay = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "leather_layer_1_overlay").getTexture();
                BufferedImage colorOverlay = ImageUtils.changeColorTo(ImageUtils.copyImage(bootsImage), color);
                bootsImage = ImageUtils.multiply(bootsImage, colorOverlay);
                Graphics2D g2 = bootsImage.createGraphics();
                g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
                g2.drawImage(armorOverlay, 0, 0, null);
                g2.dispose();
                break;
            case CHAINMAIL_BOOTS:
                bootsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "chainmail_layer_1").getTexture();
                break;
            case GOLDEN_BOOTS:
                bootsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "gold_layer_1").getTexture();
                break;
            case IRON_BOOTS:
                bootsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "iron_layer_1").getTexture();
                break;
            case DIAMOND_BOOTS:
                bootsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "diamond_layer_1").getTexture();
                break;
            case NETHERITE_BOOTS:
                bootsImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "netherite_layer_1").getTexture();
                break;
            default:
                break;
        }
        if (bootsImage != null) {
            if (boots.getEnchantments().size() > 0) {
                bootsImage = getEnchantedImage(bootsImage);
            }
            providedTextures.put(ResourceRegistry.BOOTS_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(bootsImage));
        }
    }
    if (ItemStackUtils.isWearable(chestplate)) {
        XMaterial type = XMaterialUtils.matchXMaterial(chestplate);
        BufferedImage chestplateImage = null;
        boolean isArmor = true;
        switch(type) {
            case LEATHER_CHESTPLATE:
                chestplateImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "leather_layer_1").getTexture();
                LeatherArmorMeta meta = (LeatherArmorMeta) chestplate.getItemMeta();
                Color color = new Color(meta.getColor().asRGB());
                BufferedImage armorOverlay = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "leather_layer_1_overlay").getTexture();
                BufferedImage colorOverlay = ImageUtils.changeColorTo(ImageUtils.copyImage(chestplateImage), color);
                chestplateImage = ImageUtils.multiply(chestplateImage, colorOverlay);
                Graphics2D g2 = chestplateImage.createGraphics();
                g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
                g2.drawImage(armorOverlay, 0, 0, null);
                g2.dispose();
                break;
            case CHAINMAIL_CHESTPLATE:
                chestplateImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "chainmail_layer_1").getTexture();
                break;
            case GOLDEN_CHESTPLATE:
                chestplateImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "gold_layer_1").getTexture();
                break;
            case IRON_CHESTPLATE:
                chestplateImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "iron_layer_1").getTexture();
                break;
            case DIAMOND_CHESTPLATE:
                chestplateImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "diamond_layer_1").getTexture();
                break;
            case NETHERITE_CHESTPLATE:
                chestplateImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "netherite_layer_1").getTexture();
                break;
            case ELYTRA:
                isArmor = false;
                chestplateImage = new BufferedImage(150, 150, BufferedImage.TYPE_INT_ARGB);
                BufferedImage wing = cape == null ? resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ENTITY_TEXTURE_LOCATION + "elytra").getTexture() : cape;
                if (wing.getWidth() % 64 != 0 || wing.getHeight() % 32 != 0) {
                    int w = 0;
                    int h = 0;
                    while (w < wing.getWidth()) {
                        w += 64;
                        h += 32;
                    }
                    BufferedImage resize = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                    Graphics2D g3 = resize.createGraphics();
                    g3.drawImage(wing, 0, 0, null);
                    g3.dispose();
                    wing = resize;
                }
                int scale = wing.getWidth() / 64;
                wing = ImageUtils.copyAndGetSubImage(wing, 34 * scale, 2 * scale, 12 * scale, 20 * scale);
                wing = ImageUtils.multiply(ImageUtils.resizeImage(wing, Math.pow(scale, -1) * 3.75), 0.7);
                BufferedImage leftWing = ImageUtils.rotateImageByDegrees(wing, 23.41);
                Graphics2D g3 = chestplateImage.createGraphics();
                g3.drawImage(leftWing, 0, 0, null);
                wing = ImageUtils.flipHorizontal(wing);
                BufferedImage rightWing = ImageUtils.rotateImageByDegrees(wing, 360.0 - 23.41);
                g3.drawImage(rightWing, 26, 0, null);
                g3.dispose();
                if (chestplate.getEnchantments().size() > 0) {
                    chestplateImage = getEnchantedImage(chestplateImage);
                }
                elytraImage = chestplateImage;
            default:
                break;
        }
        if (isArmor && chestplateImage != null) {
            if (chestplate.getEnchantments().size() > 0) {
                chestplateImage = getEnchantedImage(chestplateImage);
            }
            providedTextures.put(ResourceRegistry.CHESTPLATE_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(chestplateImage));
        }
    }
    if (helmet != null && !helmet.getType().equals(Material.AIR)) {
        XMaterial type = XMaterialUtils.matchXMaterial(helmet);
        BufferedImage helmetImage = null;
        boolean isArmor = true;
        switch(type) {
            case LEATHER_HELMET:
                helmetImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "leather_layer_1").getTexture();
                LeatherArmorMeta meta = (LeatherArmorMeta) helmet.getItemMeta();
                Color color = new Color(meta.getColor().asRGB());
                BufferedImage armorOverlay = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "leather_layer_1_overlay").getTexture();
                BufferedImage colorOverlay = ImageUtils.changeColorTo(ImageUtils.copyImage(helmetImage), color);
                helmetImage = ImageUtils.multiply(helmetImage, colorOverlay);
                Graphics2D g2 = helmetImage.createGraphics();
                g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
                g2.drawImage(armorOverlay, 0, 0, null);
                g2.dispose();
                break;
            case CHAINMAIL_HELMET:
                helmetImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "chainmail_layer_1").getTexture();
                break;
            case GOLDEN_HELMET:
                helmetImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "gold_layer_1").getTexture();
                break;
            case IRON_HELMET:
                helmetImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "iron_layer_1").getTexture();
                break;
            case DIAMOND_HELMET:
                helmetImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "diamond_layer_1").getTexture();
                break;
            case NETHERITE_HELMET:
                helmetImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "netherite_layer_1").getTexture();
                break;
            case TURTLE_HELMET:
                helmetImage = resourceManager.get().getTextureManager().getTexture(ResourceRegistry.ARMOR_TEXTURE_LOCATION + "turtle_layer_1").getTexture();
                break;
            default:
                isArmor = false;
                String key = ModelUtils.getItemModelKey(type);
                ItemStackProcessResult itemProcessResult = ItemRenderUtils.processItemForRendering(player, helmet);
                boolean enchanted = itemProcessResult.requiresEnchantmentGlint();
                Map<ModelOverrideType, Float> predicate = itemProcessResult.getPredicates();
                String modelKey = itemProcessResult.getDirectLocation() == null ? ResourceRegistry.ITEM_MODEL_LOCATION + key : itemProcessResult.getDirectLocation();
                Map<String, TextureResource> itemProvidedTextures = itemProcessResult.getProvidedTextures();
                TintIndexData tintIndexData = itemProcessResult.getTintIndexData();
                modelItems.put(PlayerModelItemPosition.HELMET, new PlayerModelItem(PlayerModelItemPosition.HELMET, modelKey, predicate, enchanted, itemProvidedTextures, tintIndexData));
                break;
        }
        if (isArmor) {
            if (helmet.getEnchantments().size() > 0) {
                helmetImage = getEnchantedImage(helmetImage);
            }
            providedTextures.put(ResourceRegistry.HELMET_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(helmetImage));
        }
    }
    if (InteractiveChatDiscordSrvAddon.plugin.renderHandHeldItems) {
        ItemStack rightHand = player.isRightHanded() ? player.getMainHandItem() : player.getOffHandItem();
        if (rightHand != null) {
            String key = ModelUtils.getItemModelKey(XMaterialUtils.matchXMaterial(rightHand));
            ItemStackProcessResult itemProcessResult = ItemRenderUtils.processItemForRendering(player, rightHand);
            boolean enchanted = itemProcessResult.requiresEnchantmentGlint();
            Map<ModelOverrideType, Float> predicate = itemProcessResult.getPredicates();
            String modelKey = itemProcessResult.getDirectLocation() == null ? ResourceRegistry.ITEM_MODEL_LOCATION + key : itemProcessResult.getDirectLocation();
            Map<String, TextureResource> itemProvidedTextures = itemProcessResult.getProvidedTextures();
            TintIndexData tintIndexData = itemProcessResult.getTintIndexData();
            modelItems.put(PlayerModelItemPosition.RIGHT_HAND, new PlayerModelItem(PlayerModelItemPosition.RIGHT_HAND, modelKey, predicate, enchanted, itemProvidedTextures, tintIndexData));
        }
        ItemStack leftHand = player.isRightHanded() ? player.getOffHandItem() : player.getMainHandItem();
        if (leftHand != null) {
            String key = ModelUtils.getItemModelKey(XMaterialUtils.matchXMaterial(leftHand));
            ItemStackProcessResult itemProcessResult = ItemRenderUtils.processItemForRendering(player, leftHand);
            boolean enchanted = itemProcessResult.requiresEnchantmentGlint();
            Map<ModelOverrideType, Float> predicate = itemProcessResult.getPredicates();
            String modelKey = itemProcessResult.getDirectLocation() == null ? ResourceRegistry.ITEM_MODEL_LOCATION + key : itemProcessResult.getDirectLocation();
            Map<String, TextureResource> itemProvidedTextures = itemProcessResult.getProvidedTextures();
            TintIndexData tintIndexData = itemProcessResult.getTintIndexData();
            modelItems.put(PlayerModelItemPosition.LEFT_HAND, new PlayerModelItem(PlayerModelItemPosition.LEFT_HAND, modelKey, predicate, enchanted, itemProvidedTextures, tintIndexData));
        }
    }
    boolean upsideDown = ModelUtils.isRenderedUpsideDown(player.getName(), cape != null);
    RenderResult renderResult = InteractiveChatDiscordSrvAddon.plugin.modelRenderer.renderPlayer(image.getWidth(), image.getHeight(), resourceManager.get(), version.get().isOld(), slim, providedTextures, TintIndexData.EMPTY_INSTANCE, modelItems);
    Graphics2D g = image.createGraphics();
    BufferedImage resizedImage = ImageUtils.resizeImageAbs(renderResult.getImage(), 117, 159);
    if (upsideDown) {
        resizedImage = ImageUtils.rotateImageByDegrees(resizedImage, 180);
    }
    g.drawImage(resizedImage, -1, 12, null);
    g.dispose();
    if (elytraImage != null) {
        BufferedImage resizedElytraImage = ImageUtils.resizeImage(elytraImage, 0.9);
        if (upsideDown) {
            resizedElytraImage = ImageUtils.rotateImageByDegrees(resizedElytraImage, 180);
        }
        ImageUtils.drawTransparent(image, resizedElytraImage, 14, 75);
    }
    return image;
}
Also used : TextureResource(com.loohp.interactivechatdiscordsrvaddon.resources.textures.TextureResource) GeneratedTextureResource(com.loohp.interactivechatdiscordsrvaddon.resources.textures.GeneratedTextureResource) ICPlayer(com.loohp.interactivechat.objectholders.ICPlayer) OfflineICPlayer(com.loohp.interactivechat.objectholders.OfflineICPlayer) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ItemStackProcessResult(com.loohp.interactivechatdiscordsrvaddon.utils.ItemRenderUtils.ItemStackProcessResult) RenderResult(com.loohp.interactivechatdiscordsrvaddon.resources.ModelRenderer.RenderResult) BufferedImage(java.awt.image.BufferedImage) PlayerModelItemPosition(com.loohp.interactivechatdiscordsrvaddon.resources.ModelRenderer.PlayerModelItemPosition) PlayerModelItem(com.loohp.interactivechatdiscordsrvaddon.resources.ModelRenderer.PlayerModelItem) ModelOverrideType(com.loohp.interactivechatdiscordsrvaddon.resources.models.ModelOverride.ModelOverrideType) Color(java.awt.Color) TextColor(com.loohp.interactivechat.libs.net.kyori.adventure.text.format.TextColor) NamedTextColor(com.loohp.interactivechat.libs.net.kyori.adventure.text.format.NamedTextColor) GeneratedTextureResource(com.loohp.interactivechatdiscordsrvaddon.resources.textures.GeneratedTextureResource) XMaterial(com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial) IOException(java.io.IOException) TintIndexData(com.loohp.interactivechatdiscordsrvaddon.utils.TintUtils.TintIndexData) Graphics2D(java.awt.Graphics2D) JSONObject(com.loohp.interactivechat.libs.org.json.simple.JSONObject) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) JSONParser(com.loohp.interactivechat.libs.org.json.simple.parser.JSONParser) ItemStack(org.bukkit.inventory.ItemStack)

Example 4 with XMaterial

use of com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial in project InteractiveChat-DiscordSRV-Addon by LOOHP.

the class BannerGraphics method generateBannerAssets.

public static BannerAssetResult generateBannerAssets(ItemStack item) {
    BufferedImage baseImage = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.ENTITY_TEXTURE_LOCATION + "banner_base").getTexture(64, 64);
    BufferedImage patternsImage = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB);
    XMaterial xMaterial = XMaterialUtils.matchXMaterial(item);
    String colorName = xMaterial.name().replace("_BANNER", "");
    Color baseColor = new Color(DyeColor.valueOf(colorName.toUpperCase()).getColor().asRGB());
    BufferedImage baseTint = new BufferedImage(42, 41, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = baseTint.createGraphics();
    g.setColor(baseColor);
    g.fillRect(0, 0, 42, 41);
    g.dispose();
    baseImage = ImageUtils.add(ImageUtils.multiply(baseImage, baseTint), 40);
    if (!item.hasItemMeta()) {
        return new BannerAssetResult(baseImage, patternsImage);
    }
    List<Pattern> patterns;
    if (!(item.getItemMeta() instanceof BannerMeta)) {
        if (!(item.getItemMeta() instanceof BlockStateMeta)) {
            return new BannerAssetResult(baseImage, patternsImage);
        }
        BlockStateMeta bmeta = (BlockStateMeta) item.getItemMeta();
        Banner bannerBlockMeta = (Banner) bmeta.getBlockState();
        patterns = bannerBlockMeta.getPatterns();
    } else {
        BannerMeta meta = (BannerMeta) item.getItemMeta();
        patterns = meta.getPatterns();
    }
    Graphics2D g2 = patternsImage.createGraphics();
    for (Pattern pattern : patterns) {
        PatternTypeWrapper type = PatternTypeWrapper.fromPatternType(pattern.getPattern());
        Color color = new Color(pattern.getColor().getColor().asRGB());
        BufferedImage image = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.BANNER_TEXTURE_LOCATION + type.getAssetName()).getTexture(64, 64);
        BufferedImage tint = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g3 = tint.createGraphics();
        g3.setColor(color);
        g3.fillRect(0, 0, 64, 64);
        g3.dispose();
        image = ImageUtils.add(ImageUtils.multiply(image, tint), 40);
        g2.drawImage(image, 0, 0, null);
    }
    g2.dispose();
    return new BannerAssetResult(baseImage, patternsImage);
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) Pattern(org.bukkit.block.banner.Pattern) BannerMeta(org.bukkit.inventory.meta.BannerMeta) Banner(org.bukkit.block.Banner) Color(java.awt.Color) DyeColor(org.bukkit.DyeColor) PatternTypeWrapper(com.loohp.interactivechatdiscordsrvaddon.wrappers.PatternTypeWrapper) XMaterial(com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 5 with XMaterial

use of com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial in project InteractiveChat-DiscordSRV-Addon by LOOHP.

the class ItemRenderUtils method processItemForRendering.

public static ItemStackProcessResult processItemForRendering(OfflineICPlayer player, ItemStack item) throws IOException {
    boolean requiresEnchantmentGlint = false;
    XMaterial xMaterial = XMaterialUtils.matchXMaterial(item);
    String directLocation = null;
    if (xMaterial.equals(XMaterial.DEBUG_STICK)) {
        requiresEnchantmentGlint = true;
    } else if (xMaterial.equals(XMaterial.ENCHANTED_GOLDEN_APPLE)) {
        requiresEnchantmentGlint = true;
    } else if (xMaterial.equals(XMaterial.WRITTEN_BOOK)) {
        requiresEnchantmentGlint = true;
    } else if (xMaterial.equals(XMaterial.ENCHANTED_BOOK)) {
        requiresEnchantmentGlint = true;
    } else if (item.getEnchantments().size() > 0) {
        requiresEnchantmentGlint = true;
    }
    TintIndexData tintIndexData = TintUtils.getTintData(xMaterial);
    Map<ModelOverrideType, Float> predicates = new EnumMap<>(ModelOverrideType.class);
    Map<String, TextureResource> providedTextures = new HashMap<>();
    if (NBTEditor.contains(item, "CustomModelData")) {
        int customModelData = NBTEditor.getInt(item, "CustomModelData");
        predicates.put(ModelOverrideType.CUSTOM_MODEL_DATA, (float) customModelData);
    }
    if (xMaterial.equals(XMaterial.CHEST) || xMaterial.equals(XMaterial.TRAPPED_CHEST)) {
        LocalDate time = LocalDate.now();
        if (time.getMonth().equals(Month.DECEMBER) && (time.getDayOfMonth() == 24 || time.getDayOfMonth() == 25 || time.getDayOfMonth() == 26)) {
            directLocation = ResourceRegistry.BUILTIN_ENTITY_MODEL_LOCATION + "christmas_chest";
        }
    } else if (xMaterial.isOneOf(Arrays.asList("CONTAINS:banner"))) {
        BannerAssetResult bannerAsset = BannerGraphics.generateBannerAssets(item);
        providedTextures.put(ResourceRegistry.BANNER_BASE_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(bannerAsset.getBase()));
        providedTextures.put(ResourceRegistry.BANNER_PATTERNS_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(bannerAsset.getPatterns()));
    } else if (xMaterial.equals(XMaterial.SHIELD)) {
        BannerAssetResult shieldAsset = BannerGraphics.generateShieldAssets(item);
        providedTextures.put(ResourceRegistry.SHIELD_BASE_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(shieldAsset.getBase()));
        providedTextures.put(ResourceRegistry.SHIELD_PATTERNS_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(shieldAsset.getPatterns()));
    } else if (xMaterial.equals(XMaterial.PLAYER_HEAD)) {
        BufferedImage skinImage = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.ENTITY_TEXTURE_LOCATION + "steve").getTexture();
        try {
            String base64 = SkinUtils.getSkinValue(item.getItemMeta());
            if (base64 != null) {
                JSONObject json = (JSONObject) new JSONParser().parse(new String(Base64.getDecoder().decode(base64)));
                String value = (String) ((JSONObject) ((JSONObject) json.get("textures")).get("SKIN")).get("url");
                skinImage = ImageUtils.downloadImage(value);
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        providedTextures.put(ResourceRegistry.SKIN_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(ModelUtils.convertToModernSkinTexture(skinImage)));
    } else if (xMaterial.equals(XMaterial.ELYTRA)) {
        int durability = item.getType().getMaxDurability() - (InteractiveChat.version.isLegacy() ? item.getDurability() : ((Damageable) item.getItemMeta()).getDamage());
        if (durability <= 1) {
            predicates.put(ModelOverrideType.BROKEN, 1F);
        }
    } else if (xMaterial.equals(XMaterial.CROSSBOW)) {
        CrossbowMeta meta = (CrossbowMeta) item.getItemMeta();
        List<ItemStack> charged = meta.getChargedProjectiles();
        if (charged != null && !charged.isEmpty()) {
            predicates.put(ModelOverrideType.CHARGED, 1F);
            ItemStack charge = charged.get(0);
            XMaterial chargeType = XMaterialUtils.matchXMaterial(charge);
            if (chargeType.equals(XMaterial.FIREWORK_ROCKET)) {
                predicates.put(ModelOverrideType.FIREWORK, 1F);
            }
        }
    } else if (xMaterial.equals(XMaterial.CLOCK)) {
        ICPlayer onlinePlayer = player.getPlayer();
        long time = ((onlinePlayer != null && onlinePlayer.isLocal() ? ((ICPlayer) player).getLocalPlayer().getPlayerTime() : Bukkit.getWorlds().get(0).getTime()) % 24000) - 6000;
        if (time < 0) {
            time += 24000;
        }
        double timePhase = (double) time / 24000;
        predicates.put(ModelOverrideType.TIME, (float) (timePhase - 0.0078125));
    } else if (xMaterial.equals(XMaterial.COMPASS)) {
        double angle;
        ICPlayer icplayer = player.getPlayer();
        if (icplayer != null && icplayer.isLocal()) {
            if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_16)) {
                CompassMeta meta = (CompassMeta) item.getItemMeta();
                Location target;
                if (meta.hasLodestone()) {
                    Location lodestone = meta.getLodestone();
                    target = new Location(lodestone.getWorld(), lodestone.getBlockX() + 0.5, lodestone.getBlockY(), lodestone.getBlockZ() + 0.5, lodestone.getYaw(), lodestone.getPitch());
                    requiresEnchantmentGlint = true;
                } else if (icplayer.getLocalPlayer().getWorld().getEnvironment().equals(Environment.NORMAL)) {
                    Location spawn = icplayer.getLocalPlayer().getWorld().getSpawnLocation();
                    target = new Location(spawn.getWorld(), spawn.getBlockX() + 0.5, spawn.getBlockY(), spawn.getBlockZ() + 0.5, spawn.getYaw(), spawn.getPitch());
                } else {
                    target = null;
                }
                if (target != null && target.getWorld().equals(icplayer.getLocalPlayer().getWorld())) {
                    Location playerLocation = icplayer.getLocalPlayer().getEyeLocation();
                    playerLocation.setPitch(0);
                    Vector looking = playerLocation.getDirection();
                    Vector pointing = target.toVector().subtract(playerLocation.toVector());
                    pointing.setY(0);
                    double degree = VectorUtils.getBearing(looking, pointing);
                    if (degree < 0) {
                        degree += 360;
                    }
                    angle = degree / 360;
                } else {
                    angle = RANDOM.nextDouble();
                }
            } else {
                if (icplayer.getLocalPlayer().getWorld().getEnvironment().equals(Environment.NORMAL)) {
                    Location spawn = icplayer.getLocalPlayer().getWorld().getSpawnLocation();
                    Location target = new Location(spawn.getWorld(), spawn.getBlockX() + 0.5, spawn.getBlockY(), spawn.getBlockZ() + 0.5, spawn.getYaw(), spawn.getPitch());
                    Location playerLocation = icplayer.getLocalPlayer().getEyeLocation();
                    playerLocation.setPitch(0);
                    Vector looking = playerLocation.getDirection();
                    Vector pointing = target.toVector().subtract(playerLocation.toVector());
                    pointing.setY(0);
                    double degree = VectorUtils.getBearing(looking, pointing);
                    if (degree < 0) {
                        degree += 360;
                    }
                    angle = degree / 360;
                } else {
                    angle = RANDOM.nextDouble();
                }
            }
        } else {
            if (InteractiveChat.version.isNewerOrEqualTo(MCVersion.V1_16)) {
                CompassMeta meta = (CompassMeta) item.getItemMeta();
                if (meta.hasLodestone()) {
                    requiresEnchantmentGlint = true;
                }
            }
            angle = 0;
        }
        predicates.put(ModelOverrideType.ANGLE, (float) (angle - 0.015625));
    } else if (xMaterial.equals(XMaterial.LIGHT)) {
        int level = 15;
        Object blockStateObj = item.getItemMeta().serialize().get("BlockStateTag");
        if (blockStateObj != null && blockStateObj instanceof Map) {
            Object levelObj = ((Map<?, Object>) blockStateObj).get("level");
            if (levelObj != null) {
                try {
                    level = Integer.parseInt(levelObj.toString().replace("i", ""));
                } catch (NumberFormatException e) {
                }
            }
        }
        predicates.put(ModelOverrideType.LEVEL, (float) level / 16F);
    } else if (item.getItemMeta() instanceof LeatherArmorMeta) {
        LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
        Color color = new Color(meta.getColor().asRGB());
        if (xMaterial.equals(XMaterial.LEATHER_HORSE_ARMOR)) {
            BufferedImage itemImage = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.ITEM_TEXTURE_LOCATION + xMaterial.name().toLowerCase()).getTexture(32, 32);
            BufferedImage colorOverlay = ImageUtils.changeColorTo(ImageUtils.copyImage(itemImage), color);
            itemImage = ImageUtils.multiply(itemImage, colorOverlay);
            providedTextures.put(ResourceRegistry.LEATHER_HORSE_ARMOR_PLACEHOLDER, new GeneratedTextureResource(itemImage));
        } else {
            BufferedImage itemImage = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.ITEM_TEXTURE_LOCATION + xMaterial.name().toLowerCase()).getTexture(32, 32);
            BufferedImage colorOverlay = ImageUtils.changeColorTo(ImageUtils.copyImage(itemImage), color);
            itemImage = ImageUtils.multiply(itemImage, colorOverlay);
            if (xMaterial.name().contains("HELMET")) {
                providedTextures.put(ResourceRegistry.LEATHER_HELMET_PLACEHOLDER, new GeneratedTextureResource(itemImage));
            } else if (xMaterial.name().contains("CHESTPLATE")) {
                providedTextures.put(ResourceRegistry.LEATHER_CHESTPLATE_PLACEHOLDER, new GeneratedTextureResource(itemImage));
            } else if (xMaterial.name().contains("LEGGINGS")) {
                providedTextures.put(ResourceRegistry.LEATHER_LEGGINGS_PLACEHOLDER, new GeneratedTextureResource(itemImage));
            } else if (xMaterial.name().contains("BOOTS")) {
                providedTextures.put(ResourceRegistry.LEATHER_BOOTS_PLACEHOLDER, new GeneratedTextureResource(itemImage));
            }
        }
    } else if (item.getItemMeta() instanceof PotionMeta) {
        if (xMaterial.equals(XMaterial.TIPPED_ARROW)) {
            PotionMeta meta = (PotionMeta) item.getItemMeta();
            PotionType potiontype = InteractiveChat.version.isOld() ? Potion.fromItemStack(item).getType() : meta.getBasePotionData().getType();
            BufferedImage tippedArrowHead = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.ITEM_TEXTURE_LOCATION + "tipped_arrow_head").getTexture(32, 32);
            int color;
            try {
                if (meta.hasColor()) {
                    color = meta.getColor().asRGB();
                } else {
                    color = PotionUtils.getPotionBaseColor(potiontype);
                }
            } catch (Throwable e) {
                color = PotionUtils.getPotionBaseColor(PotionType.WATER);
            }
            BufferedImage colorOverlay = ImageUtils.changeColorTo(ImageUtils.copyImage(tippedArrowHead), color);
            tippedArrowHead = ImageUtils.multiply(tippedArrowHead, colorOverlay);
            providedTextures.put(ResourceRegistry.TIPPED_ARROW_HEAD_PLACEHOLDER, new GeneratedTextureResource(tippedArrowHead));
        } else {
            PotionMeta meta = (PotionMeta) item.getItemMeta();
            PotionType potiontype = InteractiveChat.version.isOld() ? Potion.fromItemStack(item).getType() : meta.getBasePotionData().getType();
            BufferedImage potionOverlay = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.ITEM_TEXTURE_LOCATION + "potion_overlay").getTexture(32, 32);
            int color;
            try {
                if (meta.hasColor()) {
                    color = meta.getColor().asRGB();
                } else {
                    color = PotionUtils.getPotionBaseColor(potiontype);
                }
            } catch (Throwable e) {
                color = PotionUtils.getPotionBaseColor(PotionType.WATER);
            }
            BufferedImage colorOverlay = ImageUtils.changeColorTo(ImageUtils.copyImage(potionOverlay), color);
            potionOverlay = ImageUtils.multiply(potionOverlay, colorOverlay);
            providedTextures.put(ResourceRegistry.POTION_OVERLAY_PLACEHOLDER, new GeneratedTextureResource(potionOverlay));
            if (potiontype != null) {
                if (!(potiontype.name().equals("WATER") || potiontype.name().equals("AWKWARD") || potiontype.name().equals("MUNDANE") || potiontype.name().equals("THICK") || potiontype.name().equals("UNCRAFTABLE"))) {
                    requiresEnchantmentGlint = true;
                }
            }
        }
    } else if (xMaterial.isOneOf(Arrays.asList("CONTAINS:spawn_egg"))) {
        SpawnEggTintData tintData = TintUtils.getSpawnEggTint(xMaterial);
        if (tintData != null) {
            BufferedImage baseImage = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.ITEM_TEXTURE_LOCATION + "spawn_egg").getTexture();
            BufferedImage overlayImage = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.ITEM_TEXTURE_LOCATION + "spawn_egg_overlay").getTexture(baseImage.getWidth(), baseImage.getHeight());
            BufferedImage colorBase = ImageUtils.changeColorTo(ImageUtils.copyImage(baseImage), tintData.getBase());
            BufferedImage colorOverlay = ImageUtils.changeColorTo(ImageUtils.copyImage(overlayImage), tintData.getOverlay());
            baseImage = ImageUtils.multiply(baseImage, colorBase);
            overlayImage = ImageUtils.multiply(overlayImage, colorOverlay);
            providedTextures.put(ResourceRegistry.SPAWN_EGG_PLACEHOLDER, new GeneratedTextureResource(baseImage));
            providedTextures.put(ResourceRegistry.SPAWN_EGG_OVERLAY_PLACEHOLDER, new GeneratedTextureResource(overlayImage));
        }
    } else if (InteractiveChat.version.isLegacy() && xMaterial.isOneOf(Arrays.asList("CONTAINS:bed"))) {
        String colorName = xMaterial.name().replace("_BED", "").toLowerCase();
        BufferedImage bedTexture = InteractiveChatDiscordSrvAddon.plugin.resourceManager.getTextureManager().getTexture(ResourceRegistry.ENTITY_TEXTURE_LOCATION + "bed/" + colorName).getTexture();
        providedTextures.put(ResourceRegistry.LEGACY_BED_TEXTURE_PLACEHOLDER, new GeneratedTextureResource(bedTexture));
    }
    return new ItemStackProcessResult(requiresEnchantmentGlint, predicates, providedTextures, tintIndexData, directLocation);
}
Also used : GeneratedTextureResource(com.loohp.interactivechatdiscordsrvaddon.resources.textures.GeneratedTextureResource) TextureResource(com.loohp.interactivechatdiscordsrvaddon.resources.textures.TextureResource) ICPlayer(com.loohp.interactivechat.objectholders.ICPlayer) OfflineICPlayer(com.loohp.interactivechat.objectholders.OfflineICPlayer) HashMap(java.util.HashMap) LocalDate(java.time.LocalDate) BufferedImage(java.awt.image.BufferedImage) BannerAssetResult(com.loohp.interactivechatdiscordsrvaddon.graphics.BannerGraphics.BannerAssetResult) List(java.util.List) CompassMeta(org.bukkit.inventory.meta.CompassMeta) ModelOverrideType(com.loohp.interactivechatdiscordsrvaddon.resources.models.ModelOverride.ModelOverrideType) EnumMap(java.util.EnumMap) Vector(org.bukkit.util.Vector) SpawnEggTintData(com.loohp.interactivechatdiscordsrvaddon.utils.TintUtils.SpawnEggTintData) CrossbowMeta(org.bukkit.inventory.meta.CrossbowMeta) Color(java.awt.Color) GeneratedTextureResource(com.loohp.interactivechatdiscordsrvaddon.resources.textures.GeneratedTextureResource) PotionMeta(org.bukkit.inventory.meta.PotionMeta) XMaterial(com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial) TintIndexData(com.loohp.interactivechatdiscordsrvaddon.utils.TintUtils.TintIndexData) JSONObject(com.loohp.interactivechat.libs.org.json.simple.JSONObject) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) JSONParser(com.loohp.interactivechat.libs.org.json.simple.parser.JSONParser) JSONObject(com.loohp.interactivechat.libs.org.json.simple.JSONObject) ParseException(com.loohp.interactivechat.libs.org.json.simple.parser.ParseException) PotionType(org.bukkit.potion.PotionType) ItemStack(org.bukkit.inventory.ItemStack) HashMap(java.util.HashMap) Map(java.util.Map) EnumMap(java.util.EnumMap) Location(org.bukkit.Location)

Aggregations

XMaterial (com.loohp.interactivechat.libs.com.cryptomorin.xseries.XMaterial)7 Color (java.awt.Color)7 BufferedImage (java.awt.image.BufferedImage)5 ItemStack (org.bukkit.inventory.ItemStack)5 Component (com.loohp.interactivechat.libs.net.kyori.adventure.text.Component)4 BlockStateMeta (org.bukkit.inventory.meta.BlockStateMeta)4 LeatherArmorMeta (org.bukkit.inventory.meta.LeatherArmorMeta)4 ICPlayer (com.loohp.interactivechat.objectholders.ICPlayer)3 ModelOverrideType (com.loohp.interactivechatdiscordsrvaddon.resources.models.ModelOverride.ModelOverrideType)3 GeneratedTextureResource (com.loohp.interactivechatdiscordsrvaddon.resources.textures.GeneratedTextureResource)3 TextureResource (com.loohp.interactivechatdiscordsrvaddon.resources.textures.TextureResource)3 TintIndexData (com.loohp.interactivechatdiscordsrvaddon.utils.TintUtils.TintIndexData)3 PatternTypeWrapper (com.loohp.interactivechatdiscordsrvaddon.wrappers.PatternTypeWrapper)3 Graphics2D (java.awt.Graphics2D)3 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 InteractiveChat (com.loohp.interactivechat.InteractiveChat)2 LegacyComponentSerializer (com.loohp.interactivechat.libs.net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer)2 PlainTextComponentSerializer (com.loohp.interactivechat.libs.net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer)2