use of com.elmakers.mine.bukkit.api.magic.Mage in project MagicPlugin by elBukkit.
the class MageCommandExecutor method onMageLock.
public boolean onMageLock(CommandSender sender, Player player, String[] parameters) {
if (parameters.length < 1) {
sender.sendMessage(ChatColor.RED + "Usage: " + ChatColor.WHITE + "/mage lock [player] <class>");
return true;
}
Mage mage = controller.getMage(player);
String classKey = parameters[0];
boolean locked = mage.lockClass(classKey);
if (!locked) {
sender.sendMessage(ChatColor.RED + "No unlocked class: " + ChatColor.WHITE + classKey + ChatColor.RED + " for " + ChatColor.WHITE + player.getName());
} else {
sender.sendMessage("Locked class " + classKey + " for " + player.getName());
}
return true;
}
use of com.elmakers.mine.bukkit.api.magic.Mage in project MagicPlugin by elBukkit.
the class MageCommandExecutor method onMageGetData.
public boolean onMageGetData(CommandSender sender, Player player, String[] args) {
Mage mage = controller.getMage(player);
ConfigurationSection data = mage.getData();
if (args != null && args.length > 0) {
if (args[0].equals("*")) {
sender.sendMessage(ChatColor.GOLD + "Mage data for " + ChatColor.AQUA + player.getDisplayName() + ChatColor.GOLD + ": ");
Collection<Spell> spells = mage.getSpells();
if (spells.size() == 0) {
sender.sendMessage(ChatColor.RED + "No spell casts!");
return true;
}
for (Spell spell : spells) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + spell.getName() + ChatColor.AQUA + " Cast Count: " + ChatColor.GOLD + spell.getCastCount());
}
return true;
}
Spell spell = mage.getSpell(args[0]);
if (spell != null) {
sender.sendMessage(ChatColor.GOLD + "Mage data for " + ChatColor.AQUA + player.getDisplayName() + ChatColor.GOLD + ": " + ChatColor.LIGHT_PURPLE + spell.getName());
sender.sendMessage(ChatColor.AQUA + " Cast Count: " + ChatColor.GOLD + spell.getCastCount());
return true;
}
ConfigurationSection subSection = data.getConfigurationSection(args[0]);
if (subSection == null) {
sender.sendMessage(ChatColor.RED + "Unknown subsection or spell: " + args[0]);
return true;
}
data = subSection;
}
Collection<String> keys = data.getKeys(false);
sender.sendMessage(ChatColor.GOLD + "Mage data for " + ChatColor.AQUA + player.getDisplayName());
for (String key : keys) {
if (data.isConfigurationSection(key)) {
ConfigurationSection subSection = data.getConfigurationSection(key);
sender.sendMessage(ChatColor.AQUA + " " + key + ChatColor.DARK_AQUA + " (" + subSection.getKeys(true).size() + " items)");
} else {
String value = data.getString(key);
if (value != null) {
sender.sendMessage(ChatColor.AQUA + " " + key + ChatColor.DARK_AQUA + " (" + value + ")");
} else {
sender.sendMessage(ChatColor.AQUA + " " + key);
}
}
}
return true;
}
use of com.elmakers.mine.bukkit.api.magic.Mage in project MagicPlugin by elBukkit.
the class ExprActiveSpell method change.
@Override
public void change(final Event e, @Nullable final Object[] delta, final Changer.ChangeMode mode) {
assert mode == Changer.ChangeMode.SET || mode == Changer.ChangeMode.REMOVE_ALL;
for (final Player p : getExpr().getArray(e)) {
Mage mage = MagicPlugin.getAPI().getController().getRegisteredMage(p);
if (mage == null)
continue;
Wand wand = mage.getActiveWand();
if (wand == null) {
continue;
}
final String newSpell = delta == null ? null : ((String) delta[0]);
switch(mode) {
case SET:
wand.setActiveSpell(newSpell);
break;
case REMOVE_ALL:
wand.setActiveSpell(null);
break;
default:
assert false;
continue;
}
}
}
use of com.elmakers.mine.bukkit.api.magic.Mage in project MagicPlugin by elBukkit.
the class MobArenaManager method onPlayerJoinArena.
@EventHandler
public void onPlayerJoinArena(ArenaPlayerJoinEvent event) {
Player player = event.getPlayer();
Mage mage = controller.getRegisteredMage(player.getUniqueId().toString());
if (mage != null) {
mage.deactivate();
}
}
use of com.elmakers.mine.bukkit.api.magic.Mage 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());
}
});
}
Aggregations