Search in sources :

Example 21 with BlockData

use of org.bukkit.block.data.BlockData in project Minigames by AddstarMC.

the class PulseRedstoneAction method executeNodeAction.

@Override
public void executeNodeAction(MinigamePlayer player, Node node) {
    debug(player, node);
    BlockData bdata = Material.REDSTONE_BLOCK.createBlockData();
    if (torch.getFlag()) {
        bdata = Material.REDSTONE_TORCH.createBlockData();
        if (bdata instanceof Lightable)
            ((Lightable) bdata).setLit(true);
    }
    final BlockState last = node.getLocation().getBlock().getState();
    node.getLocation().getBlock().setBlockData(bdata);
    Bukkit.getScheduler().scheduleSyncDelayedTask(Minigames.getPlugin(), () -> last.update(true), 20 * time.getFlag());
}
Also used : BlockState(org.bukkit.block.BlockState) Lightable(org.bukkit.block.data.Lightable) BlockData(org.bukkit.block.data.BlockData)

Example 22 with BlockData

use of org.bukkit.block.data.BlockData in project Minigames by AddstarMC.

the class MatchBlockCondition method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
    Menu m = new Menu(3, "Match Block", player);
    m.addItem(new MenuItemPage("Back", MenuUtility.getBackMaterial(), prev), m.getSize() - 9);
    final MenuItemCustom c = new MenuItemCustom("Auto Set Block", MinigameUtils.stringToList("Click here with a;block you wish to;match to."), Material.ITEM_FRAME);
    m.addItem(c, m.getSize() - 1);
    final MinigamePlayer ply = m.getViewer();
    final MenuItemBlockData btype = new MenuItemBlockData("Block Type", Material.STONE, new Callback<BlockData>() {

        @Override
        public void setValue(BlockData value) {
            type.setFlag(value);
        }

        @Override
        public BlockData getValue() {
            return type.getFlag();
        }
    });
    m.addItem(btype);
    final MenuItemBoolean busedur = (MenuItemBoolean) useBlockData.getMenuItem("Use Data Values", Material.ENDER_PEARL);
    m.addItem(busedur);
    c.setClickItem(object -> {
        ItemStack i = (ItemStack) object;
        try {
            type.setFlag(i.getType().createBlockData());
            useBlockData.setFlag(true);
        } catch (IllegalArgumentException e) {
            c.getContainer().getViewer().sendMessage("That item is not a block", MinigameMessageType.ERROR);
        }
        useBlockData.setFlag(true);
        busedur.updateDescription();
        btype.update();
        return c.getItem();
    });
    addInvertMenuItem(m);
    m.displayMenu(player);
    return true;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) BlockData(org.bukkit.block.data.BlockData) ItemStack(org.bukkit.inventory.ItemStack)

Example 23 with BlockData

use of org.bukkit.block.data.BlockData in project Denizen-For-Bukkit by DenizenScript.

the class MaterialCount method describes.

public static boolean describes(ObjectTag material) {
    if (!(material instanceof MaterialTag)) {
        return false;
    }
    MaterialTag mat = (MaterialTag) material;
    if (!mat.hasModernData()) {
        return false;
    }
    BlockData data = mat.getModernData();
    return data instanceof SeaPickle || data instanceof TurtleEgg || data instanceof RespawnAnchor || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && data instanceof Candle);
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) Candle(org.bukkit.block.data.type.Candle) SeaPickle(org.bukkit.block.data.type.SeaPickle) RespawnAnchor(org.bukkit.block.data.type.RespawnAnchor) BlockData(org.bukkit.block.data.BlockData) TurtleEgg(org.bukkit.block.data.type.TurtleEgg)

Example 24 with BlockData

use of org.bukkit.block.data.BlockData in project Denizen-For-Bukkit by DenizenScript.

the class MaterialBlockType method describes.

public static boolean describes(ObjectTag material) {
    if (!(material instanceof MaterialTag)) {
        return false;
    }
    MaterialTag mat = (MaterialTag) material;
    if (!mat.hasModernData()) {
        return false;
    }
    BlockData data = mat.getModernData();
    return data instanceof Slab || data instanceof TechnicalPiston || data instanceof Campfire || data instanceof Scaffolding || (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17) && (data instanceof PointedDripstone || data instanceof CaveVinesPlant));
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) BlockData(org.bukkit.block.data.BlockData)

Example 25 with BlockData

use of org.bukkit.block.data.BlockData in project Denizen-For-Bukkit by DenizenScript.

the class MaterialLevel method describes.

public static boolean describes(ObjectTag material) {
    if (!(material instanceof MaterialTag)) {
        return false;
    }
    MaterialTag mat = (MaterialTag) material;
    if (!mat.hasModernData()) {
        return false;
    }
    BlockData data = mat.getModernData();
    return data instanceof Levelled || data instanceof Cake || data instanceof Snow || data instanceof Farmland || data instanceof Beehive;
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) Snow(org.bukkit.block.data.type.Snow) Beehive(org.bukkit.block.data.type.Beehive) Cake(org.bukkit.block.data.type.Cake) Farmland(org.bukkit.block.data.type.Farmland) Levelled(org.bukkit.block.data.Levelled) BlockData(org.bukkit.block.data.BlockData)

Aggregations

BlockData (org.bukkit.block.data.BlockData)34 Block (org.bukkit.block.Block)10 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)8 Location (org.bukkit.Location)7 MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)3 ArrayList (java.util.ArrayList)3 Material (org.bukkit.Material)3 BlockState (org.bukkit.block.BlockState)3 Lightable (org.bukkit.block.data.Lightable)3 ItemStack (org.bukkit.inventory.ItemStack)3 LocationTag (com.denizenscript.denizen.objects.LocationTag)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 MaterialState (me.botsko.prism.api.objects.MaterialState)2 BlockStateChangeImpl (me.botsko.prism.events.BlockStateChangeImpl)2 Bisected (org.bukkit.block.data.Bisected)2 Bed (org.bukkit.block.data.type.Bed)2 Player (org.bukkit.entity.Player)2