Search in sources :

Example 11 with BlockStateMeta

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

the class ItemSpawnerPlayerRange method getPropertyString.

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

Example 12 with BlockStateMeta

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

the class ItemSpawnerPlayerRange method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("spawner_player_range") && mechanism.requireInteger()) {
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        state.setRequiredPlayerRange(mechanism.getValue().asInt());
        meta.setBlockState(state);
        item.setItemMeta(meta);
    }
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Example 13 with BlockStateMeta

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

the class ItemSpawnerType method getPropertyString.

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

Example 14 with BlockStateMeta

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

the class ItemSpawnerType method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("spawner_type") && mechanism.requireObject(EntityTag.class)) {
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        state.setSpawnedType(mechanism.valueAsType(EntityTag.class).getBukkitEntityType());
        meta.setBlockState(state);
        item.setItemMeta(meta);
    }
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) EntityTag(com.denizenscript.denizen.objects.EntityTag) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Example 15 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) {
    ItemStack itemStack = item.getItemStack();
    ItemMeta itemMeta = itemStack.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);
    }
    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)

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