use of com.elmakers.mine.bukkit.api.magic.MageClass in project MagicPlugin by elBukkit.
the class MageCommandExecutor method onTabComplete.
@Override
public Collection<String> onTabComplete(CommandSender sender, String commandName, String[] args) {
List<String> options = new ArrayList<>();
if (args.length == 1) {
addIfPermissible(sender, options, "Magic.commands.mage.", "add");
addIfPermissible(sender, options, "Magic.commands.mage.", "remove");
addIfPermissible(sender, options, "Magic.commands.mage.", "configure");
addIfPermissible(sender, options, "Magic.commands.mage.", "describe");
addIfPermissible(sender, options, "Magic.commands.mage.", "upgrade");
addIfPermissible(sender, options, "Magic.commands.mage.", "getdata");
addIfPermissible(sender, options, "Magic.commands.mage.", "setdata");
addIfPermissible(sender, options, "Magic.commands.mage.", "check");
addIfPermissible(sender, options, "Magic.commands.mage.", "debug");
addIfPermissible(sender, options, "Magic.commands.mage.", "reset");
addIfPermissible(sender, options, "Magic.commands.mage.", "unbind");
addIfPermissible(sender, options, "Magic.commands.mage.", "activate");
addIfPermissible(sender, options, "Magic.commands.mage.", "unlock");
addIfPermissible(sender, options, "Magic.commands.mage.", "lock");
addIfPermissible(sender, options, "Magic.commands.mage.", "levelspells");
addIfPermissible(sender, options, "Magic.commands.mage.", "attribute");
} else if (args.length == 2 && sender.hasPermission("Magic.commands.mage.others")) {
options.addAll(api.getPlayerNames());
}
if (args.length == 3 || args.length == 2) {
CommandSender target = args.length == 2 ? sender : DeprecatedUtils.getPlayer(args[1]);
String subCommand = args[0];
String subCommandPNode = "Magic.commands.mage." + subCommand;
if (subCommand.equalsIgnoreCase("setdata") || subCommand.equalsIgnoreCase("getdata")) {
if (target != null) {
Mage mage = controller.getMage(target);
ConfigurationSection data = mage.getData();
options.addAll(data.getKeys(false));
}
}
if (subCommand.equalsIgnoreCase("add")) {
Collection<SpellTemplate> spellList = api.getSpellTemplates(sender.hasPermission("Magic.bypass_hidden"));
for (SpellTemplate spell : spellList) {
addIfPermissible(sender, options, subCommandPNode, spell.getKey(), true);
}
addIfPermissible(sender, options, subCommandPNode, "brush", true);
}
if (subCommand.equalsIgnoreCase("remove")) {
if (target != null) {
Mage mage = controller.getMage(target);
MageClass mageClass = mage.getActiveClass();
if (mageClass != null) {
options.addAll(mageClass.getSpells());
}
}
options.add("brush");
}
if (subCommand.equalsIgnoreCase("configure") || subCommand.equalsIgnoreCase("describe") || subCommand.equalsIgnoreCase("upgrade")) {
for (String key : BaseMagicProperties.PROPERTY_KEYS) {
options.add(key);
}
for (String protection : api.getController().getDamageTypes()) {
options.add("protection." + protection);
}
}
if (subCommand.equalsIgnoreCase("attribute")) {
for (String attribute : api.getController().getAttributes()) {
options.add(attribute);
}
}
if (subCommand.equalsIgnoreCase("add")) {
Collection<SpellTemplate> spellList = api.getSpellTemplates(sender.hasPermission("Magic.bypass_hidden"));
for (SpellTemplate spell : spellList) {
addIfPermissible(sender, options, subCommandPNode, spell.getKey(), true);
}
addIfPermissible(sender, options, subCommandPNode, "brush", true);
}
if (args[0].equalsIgnoreCase("lock") || args[0].equalsIgnoreCase("unlock") || args[0].equalsIgnoreCase("activate")) {
options.addAll(api.getController().getMageClassKeys());
}
}
return options;
}
use of com.elmakers.mine.bukkit.api.magic.MageClass in project MagicPlugin by elBukkit.
the class MageCommandExecutor method onMageAdd.
public boolean onMageAdd(CommandSender sender, Player player, String[] parameters) {
if (parameters.length < 1) {
sender.sendMessage("Use: /mage add <spell|material> [material:data]");
return true;
}
Mage mage = controller.getMage(player);
MageClass activeClass = mage.getActiveClass();
if (activeClass == null) {
sender.sendMessage("Can't modify player " + player.getName());
return true;
}
String spellName = parameters[0];
if (spellName.equals("material") || spellName.equals("brush")) {
if (parameters.length < 2) {
sender.sendMessage("Use: /mage add brush <material:data>");
return true;
}
String materialKey = parameters[1];
if (!MaterialBrush.isValidMaterial(materialKey, false)) {
sender.sendMessage(materialKey + " is not a valid brush");
return true;
}
if (activeClass.addBrush(materialKey)) {
if (sender != player) {
sender.sendMessage("Added brush '" + materialKey + "' to " + player.getName());
} else {
sender.sendMessage(api.getMessages().get("mage.brush_added").replace("$name", materialKey));
}
}
return true;
}
Spell spell = mage.getSpell(spellName);
if (spell == null) {
sender.sendMessage("Spell '" + spellName + "' unknown, Use /spells for spell list");
return true;
}
SpellTemplate currentSpell = activeClass.getSpellTemplate(spellName);
if (activeClass.addSpell(spellName)) {
if (currentSpell != null) {
String levelDescription = spell.getLevelDescription();
if (levelDescription == null || levelDescription.isEmpty()) {
levelDescription = spell.getName();
}
if (sender != player) {
sender.sendMessage(api.getMessages().get("mage.player_spell_upgraded").replace("$player", player.getName()).replace("$name", currentSpell.getName()).replace("$level", levelDescription));
}
} else {
if (sender != player) {
sender.sendMessage("Added '" + spell.getName() + "' to " + player.getName());
}
}
} else if (sender != player) {
sender.sendMessage("Could not add " + spellName + " to " + player.getName());
}
return true;
}
use of com.elmakers.mine.bukkit.api.magic.MageClass in project MagicPlugin by elBukkit.
the class MageCommandExecutor method onMageLevelSpells.
public boolean onMageLevelSpells(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;
}
}
Mage mage = controller.getMage(player);
MageClass activeClass = mage.getActiveClass();
return onLevelSpells("mage", sender, player, activeClass == null ? mage.getProperties() : activeClass, maxLevel);
}
use of com.elmakers.mine.bukkit.api.magic.MageClass in project MagicPlugin by elBukkit.
the class CondHasPath method check.
@Override
public boolean check(final Event e) {
return entities.check(e, new Checker<Entity>() {
@Override
public boolean check(final Entity entity) {
final Mage mage = MagicPlugin.getAPI().getController().getRegisteredMage(entity);
if (mage == null) {
return false;
}
return paths.check(e, new Checker<String>() {
@Override
public boolean check(final String pathKey) {
Wand wand = mage.getActiveWand();
if (checkPath(wand, pathKey)) {
return true;
}
MageClass activeClass = mage.getActiveClass();
if (checkPath(activeClass, pathKey)) {
return true;
}
return false;
}
}, isNegated());
}
});
}
use of com.elmakers.mine.bukkit.api.magic.MageClass in project MagicPlugin by elBukkit.
the class PlaceholderAPIManager method onPlaceholderRequest.
@Override
public String onPlaceholderRequest(Player player, String placeholder) {
Mage mage = controller.getMage(player);
MageClass activeClass = mage.getActiveClass();
Wand wand = mage.getActiveWand();
Spell spell = wand == null ? null : wand.getActiveSpell();
if (spell == null) {
ItemStack item = player.getInventory().getItemInMainHand();
String spellKey = controller.getSpell(item);
if (spellKey != null) {
spell = mage.getSpell(spellKey);
}
}
if (spell == null) {
ItemStack item = player.getInventory().getItemInOffHand();
String spellKey = controller.getSpell(item);
if (spellKey != null) {
spell = mage.getSpell(spellKey);
}
}
CasterProperties casterProperties = mage.getActiveProperties();
switch(placeholder) {
case "path":
ProgressionPath path = casterProperties.getPath();
return path == null ? "" : path.getName();
case "class":
return activeClass == null ? "" : activeClass.getName();
case "wand":
return wand == null ? "" : wand.getName();
case "spell":
return spell == null ? "" : spell.getName();
}
return "";
}
Aggregations