use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.
the class WandCommandExecutor method onWandEnchant.
public boolean onWandEnchant(CommandSender sender, Player player, String levelString) {
Wand wand = checkWand(sender, player);
if (wand == null) {
return false;
}
Mage mage = controller.getMage(player);
int xpLevels = 0;
boolean useXp = levelString.equalsIgnoreCase("xp");
if (useXp) {
xpLevels = mage.getLevel();
} else {
try {
xpLevels = Integer.parseInt(levelString);
} catch (Exception ex) {
sender.sendMessage("Invalid parameter: " + levelString);
}
}
int levels = wand.enchant(xpLevels);
if (levels > 0 && useXp) {
mage.setLevel(Math.max(0, mage.getLevel() - levels));
}
wand.saveState();
if (sender != player) {
if (levels > 0) {
sender.sendMessage(api.getMessages().getParameterized("wand.player_upgraded", "$name", player.getName()));
} else {
sender.sendMessage(api.getMessages().getParameterized("wand.player_not_upgraded", "$name", player.getName()));
}
}
return true;
}
use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.
the class WandCommandExecutor method onWandCombine.
public boolean onWandCombine(CommandSender sender, Player player, String[] parameters) {
if (parameters.length < 1) {
sender.sendMessage("Use: /wand combine <wandname>");
return false;
}
Wand wand = checkWand(sender, player);
if (wand == null) {
return true;
}
Mage mage = controller.getMage(player);
String wandName = parameters[0];
Wand newWand = api.createWand(wandName);
if (newWand == null) {
sender.sendMessage(api.getMessages().getParameterized("wand.unknown_template", "$name", wandName));
return false;
}
wand.deactivate();
boolean result = wand.add(newWand);
mage.checkWand();
if (sender != player) {
if (result) {
sender.sendMessage(api.getMessages().getParameterized("wand.player_upgraded", "$name", player.getName()));
} else {
sender.sendMessage(api.getMessages().getParameterized("wand.player_not_upgraded", "$name", player.getName()));
}
}
return true;
}
use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.
the class WandCommandExecutor method onWandOverride.
public boolean onWandOverride(CommandSender sender, Player player, String[] parameters) {
Wand wand = checkWand(sender, player, true, true, false);
if (wand == null) {
return true;
}
if (parameters.length == 0) {
Map<String, String> overrides = wand.getOverrides();
if (overrides.size() == 0) {
sender.sendMessage(ChatColor.DARK_AQUA + "This wand has no overrides");
} else {
for (Map.Entry<String, String> override : overrides.entrySet()) {
sender.sendMessage(ChatColor.AQUA + override.getKey() + ChatColor.WHITE + " = " + ChatColor.DARK_AQUA + override.getValue());
}
}
return true;
}
wand = checkWand(sender, player);
if (wand == null) {
return true;
}
if (parameters.length == 1) {
wand.removeOverride(parameters[0]);
wand.saveState();
sender.sendMessage(ChatColor.DARK_AQUA + "Removed override " + parameters[0]);
return true;
}
String value = "";
for (int i = 1; i < parameters.length; i++) {
if (i != 1)
value = value + " ";
value = value + parameters[i];
}
wand.setOverride(parameters[0], value);
wand.saveState();
sender.sendMessage(ChatColor.DARK_AQUA + "Added override " + ChatColor.AQUA + parameters[0] + ChatColor.WHITE + " = " + ChatColor.DARK_AQUA + parameters[1]);
return true;
}
use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.
the class WandCommandExecutor method onWandLevelSpells.
public boolean onWandLevelSpells(CommandSender sender, Player player, String[] parameters) {
Integer maxLevel = null;
if (parameters.length > 0) {
try {
maxLevel = Integer.parseInt(parameters[0]);
} catch (Exception ex) {
sender.sendMessage("Usage: /wand levelspells <level>");
return true;
}
}
Wand wand = checkWand(sender, player);
if (wand == null) {
return true;
}
return onLevelSpells("wand", sender, player, wand, maxLevel);
}
use of com.elmakers.mine.bukkit.api.wand.Wand in project MagicPlugin by elBukkit.
the class WandCommandExecutor method onWandOrganize.
public boolean onWandOrganize(CommandSender sender, Player player) {
// Allow reorganizing modifiable wands
Wand wand = checkWand(sender, player, true);
if (wand == null) {
return true;
}
Mage mage = controller.getMage(player);
wand.organizeInventory(mage);
wand.saveState();
mage.sendMessage(api.getMessages().get("wand.reorganized").replace("$wand", wand.getName()));
if (sender != player) {
sender.sendMessage(api.getMessages().getParameterized("wand.player_reorganized", "$name", player.getName()).replace("$wand", wand.getName()));
}
return true;
}
Aggregations