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());
}
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;
}
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);
}
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));
}
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;
}
Aggregations