use of org.bukkit.block.Block in project Minigames by AddstarMC.
the class ScoreboardDisplay method updateSigns.
/**
* Updates all signs with the current values of the stats
*/
public void updateSigns() {
settings = minigame.getSettings(stat);
placeRootSign();
List<Block> signs = getSignBlocks(true);
int nextIndex = 0;
for (Block sign : signs) {
if (nextIndex <= stats.size() - 2) {
updateSign(sign, nextIndex + 1, stats.get(nextIndex++), stats.get(nextIndex++));
} else if (nextIndex <= stats.size() - 1) {
updateSign(sign, nextIndex + 1, stats.get(nextIndex++));
} else {
clearSign(sign);
}
}
}
use of org.bukkit.block.Block in project Minigames by AddstarMC.
the class ScoreboardDisplay method placeRootSign.
public void placeRootSign() {
// For external calls
if (settings == null) {
settings = minigame.getSettings(stat);
}
Block root = rootBlock.getBlock();
Sign sign = (Sign) root.getState();
sign.setLine(0, ChatColor.BLUE + minigame.getName(true));
sign.setLine(1, ChatColor.GREEN + settings.getDisplayName());
sign.setLine(2, ChatColor.GREEN + field.getTitle());
sign.setLine(3, "(" + WordUtils.capitalize(order.toString()) + ")");
sign.update();
sign.setMetadata("MGScoreboardSign", new FixedMetadataValue(Minigames.plugin, true));
sign.setMetadata("Minigame", new FixedMetadataValue(Minigames.plugin, minigame));
}
use of org.bukkit.block.Block in project Minigames by AddstarMC.
the class TreasureHuntMechanic method interactEvent.
@EventHandler
private void interactEvent(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block cblock = event.getClickedBlock();
if (cblock.getState() instanceof Chest && !event.isCancelled()) {
for (Minigame minigame : mdata.getAllMinigames().values()) {
if (minigame.getType() == MinigameType.GLOBAL && minigame.getMechanicName().equalsIgnoreCase(getMechanic()) && minigame.getMinigameTimer() != null) {
TreasureHuntModule thm = TreasureHuntModule.getMinigameModule(minigame);
if (!thm.isTreasureFound() && thm.hasTreasureLocation()) {
int x1 = thm.getTreasureLocation().getBlockX();
int x2 = cblock.getLocation().getBlockX();
int y1 = thm.getTreasureLocation().getBlockY();
int y2 = cblock.getLocation().getBlockY();
int z1 = thm.getTreasureLocation().getBlockZ();
int z2 = cblock.getLocation().getBlockZ();
if (x2 == x1 && y2 == y1 && z2 == z1) {
MinigameUtils.broadcast(MinigameUtils.formStr("minigame.treasurehunt.plyFound", event.getPlayer().getDisplayName(), minigame.getName(true)), minigame, "minigame.treasure.announce");
event.setCancelled(true);
Chest chest = (Chest) cblock.getState();
event.getPlayer().openInventory(chest.getInventory());
thm.setTreasureFound(true);
minigame.getMinigameTimer().setTimeLeft(300);
}
}
}
}
}
}
}
use of org.bukkit.block.Block in project Minigames by AddstarMC.
the class SwapBlockAction method executeRegionAction.
@SuppressWarnings("deprecation")
@Override
public void executeRegionAction(MinigamePlayer player, Region region) {
for (int y = region.getFirstPoint().getBlockY(); y <= region.getSecondPoint().getBlockY(); y++) {
for (int x = region.getFirstPoint().getBlockX(); x <= region.getSecondPoint().getBlockX(); x++) {
for (int z = region.getFirstPoint().getBlockZ(); z <= region.getSecondPoint().getBlockZ(); z++) {
Block block = region.getFirstPoint().getWorld().getBlockAt(x, y, z);
if (block.getType() == Material.getMaterial(matchType.getFlag())) {
if (matchData.getFlag() && block.getData() != matchDataValue.getFlag().byteValue()) {
continue;
}
// Block matches, now replace it
byte data = 0;
BlockFace facing = null;
if (toData.getFlag()) {
// Replace data
data = toDataValue.getFlag().byteValue();
} else if (keepAttachment.getFlag()) {
// Keep attachments if possible
MaterialData mat = block.getState().getData();
if (mat instanceof Directional) {
facing = ((Directional) mat).getFacing();
}
}
// Update block type
block.setType(Material.getMaterial(toType.getFlag()), false);
if (facing != null) {
BlockState state = block.getState();
MaterialData mat = block.getState().getData();
if (mat instanceof Directional) {
((Directional) mat).setFacingDirection(facing);
}
state.setData(mat);
state.update(true, false);
} else {
block.setData(data, false);
}
}
}
}
}
}
use of org.bukkit.block.Block in project Towny by ElgarL.
the class BlockWorker method buildBlock.
public void buildBlock(BlockWork blockWork) {
Block block = blockWork.getWorld().getBlockAt(blockWork.getX(), blockWork.getY(), blockWork.getZ());
if (blockWork.getId() == BukkitTools.getTypeId(block))
return;
// TODO: Set block
BukkitTools.setTypeIdAndData(block, blockWork.getId(), blockWork.getData(), true);
}
Aggregations