use of com.elmakers.mine.bukkit.api.magic.MaterialSet in project MagicPlugin by elBukkit.
the class BlockSpell method addDestructible.
protected void addDestructible(MaterialAndData material) {
MaterialSet current = getDestructible();
destructible = MaterialSets.union(current, material);
}
use of com.elmakers.mine.bukkit.api.magic.MaterialSet in project MagicPlugin by elBukkit.
the class BlockController method onBlockFromTo.
@EventHandler
public void onBlockFromTo(BlockFromToEvent event) {
Block targetBlock = event.getToBlock();
Block sourceBlock = event.getBlock();
UndoList undoList = controller.getPendingUndo(sourceBlock.getLocation());
if (undoList != null) {
undoList.add(targetBlock);
} else {
undoList = controller.getPendingUndo(targetBlock.getLocation());
if (undoList != null) {
undoList.add(targetBlock);
}
}
if (undoList != null && undoList.isScheduled()) {
// Avoid dropping broken items!
MaterialSet doubles = com.elmakers.mine.bukkit.block.UndoList.attachablesDouble;
if (doubles.testBlock(targetBlock)) {
Block upBlock = targetBlock.getRelative(BlockFace.UP);
while (doubles.testBlock(upBlock)) {
undoList.add(upBlock);
DeprecatedUtils.setTypeIdAndData(upBlock, Material.AIR.ordinal(), (byte) 0, false);
upBlock = upBlock.getRelative(BlockFace.UP);
}
Block downBlock = targetBlock.getRelative(BlockFace.DOWN);
while (doubles.testBlock(downBlock)) {
undoList.add(downBlock);
DeprecatedUtils.setTypeIdAndData(downBlock, Material.AIR.ordinal(), (byte) 0, false);
downBlock = downBlock.getRelative(BlockFace.DOWN);
}
}
DeprecatedUtils.setTypeIdAndData(targetBlock, Material.AIR.ordinal(), (byte) 0, false);
event.setCancelled(true);
}
}
use of com.elmakers.mine.bukkit.api.magic.MaterialSet in project MagicPlugin by elBukkit.
the class DropSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Block target = getTargetBlock();
if (target == null) {
return SpellResult.NO_TARGET;
}
MaterialSet dropMaterials = controller.getMaterialSetManager().fromConfigEmpty(parameters.getString("drop"));
if (!dropMaterials.testBlock(target)) {
return SpellResult.NO_TARGET;
}
if (!hasBreakPermission(target)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
Collection<ItemStack> drops = new ArrayList<>();
int maxRecursion = parameters.getInt("recursion_depth", DEFAULT_MAX_RECURSION);
dropCount = parameters.getInt("drop_count", -1);
falling = parameters.getBoolean("falling", true);
diagonals = parameters.getBoolean("diagonals", true);
drop(target, dropMaterials, drops, maxRecursion);
for (ItemStack drop : drops) {
target.getWorld().dropItemNaturally(target.getLocation(), drop);
}
// Make this undoable.. even though it means you can exploit it for ore with Rewind. Meh!
registerForUndo();
return SpellResult.CAST;
}
Aggregations