Search in sources :

Example 41 with MaterialTag

use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.

the class ItemCanPlaceOn method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("can_place_on")) {
        if (item.getMaterial().getMaterial() == Material.AIR) {
            mechanism.echoError("Cannot apply NBT to AIR!");
            return;
        }
        ItemStack itemStack = item.getItemStack();
        if (mechanism.hasValue()) {
            List<Material> materials = mechanism.valueAsType(ListTag.class).filter(MaterialTag.class, mechanism.context).stream().map(MaterialTag::getMaterial).collect(Collectors.toList());
            itemStack = CustomNBT.setNBTMaterials(itemStack, CustomNBT.KEY_CAN_PLACE_ON, materials);
        } else {
            itemStack = CustomNBT.clearNBT(itemStack, CustomNBT.KEY_CAN_PLACE_ON);
        }
        item.setItemStack(itemStack);
    }
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack)

Example 42 with MaterialTag

use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.

the class ItemCanDestroy method getMaterials.

private ListTag getMaterials() {
    ItemStack itemStack = item.getItemStack();
    List<Material> materials = CustomNBT.getNBTMaterials(itemStack, CustomNBT.KEY_CAN_DESTROY);
    if (materials != null && !materials.isEmpty()) {
        ListTag list = new ListTag();
        for (Material material : materials) {
            list.addObject(new MaterialTag(material));
        }
        return list;
    }
    return null;
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 43 with MaterialTag

use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.

the class EntityFormsBlockScriptEvent method onEntityFormsBlock.

@EventHandler
public void onEntityFormsBlock(EntityBlockFormEvent event) {
    location = new LocationTag(event.getBlock().getLocation());
    material = new MaterialTag(event.getBlock());
    entity = new EntityTag(event.getEntity());
    this.event = event;
    fire(event);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) MaterialTag(com.denizenscript.denizen.objects.MaterialTag) EntityTag(com.denizenscript.denizen.objects.EntityTag) EventHandler(org.bukkit.event.EventHandler)

Example 44 with MaterialTag

use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.

the class LiquidLevelChangeScriptEvent method onLiquidLevelChange.

@EventHandler
public void onLiquidLevelChange(FluidLevelChangeEvent event) {
    location = new LocationTag(event.getBlock().getLocation());
    old_material = new MaterialTag(event.getBlock());
    this.event = event;
    fire(event);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) MaterialTag(com.denizenscript.denizen.objects.MaterialTag) EventHandler(org.bukkit.event.EventHandler)

Example 45 with MaterialTag

use of com.denizenscript.denizen.objects.MaterialTag in project Denizen-For-Bukkit by DenizenScript.

the class BlockGrowsScriptEvent method onBlockGrows.

@EventHandler
public void onBlockGrows(BlockGrowEvent event) {
    location = new LocationTag(event.getBlock().getLocation());
    material = new MaterialTag(event.getNewState());
    if (material.isStructure()) {
        return;
    }
    this.event = event;
    fire(event);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) MaterialTag(com.denizenscript.denizen.objects.MaterialTag) EventHandler(org.bukkit.event.EventHandler)

Aggregations

MaterialTag (com.denizenscript.denizen.objects.MaterialTag)51 LocationTag (com.denizenscript.denizen.objects.LocationTag)33 EventHandler (org.bukkit.event.EventHandler)21 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)9 EntityTag (com.denizenscript.denizen.objects.EntityTag)8 Material (org.bukkit.Material)8 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)7 BlockData (org.bukkit.block.data.BlockData)7 DurationTag (com.denizenscript.denizencore.objects.core.DurationTag)6 ListTag (com.denizenscript.denizencore.objects.core.ListTag)6 ItemStack (org.bukkit.inventory.ItemStack)6 List (java.util.List)4 Block (org.bukkit.block.Block)4 PlayerChangesSignScriptEvent (com.denizenscript.denizen.events.player.PlayerChangesSignScriptEvent)3 ItemTag (com.denizenscript.denizen.objects.ItemTag)3 SignChangeEvent (org.bukkit.event.block.SignChangeEvent)3 InvalidArgumentsException (com.denizenscript.denizencore.exceptions.InvalidArgumentsException)2 ScriptEntry (com.denizenscript.denizencore.scripts.ScriptEntry)2 HashSet (java.util.HashSet)2 BlockPos (net.minecraft.core.BlockPos)2