use of com.elmakers.mine.bukkit.block.MaterialAndData in project MagicPlugin by elBukkit.
the class DisintegrateSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Target target = getTarget();
int playerDamage = parameters.getInt("player_damage", DEFAULT_PLAYER_DAMAGE);
int entityDamage = parameters.getInt("entity_damage", DEFAULT_ENTITY_DAMAGE);
if (target.hasEntity()) {
Entity targetEntity = target.getEntity();
if (controller.isElemental(targetEntity)) {
int elementalDamage = parameters.getInt("elemental_damage", DEFAULT_ENTITY_DAMAGE);
controller.damageElemental(targetEntity, elementalDamage, 0, mage.getCommandSender());
return SpellResult.CAST;
} else {
registerModified(targetEntity);
if (targetEntity instanceof Player) {
Player player = (Player) targetEntity;
CompatibilityUtils.magicDamage(player, mage.getDamageMultiplier() * playerDamage, mage.getEntity());
} else if (targetEntity instanceof LivingEntity) {
LivingEntity li = (LivingEntity) targetEntity;
CompatibilityUtils.magicDamage(li, mage.getDamageMultiplier() * entityDamage, mage.getEntity());
} else {
targetEntity.remove();
}
registerForUndo();
return SpellResult.CAST;
}
}
if (!target.hasTarget()) {
return SpellResult.NO_TARGET;
}
Block targetBlock = target.getBlock();
if (!hasBreakPermission(targetBlock)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
if (!isDestructible(targetBlock)) {
return SpellResult.NO_TARGET;
}
registerForUndo(targetBlock);
// This makes $target messaging work properly, otherwise
// it always displays air or water
MaterialAndData targetMaterial = new MaterialAndData(targetBlock);
getCurrentCast().setTargetName(targetMaterial.getName());
if (isUnderwater()) {
targetBlock.setType(Material.STATIONARY_WATER);
} else {
targetBlock.setType(Material.AIR);
}
registerForUndo();
return SpellResult.CAST;
}
use of com.elmakers.mine.bukkit.block.MaterialAndData in project MagicPlugin by elBukkit.
the class FlingSpell method getEffectMaterial.
@Override
public com.elmakers.mine.bukkit.api.block.MaterialAndData getEffectMaterial() {
Block block = mage.getEntity().getLocation().getBlock();
block = block.getRelative(BlockFace.DOWN);
return new MaterialAndData(block);
}
Aggregations