Search in sources :

Example 11 with MaterialTag

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

the class PlayerFillsBucketScriptEvent method onBucketFill.

@EventHandler
public void onBucketFill(PlayerBucketFillEvent event) {
    entity = new EntityTag(event.getPlayer());
    location = new LocationTag(event.getBlockClicked().getLocation());
    item = new ItemTag(event.getItemStack());
    material = new MaterialTag(event.getBlockClicked());
    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) ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

Example 12 with MaterialTag

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

the class VehicleCollidesBlockScriptEvent method onVehicleCollidesBlock.

@EventHandler
public void onVehicleCollidesBlock(VehicleBlockCollisionEvent event) {
    vehicle = new EntityTag(event.getVehicle());
    location = new LocationTag(event.getBlock().getLocation());
    material = new MaterialTag(event.getBlock());
    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 13 with MaterialTag

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

the class PlayerStandsOnScriptEvent method playerStandsOn.

@EventHandler
public void playerStandsOn(PlayerInteractEvent event) {
    if (event.getAction() != Action.PHYSICAL) {
        return;
    }
    material = new MaterialTag(event.getClickedBlock());
    location = new LocationTag(event.getClickedBlock().getLocation());
    this.event = event;
    fire(event);
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) LocationTag(com.denizenscript.denizen.objects.LocationTag) EventHandler(org.bukkit.event.EventHandler)

Example 14 with MaterialTag

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

the class ItemCanDestroy method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("can_destroy")) {
        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_DESTROY, materials);
        } else {
            itemStack = CustomNBT.clearNBT(itemStack, CustomNBT.KEY_CAN_DESTROY);
        }
        item.setItemStack(itemStack);
    }
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack)

Example 15 with MaterialTag

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

the class ItemCanPlaceOn method getMaterials.

private ListTag getMaterials() {
    ItemStack itemStack = item.getItemStack();
    List<Material> materials = CustomNBT.getNBTMaterials(itemStack, CustomNBT.KEY_CAN_PLACE_ON);
    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)

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