Search in sources :

Example 6 with BlockStateMeta

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

the class ItemSpawnerMaxNearbyEntities method getObjectAttribute.

@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
    if (attribute == null) {
        return null;
    }
    // -->
    if (attribute.startsWith("spawner_max_nearby_entities")) {
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        return new ElementTag(state.getMaxNearbyEntities()).getObjectAttribute(attribute.fulfill(1));
    }
    return null;
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Example 7 with BlockStateMeta

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

the class ItemBaseColor method setBaseColor.

private void setBaseColor(DyeColor color, TagContext context) {
    if (color == null && item.getBukkitMaterial() == Material.SHIELD) {
        ItemRawNBT property = ItemRawNBT.getFrom(item);
        MapTag nbt = property.getFullNBTMap();
        nbt.putObject("BlockEntityTag", null);
        property.setFullNBT(item, nbt, context, false);
        return;
    }
    ItemMeta itemMeta = item.getItemMeta();
    if (itemMeta instanceof BlockStateMeta) {
        Banner banner = (Banner) ((BlockStateMeta) itemMeta).getBlockState();
        banner.setBaseColor(color);
        banner.update();
        ((BlockStateMeta) itemMeta).setBlockState(banner);
    } else {
        ((BannerMeta) itemMeta).setBaseColor(color);
    }
    item.setItemMeta(itemMeta);
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) BannerMeta(org.bukkit.inventory.meta.BannerMeta) Banner(org.bukkit.block.Banner) MapTag(com.denizenscript.denizencore.objects.core.MapTag) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 8 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) {
    ItemMeta itemMeta = item.getItemMeta();
    if (itemMeta instanceof BannerMeta) {
        ((BannerMeta) itemMeta).setPatterns(patterns);
    } else if (itemMeta instanceof BlockStateMeta) {
        try {
            Banner banner = (Banner) ((BlockStateMeta) itemMeta).getBlockState();
            banner.setPatterns(patterns);
            banner.update();
            ((BlockStateMeta) itemMeta).setBlockState(banner);
        } catch (Exception ex) {
            Debug.echoError("Banner setPatterns failed!");
            Debug.echoError(ex);
        }
    } else {
    // ...???
    }
    item.setItemMeta(itemMeta);
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) BannerMeta(org.bukkit.inventory.meta.BannerMeta) Banner(org.bukkit.block.Banner) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 9 with BlockStateMeta

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

the class ItemSpawnerRange method getObjectAttribute.

@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
    if (attribute == null) {
        return null;
    }
    // -->
    if (attribute.startsWith("spawner_range")) {
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        return new ElementTag(state.getSpawnRange()).getObjectAttribute(attribute.fulfill(1));
    }
    return null;
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Example 10 with BlockStateMeta

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

the class ItemSpawnerDelay method getObjectAttribute.

@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
    if (attribute == null) {
        return null;
    }
    // -->
    if (attribute.startsWith("spawner_spawn_delay")) {
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        return new ElementTag(state.getDelay()).getObjectAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("spawner_minimum_spawn_delay")) {
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        return new ElementTag(state.getMinSpawnDelay()).getObjectAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("spawner_maximum_spawn_delay")) {
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        return new ElementTag(state.getMaxSpawnDelay()).getObjectAttribute(attribute.fulfill(1));
    }
    return null;
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Aggregations

BlockStateMeta (org.bukkit.inventory.meta.BlockStateMeta)32 CreatureSpawner (org.bukkit.block.CreatureSpawner)22 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)6 Banner (org.bukkit.block.Banner)5 BannerMeta (org.bukkit.inventory.meta.BannerMeta)5 ItemMeta (org.bukkit.inventory.meta.ItemMeta)5 ListTag (com.denizenscript.denizencore.objects.core.ListTag)4 ItemStack (org.bukkit.inventory.ItemStack)3 EntityTag (com.denizenscript.denizen.objects.EntityTag)2 BlockState (org.bukkit.block.BlockState)2 InventoryHolder (org.bukkit.inventory.InventoryHolder)2 InventoryTag (com.denizenscript.denizen.objects.InventoryTag)1 ItemTag (com.denizenscript.denizen.objects.ItemTag)1 ItemScriptContainer (com.denizenscript.denizen.scripts.containers.core.ItemScriptContainer)1 Argument (com.denizenscript.denizencore.objects.Argument)1 MapTag (com.denizenscript.denizencore.objects.core.MapTag)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1