Search in sources :

Example 1 with BlockStateMeta

use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.

the class ItemPatterns method setPatterns.

private void setPatterns(List<Pattern> patterns) {
    ItemStack itemStack = item.getItemStack();
    ItemMeta itemMeta = itemStack.getItemMeta();
    if (itemMeta instanceof BlockStateMeta) {
        Banner banner = (Banner) ((BlockStateMeta) itemMeta).getBlockState();
        banner.setPatterns(patterns);
        banner.update();
        ((BlockStateMeta) itemMeta).setBlockState(banner);
    } else {
        ((BannerMeta) itemMeta).setPatterns(patterns);
    }
    itemStack.setItemMeta(itemMeta);
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) BannerMeta(org.bukkit.inventory.meta.BannerMeta) Banner(org.bukkit.block.Banner) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 2 with BlockStateMeta

use of org.bukkit.inventory.meta.BlockStateMeta in project Essentials by drtshock.

the class BlockMetaSpawnerProvider method getEntityType.

@Override
public EntityType getEntityType(ItemStack is) {
    BlockStateMeta bsm = (BlockStateMeta) is.getItemMeta();
    CreatureSpawner bs = (CreatureSpawner) bsm.getBlockState();
    return bs.getSpawnedType();
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Example 3 with BlockStateMeta

use of org.bukkit.inventory.meta.BlockStateMeta in project Essentials by drtshock.

the class BlockMetaSpawnerProvider method setEntityType.

@Override
public ItemStack setEntityType(ItemStack is, EntityType type) {
    BlockStateMeta bsm = (BlockStateMeta) is.getItemMeta();
    BlockState bs = bsm.getBlockState();
    ((CreatureSpawner) bs).setSpawnedType(type);
    bsm.setBlockState(bs);
    is.setItemMeta(bsm);
    return setDisplayName(is, type);
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) BlockState(org.bukkit.block.BlockState) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Example 4 with BlockStateMeta

use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.

the class ItemSignContents method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("sign_contents")) {
        BlockStateMeta bsm = ((BlockStateMeta) item.getItemMeta());
        Sign sign = (Sign) bsm.getBlockState();
        for (int i = 0; i < 4; i++) {
            AdvancedTextImpl.instance.setSignLine(sign, i, "");
        }
        ListTag list = mechanism.valueAsType(ListTag.class);
        CoreUtilities.fixNewLinesToListSeparation(list);
        if (list.size() > 4) {
            Debug.echoError("Sign can only hold four lines!");
        } else {
            for (int i = 0; i < list.size(); i++) {
                AdvancedTextImpl.instance.setSignLine(sign, i, list.get(i));
            }
        }
        bsm.setBlockState(sign);
        item.setItemMeta(bsm);
    }
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) Sign(org.bukkit.block.Sign) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 5 with BlockStateMeta

use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.

the class ItemSpawnerMaxNearbyEntities method getPropertyString.

@Override
public String getPropertyString() {
    BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
    CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
    return String.valueOf(state.getMaxNearbyEntities());
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Aggregations

BlockStateMeta (org.bukkit.inventory.meta.BlockStateMeta)33 CreatureSpawner (org.bukkit.block.CreatureSpawner)22 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)6 Banner (org.bukkit.block.Banner)6 BannerMeta (org.bukkit.inventory.meta.BannerMeta)6 ItemMeta (org.bukkit.inventory.meta.ItemMeta)5 ListTag (com.denizenscript.denizencore.objects.core.ListTag)4 BlockState (org.bukkit.block.BlockState)3 ItemStack (org.bukkit.inventory.ItemStack)3 EntityTag (com.denizenscript.denizen.objects.EntityTag)2 Map (java.util.Map)2 Pattern (org.bukkit.block.banner.Pattern)2 InventoryHolder (org.bukkit.inventory.InventoryHolder)2 BookMeta (org.bukkit.inventory.meta.BookMeta)2 EnchantmentStorageMeta (org.bukkit.inventory.meta.EnchantmentStorageMeta)2 FireworkMeta (org.bukkit.inventory.meta.FireworkMeta)2 LeatherArmorMeta (org.bukkit.inventory.meta.LeatherArmorMeta)2 MapMeta (org.bukkit.inventory.meta.MapMeta)2 PotionMeta (org.bukkit.inventory.meta.PotionMeta)2 Repairable (org.bukkit.inventory.meta.Repairable)2