use of org.bukkit.block.Block in project Denizen-For-Bukkit by DenizenScript.
the class EntityExplodesScriptEvent method onEntityExplodes.
@EventHandler
public void onEntityExplodes(EntityExplodeEvent event) {
entity = new dEntity(event.getEntity());
location = new dLocation(event.getLocation());
strength = event.getYield();
blocks = new dList();
blockSet = false;
for (Block block : event.blockList()) {
blocks.add(new dLocation(block.getLocation()).identifySimple());
}
cancelled = event.isCancelled();
this.event = event;
fire();
event.setCancelled(cancelled);
if (blockSet) {
event.blockList().clear();
if (blocks.size() > 0) {
event.blockList().clear();
for (String loc : blocks) {
dLocation location = dLocation.valueOf(loc);
event.blockList().add(location.getWorld().getBlockAt(location));
}
}
}
event.setYield(strength);
}
use of org.bukkit.block.Block in project Towny by ElgarL.
the class CellUnderAttack method destroyFlag.
public void destroyFlag() {
flagLightBlock.setType(Material.AIR);
flagBlock.setType(Material.AIR);
flagBaseBlock.setType(Material.AIR);
for (Block block : beaconFlagBlocks) block.setType(Material.AIR);
for (Block block : beaconWireframeBlocks) block.setType(Material.AIR);
}
use of org.bukkit.block.Block in project Towny by ElgarL.
the class CellUnderAttack method updateFlag.
@SuppressWarnings("deprecation")
public void updateFlag() {
DyeColor[] woolColors = TownyWarConfig.getWoolColors();
if (flagColorId < woolColors.length) {
System.out.println(String.format("Flag at %s turned %s.", getCellString(), woolColors[flagColorId].toString()));
int woolId = BukkitTools.getMaterialId(Material.WOOL);
byte woolData = woolColors[flagColorId].getDyeData();
BukkitTools.setTypeIdAndData(flagBlock, woolId, woolData, true);
for (Block block : beaconFlagBlocks) BukkitTools.setTypeIdAndData(block, woolId, woolData, true);
}
}
use of org.bukkit.block.Block in project Denizen-For-Bukkit by DenizenScript.
the class ProjectileHitsScriptEvent method onProjectileHits.
@EventHandler
public void onProjectileHits(ProjectileHitEvent event) {
projectile = new dEntity(event.getEntity());
if (projectile.getLocation() == null) {
// No, I can't explain how or why this would ever happen... nonetheless, it appears it does happen sometimes.
return;
}
if (Double.isNaN(projectile.getLocation().getDirection().normalize().getX())) {
// I can't explain this one either. It also chooses to happen whenever it pleases.
return;
}
Block block = null;
try {
BlockIterator bi = new BlockIterator(projectile.getLocation().getWorld(), projectile.getLocation().toVector(), projectile.getLocation().getDirection().normalize(), 0, 4);
while (bi.hasNext()) {
block = bi.next();
if (block.getTypeId() != 0) {
break;
}
}
} catch (IllegalStateException ex) {
// As this error happens on no fault of the user, display no error message... just cancel the event.
return;
}
if (block == null) {
return;
}
material = dMaterial.getMaterialFrom(block.getType(), block.getData());
shooter = projectile.getShooter();
location = new dLocation(block.getLocation());
this.event = event;
fire();
}
use of org.bukkit.block.Block in project Denizen-For-Bukkit by DenizenScript.
the class PortalCreateScriptEvent method onPortalCreate.
@EventHandler
public void onPortalCreate(PortalCreateEvent event) {
world = new dWorld(event.getWorld());
reason = new Element(event.getReason().toString());
blocks = new dList();
for (Block block : event.getBlocks()) {
blocks.add(new dLocation(block.getLocation()).identify());
}
this.event = event;
cancelled = event.isCancelled();
fire();
event.setCancelled(cancelled);
}
Aggregations