Search in sources :

Example 26 with BlockStateMeta

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

the class ItemSpawnerDelay method getPropertyString.

@Override
public String getPropertyString() {
    BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
    CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
    return state.getDelay() + "," + state.getMinSpawnDelay() + "," + state.getMaxSpawnDelay();
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Example 27 with BlockStateMeta

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

the class ItemSpawnerDelay method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("spawner_delay_data")) {
        ListTag list = mechanism.valueAsType(ListTag.class);
        if (list.size() < 3) {
            return;
        }
        BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
        CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
        state.setDelay(Integer.parseInt(list.get(0)));
        int minDelay = Integer.parseInt(list.get(1));
        int maxDelay = Integer.parseInt(list.get(2));
        // or new min would be higher than the current max
        if (minDelay > state.getMaxSpawnDelay()) {
            state.setMaxSpawnDelay(maxDelay);
            state.setMinSpawnDelay(minDelay);
        } else {
            state.setMinSpawnDelay(minDelay);
            state.setMaxSpawnDelay(maxDelay);
        }
        meta.setBlockState(state);
        item.setItemMeta(meta);
    }
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) ListTag(com.denizenscript.denizencore.objects.core.ListTag) CreatureSpawner(org.bukkit.block.CreatureSpawner)

Example 28 with BlockStateMeta

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

the class ItemSpawnerPlayerRange method getObjectAttribute.

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

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

the class ItemSpawnerType method getObjectAttribute.

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

Example 30 with BlockStateMeta

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

the class ItemInventory method getItemInventory.

private InventoryTag getItemInventory() {
    InventoryHolder holder = ((InventoryHolder) ((BlockStateMeta) item.getItemMeta()).getBlockState());
    Inventory inv = getInventoryFor(holder);
    return InventoryTag.mirrorBukkitInventory(inv);
}
Also used : BlockStateMeta(org.bukkit.inventory.meta.BlockStateMeta) InventoryHolder(org.bukkit.inventory.InventoryHolder) Inventory(org.bukkit.inventory.Inventory)

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