Java Code Examples for org.bukkit.block.Banner#setPatterns()

The following examples show how to use org.bukkit.block.Banner#setPatterns() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BannerBlock.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
public boolean set(Block block) {
    Banner banner = (Banner) block.getState();
    banner.setBaseColor(bannerBaseColor);
    banner.setPatterns(bannerPattern);
    banner.update(true, false);
    return true;
}
 
Example 2
Source File: Materials.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
static void applyToBlock(Banner block, BannerMeta meta) {
  block.setBaseColor(meta.getBaseColor());
  block.setPatterns(meta.getPatterns());
}
 
Example 3
Source File: Banners.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void applyToBlock(Banner block, BannerMeta meta) {
    block.setBaseColor(meta.getBaseColor());
    block.setPatterns(meta.getPatterns());
}
 
Example 4
Source File: ItemBuilder.java    From Crazy-Crates with MIT License 4 votes vote down vote up
/**
 * Builder the item from all the information that was given to the builder.
 * @return The result of all the info that was given to the builder as an ItemStack.
 */
public ItemStack build() {
    if (nbtItem != null) {
        referenceItem = nbtItem.getItem();
    }
    ItemStack item = referenceItem != null ? referenceItem : new ItemStack(material);
    if (item.getType() != Material.AIR) {
        if (isHead) {//Has to go 1st due to it removing all data when finished.
            if (isHash) {//Sauce: https://github.com/deanveloper/SkullCreator
                if (isURL) {
                    SkullCreator.itemWithUrl(item, player);
                } else {
                    SkullCreator.itemWithBase64(item, player);
                }
            }
        }
        item.setAmount(amount);
        ItemMeta itemMeta = item.getItemMeta();
        itemMeta.setDisplayName(getUpdatedName());
        itemMeta.setLore(getUpdatedLore());
        if (version.isSame(Version.v1_8_R3)) {
            if (isHead && !isHash && player != null && !player.equals("")) {
                SkullMeta skullMeta = (SkullMeta) itemMeta;
                skullMeta.setOwner(player);
            }
        }
        if (version.isNewer(Version.v1_10_R1)) {
            itemMeta.setUnbreakable(unbreakable);
        }
        if (version.isNewer(Version.v1_12_R1)) {
            if (itemMeta instanceof org.bukkit.inventory.meta.Damageable) {
                ((org.bukkit.inventory.meta.Damageable) itemMeta).setDamage(damage);
            }
        } else {
            item.setDurability((short) damage);
        }
        if (isPotion && (potionType != null || potionColor != null)) {
            PotionMeta potionMeta = (PotionMeta) itemMeta;
            if (potionType != null) {
                potionMeta.setBasePotionData(new PotionData(potionType));
            }
            if (potionColor != null) {
                potionMeta.setColor(potionColor);
            }
        }
        if (isLeatherArmor && armorColor != null) {
            LeatherArmorMeta leatherMeta = (LeatherArmorMeta) itemMeta;
            leatherMeta.setColor(armorColor);
        }
        if (isBanner && !patterns.isEmpty()) {
            BannerMeta bannerMeta = (BannerMeta) itemMeta;
            bannerMeta.setPatterns(patterns);
        }
        if (isShield && !patterns.isEmpty()) {
            BlockStateMeta shieldMeta = (BlockStateMeta) itemMeta;
            Banner banner = (Banner) shieldMeta.getBlockState();
            banner.setPatterns(patterns);
            banner.update();
            shieldMeta.setBlockState(banner);
        }
        if (useCustomModelData) {
            itemMeta.setCustomModelData(customModelData);
        }
        itemFlags.forEach(itemMeta :: addItemFlags);
        item.setItemMeta(itemMeta);
        hideFlags(item);
        item.addUnsafeEnchantments(enchantments);
        addGlow(item);
        NBTItem nbt = new NBTItem(item);
        if (isHead) {
            if (!isHash && player != null && !player.equals("") && version.isNewer(Version.v1_8_R3)) {
                nbt.setString("SkullOwner", player);
            }
        }
        if (isMobEgg) {
            if (entityType != null) {
                nbt.addCompound("EntityTag").setString("id", "minecraft:" + entityType.name());
            }
        }
        if (version.isOlder(Version.v1_11_R1)) {
            if (unbreakable) {
                nbt.setBoolean("Unbreakable", true);
                nbt.setInteger("HideFlags", 4);
            }
        }
        if (!crateName.isEmpty()) {
            nbt.setString("CrazyCrates-Crate", crateName);
        }
        return nbt.getItem();
    } else {
        return item;
    }
}
 
Example 5
Source File: FlagObjective.java    From CardinalPGM with MIT License 4 votes vote down vote up
private void spawnFlag() {
    if (!isOnPost()) {
        setLastValidBlock();
        if (currentFlagBlock == null) {
            armorStand.remove();
            currentFlagBlock = nextSpawn();
            state = FlagState.WAITING_TO_RESPAWN;
            respawnTime = getPost().getRespawnTime(picker.getLocation(), currentFlagBlock.getLocation());
            resetPlayer();
            updateFlags();
            return;
        }
    }
    currentFlagBlock.setType(banner.getMaterial());
    currentFlagBlock = currentFlagBlock.getLocation().getBlock();
    Banner newBanner = (Banner)currentFlagBlock.getState();
    newBanner.setPatterns(banner.getPatterns());
    newBanner.setBaseColor(banner.getBaseColor());
    armorStand = createArmorStand();
    if (!isOnPost()) {
        if (currentFlagBlock.getRelative(BlockFace.DOWN).getType().equals(Material.STATIONARY_WATER)) {
            currentFlagBlock.getRelative(BlockFace.DOWN).setType(Material.ICE);
            state = FlagState.DROPPED_ON_WATER;
        } else {
            state = FlagState.DROPPED;
        }
        Flags.setBannerFacing(Flags.yawToFace(picker.getLocation().getYaw()), newBanner);
        FlagDropEvent event = new FlagDropEvent(getPicker(), this);
        Bukkit.getPluginManager().callEvent(event);
    } else {
        Flags.setBannerFacing(getPost().getYaw(), newBanner);
    }
    Player oldPicker = picker;
    this.lastNet = null;
    resetPlayer();
    for (Player player : Bukkit.getOnlinePlayers()) {
        if (oldPicker != null && player.equals(oldPicker)) continue;
        getPost().tryPickupFlag(player, player.getLocation(), null, this);
        if (picker != null) break;
    }
}
 
Example 6
Source File: BannerUtils.java    From NovaGuilds with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Applies meta to a banner
 *
 * @param banner banner block
 * @param meta   banner meta
 * @return banner block
 */
public static Banner applyMeta(Banner banner, BannerMeta meta) {
	banner.setBaseColor(meta.getBaseColor());
	banner.setPatterns(meta.getPatterns());
	return banner;
}