Search in sources :

Example 1 with IntTag

use of com.wasteofplastic.org.jnbt.IntTag in project askyblock by tastybento.

the class BannerBlock method prep.

@SuppressWarnings("deprecation")
public boolean prep(Map<String, Tag> tileData) {
    // x = Int
    try {
        // Do the base color
        int baseColor = 15 - ((IntTag) tileData.get("Base")).getValue();
        // //ASkyBlock.getPlugin().getLogger().info("Base value = " +
        // baseColor);
        // baseColor green = 10
        bannerBaseColor = DyeColor.getByDyeData((byte) baseColor);
        // Do the patterns (no idea if this will work or not)
        bannerPattern = new ArrayList<Pattern>();
        ListTag patterns = (ListTag) tileData.get("Patterns");
        if (patterns != null) {
            for (Tag pattern : patterns.getValue()) {
                // Translate pattern to PatternType
                if (pattern instanceof CompoundTag) {
                    CompoundTag patternColor = (CompoundTag) pattern;
                    // The tag is made up of pattern (String) and color
                    // (int)
                    Map<String, Tag> patternValue = patternColor.getValue();
                    StringTag mark = (StringTag) patternValue.get("Pattern");
                    Integer markColor = 15 - ((IntTag) patternValue.get("Color")).getValue();
                    // ASkyBlock.getPlugin().getLogger().info("mark = " +
                    // mark.getValue());
                    // ASkyBlock.getPlugin().getLogger().info("color = " +
                    // markColor);
                    DyeColor dColor = DyeColor.getByDyeData(markColor.byteValue());
                    // + dColor.toString());
                    if (patternKey.containsKey(mark.getValue())) {
                        Pattern newPattern = new Pattern(dColor, patternKey.get(mark.getValue()));
                        bannerPattern.add(newPattern);
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return true;
}
Also used : StringTag(com.wasteofplastic.org.jnbt.StringTag) Pattern(org.bukkit.block.banner.Pattern) ListTag(com.wasteofplastic.org.jnbt.ListTag) StringTag(com.wasteofplastic.org.jnbt.StringTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag) IntTag(com.wasteofplastic.org.jnbt.IntTag) Tag(com.wasteofplastic.org.jnbt.Tag) DyeColor(org.bukkit.DyeColor) ListTag(com.wasteofplastic.org.jnbt.ListTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag)

Example 2 with IntTag

use of com.wasteofplastic.org.jnbt.IntTag in project acidisland by tastybento.

the class BannerBlock method prep.

@SuppressWarnings("deprecation")
public boolean prep(Map<String, Tag> tileData) {
    // x = Int
    try {
        // Do the base color
        int baseColor = 15 - ((IntTag) tileData.get("Base")).getValue();
        // //ASkyBlock.getPlugin().getLogger().info("Base value = " +
        // baseColor);
        // baseColor green = 10
        bannerBaseColor = DyeColor.getByDyeData((byte) baseColor);
        // Do the patterns (no idea if this will work or not)
        bannerPattern = new ArrayList<Pattern>();
        ListTag patterns = (ListTag) tileData.get("Patterns");
        if (patterns != null) {
            for (Tag pattern : patterns.getValue()) {
                // Translate pattern to PatternType
                if (pattern instanceof CompoundTag) {
                    CompoundTag patternColor = (CompoundTag) pattern;
                    // The tag is made up of pattern (String) and color
                    // (int)
                    Map<String, Tag> patternValue = patternColor.getValue();
                    StringTag mark = (StringTag) patternValue.get("Pattern");
                    Integer markColor = 15 - ((IntTag) patternValue.get("Color")).getValue();
                    // ASkyBlock.getPlugin().getLogger().info("mark = " +
                    // mark.getValue());
                    // ASkyBlock.getPlugin().getLogger().info("color = " +
                    // markColor);
                    DyeColor dColor = DyeColor.getByDyeData(markColor.byteValue());
                    // + dColor.toString());
                    if (patternKey.containsKey(mark.getValue())) {
                        Pattern newPattern = new Pattern(dColor, patternKey.get(mark.getValue()));
                        bannerPattern.add(newPattern);
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return true;
}
Also used : StringTag(com.wasteofplastic.org.jnbt.StringTag) Pattern(org.bukkit.block.banner.Pattern) ListTag(com.wasteofplastic.org.jnbt.ListTag) StringTag(com.wasteofplastic.org.jnbt.StringTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag) IntTag(com.wasteofplastic.org.jnbt.IntTag) Tag(com.wasteofplastic.org.jnbt.Tag) DyeColor(org.bukkit.DyeColor) ListTag(com.wasteofplastic.org.jnbt.ListTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag)

Aggregations

CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)2 IntTag (com.wasteofplastic.org.jnbt.IntTag)2 ListTag (com.wasteofplastic.org.jnbt.ListTag)2 StringTag (com.wasteofplastic.org.jnbt.StringTag)2 Tag (com.wasteofplastic.org.jnbt.Tag)2 DyeColor (org.bukkit.DyeColor)2 Pattern (org.bukkit.block.banner.Pattern)2