Search in sources :

Example 21 with BlockStateMeta

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

the class ItemSpawnerCount method adjust.

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

Example 22 with BlockStateMeta

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

the class ItemSpawnerCount method getObjectAttribute.

@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
    if (attribute == null) {
        return null;
    }
    // -->
    if (attribute.startsWith("spawner_count")) {
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        return new ElementTag(state.getSpawnCount()).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 23 with BlockStateMeta

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

the class ItemSpawnerMaxNearbyEntities method adjust.

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

Example 24 with BlockStateMeta

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

the class ItemSpawnerRange method getPropertyString.

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

Example 25 with BlockStateMeta

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

the class ItemSpawnerRange method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("spawner_range") && mechanism.requireInteger()) {
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        state.setSpawnRange(mechanism.getValue().asInt());
        meta.setBlockState(state);
        item.setItemMeta(meta);
    }
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) 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