use of com.elmakers.mine.bukkit.api.magic.MageController in project MagicPlugin by elBukkit.
the class DeactivateAction method perform.
@Override
public SpellResult perform(CastContext context) {
Entity targetEntity = context.getTargetEntity();
MageController controller = context.getController();
Mage targetMage = targetEntity != null && controller.isMage(targetEntity) ? controller.getMage(targetEntity) : null;
if (targetMage == null) {
return SpellResult.NO_TARGET;
}
targetMage.deactivateAllSpells(true, false);
return SpellResult.CAST;
}
use of com.elmakers.mine.bukkit.api.magic.MageController in project MagicPlugin by elBukkit.
the class MountArmorStandAction method prepare.
@Override
public void prepare(CastContext context, ConfigurationSection parameters) {
super.prepare(context, parameters);
mountTarget = parameters.getBoolean("mount_target", false);
armorStandInvisible = parameters.getBoolean("armor_stand_invisible", true);
armorStandSmall = parameters.getBoolean("armor_stand_small", false);
armorStandMarker = parameters.getBoolean("armor_stand_marker", true);
armorStandGravity = parameters.getBoolean("armor_stand_gravity", true);
armorStandPitch = parameters.getDouble("armor_stand_pitch", 0.0);
armorStandRoll = parameters.getDouble("armor_stand_roll", 0.0);
mountWand = parameters.getBoolean("mount_wand", false);
mountName = parameters.getString("mount_name", null);
if (parameters.contains("armor_stand_reason")) {
String reasonText = parameters.getString("armor_stand_reason").toUpperCase();
try {
armorStandSpawnReason = CreatureSpawnEvent.SpawnReason.valueOf(reasonText);
} catch (Exception ex) {
context.getMage().sendMessage("Unknown spawn reason: " + reasonText);
}
}
MageController controller = context.getController();
ItemData itemType = controller.getOrCreateItem(parameters.getString("helmet_item"));
if (itemType != null) {
helmetItem = itemType.getItemStack(1);
if (helmetItem != null) {
InventoryUtils.makeUnbreakable(InventoryUtils.makeReal(helmetItem));
}
}
}
use of com.elmakers.mine.bukkit.api.magic.MageController in project MagicPlugin by elBukkit.
the class DropItemAction method prepare.
@Override
public void prepare(CastContext context, ConfigurationSection parameters) {
super.prepare(context, parameters);
MageController controller = context.getController();
String itemKey = parameters.getString("item");
item = controller.createItem(itemKey);
if (item == null) {
context.getLogger().warning("Invalid item: " + itemKey);
}
}
use of com.elmakers.mine.bukkit.api.magic.MageController in project MagicPlugin by elBukkit.
the class EnchantWandAction method perform.
@Override
public SpellResult perform(CastContext context) {
Mage mage = context.getMage();
Wand wand = context.getWand();
Player player = mage.getPlayer();
if (player == null) {
return SpellResult.PLAYER_REQUIRED;
}
if (levels <= 0) {
return SpellResult.FAIL;
}
if (wand == null) {
context.showMessage("no_wand", "You must be holding a wand!");
return SpellResult.FAIL;
}
if (requiredPath != null || exactPath != null) {
WandUpgradePath path = wand.getPath();
if (path == null) {
context.showMessage(context.getMessage("no_upgrade", "You may not learn with that $wand.").replace("$wand", wand.getName()));
return SpellResult.FAIL;
}
if ((requiredPath != null && !path.hasPath(requiredPath)) || (exactPath != null && !exactPath.equals(path.getKey()))) {
WandUpgradePath requiresPath = com.elmakers.mine.bukkit.wand.WandUpgradePath.getPath(requiredPath);
if (requiresPath != null) {
context.showMessage(context.getMessage("no_path", "You may not learn with that $wand.").replace("$path", requiresPath.getName()));
} else {
context.getLogger().warning("Invalid path specified in EnchantWand action: " + requiredPath);
}
return SpellResult.FAIL;
}
}
if (requireItem != null) {
MageController controller = context.getController();
boolean foundItem = false;
ItemStack[] contents = player.getInventory().getContents();
for (int i = 0; i < contents.length; i++) {
ItemStack item = contents[i];
if (controller.itemsAreEqual(item, requireItem)) {
player.getInventory().setItem(i, null);
foundItem = true;
break;
}
}
if (!foundItem) {
context.showMessage("insufficient_resources", "You must have a $requires");
return SpellResult.INSUFFICIENT_RESOURCES;
}
}
int xpLevels = levels;
if (useXp) {
xpLevels = mage.getLevel();
}
int levelsUsed = wand.enchant(xpLevels, mage);
if (levelsUsed == 0) {
return SpellResult.FAIL;
}
if (useXp) {
mage.setLevel(Math.max(0, mage.getLevel() - levelsUsed));
}
return SpellResult.CAST;
}
use of com.elmakers.mine.bukkit.api.magic.MageController in project MagicPlugin by elBukkit.
the class EnchantWandAction method prepare.
@Override
public void prepare(CastContext context, ConfigurationSection parameters) {
super.prepare(context, parameters);
levels = parameters.getInt("levels", 1);
useXp = parameters.getBoolean("use_xp", false);
requiredPath = parameters.getString("path", null);
exactPath = parameters.getString("path_exact", null);
String costKey = parameters.getString("requires");
if (costKey != null && !costKey.isEmpty()) {
MageController controller = context.getController();
requireItem = controller.createItem(costKey);
if (requireItem == null) {
context.getLogger().warning("Invalid required item: " + costKey);
}
}
}
Aggregations