use of com.elmakers.mine.bukkit.action.ActionHandler in project MagicPlugin by elBukkit.
the class ParallelAction method finish.
@Override
public void finish(CastContext context) {
super.finish(context);
ActionHandler actions = getHandler("actions");
if (actions != null) {
actions.finish(context);
}
}
use of com.elmakers.mine.bukkit.action.ActionHandler in project MagicPlugin by elBukkit.
the class ActionSpell method loadTemplate.
@Override
protected void loadTemplate(ConfigurationSection template) {
castOnNoTarget = true;
super.loadTemplate(template);
undoable = false;
requiresBuildPermission = false;
requiresBreakPermission = false;
usesBrush = template.getBoolean("uses_brush", false);
ConfigurationSection actionsNode = template.getConfigurationSection("actions");
if (actionsNode != null) {
ConfigurationSection parameters = template.getConfigurationSection("parameters");
Object baseActions = actionsNode.get("cast");
Collection<String> templateKeys = template.getKeys(false);
for (String templateKey : templateKeys) {
if (templateKey.endsWith("_parameters")) {
ConfigurationSection overrides = ConfigurationUtils.cloneConfiguration(template.getConfigurationSection(templateKey));
String handlerKey = templateKey.substring(0, templateKey.length() - 11);
handlerParameters.put(handlerKey, overrides);
// Auto-register base actions, kind of hacky to check for alternates though.
if (baseActions != null && !actionsNode.contains(handlerKey) && handlerKey.startsWith("alternate_")) {
actionsNode.set(handlerKey, baseActions);
}
}
}
actionsNode = ConfigurationUtils.replaceParameters(actionsNode, parameters);
if (actionsNode != null) {
Collection<String> actionKeys = actionsNode.getKeys(false);
for (String actionKey : actionKeys) {
ActionHandler handler = new ActionHandler();
handler.load(this, actionsNode, actionKey);
handler.initialize(this, parameters);
usesBrush = usesBrush || handler.usesBrush();
undoable = undoable || handler.isUndoable();
requiresBuildPermission = requiresBuildPermission || handler.requiresBuildPermission();
requiresBreakPermission = requiresBreakPermission || handler.requiresBreakPermission();
actions.put(actionKey, handler);
}
}
}
undoable = template.getBoolean("undoable", undoable);
requiresBreakPermission = template.getBoolean("require_break", requiresBreakPermission);
requiresBuildPermission = template.getBoolean("require_build", requiresBuildPermission);
}
use of com.elmakers.mine.bukkit.action.ActionHandler in project MagicPlugin by elBukkit.
the class AbsorbSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
target();
ActionHandler handler = new ActionHandler();
handler.loadAction(new AbsorbAction());
handler.initialize(this, parameters);
return handler.start(getCurrentCast(), parameters);
}
use of com.elmakers.mine.bukkit.action.ActionHandler in project MagicPlugin by elBukkit.
the class FireSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Target target = getTarget();
if (target == null || !target.isValid()) {
return SpellResult.NO_TARGET;
}
Block targetBlock = target.getBlock();
if (!hasBuildPermission(targetBlock)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
CoverAction cover = new CoverAction();
cover.addAction(new BurnAction());
ActionHandler handler = new ActionHandler();
handler.loadAction(cover);
handler.initialize(this, parameters);
registerForUndo();
return handler.start(getCurrentCast(), parameters);
}
use of com.elmakers.mine.bukkit.action.ActionHandler in project MagicPlugin by elBukkit.
the class FlowerSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Target target = getTarget();
if (target == null || !target.isValid()) {
return SpellResult.NO_TARGET;
}
Block targetBlock = target.getBlock();
if (!hasBuildPermission(targetBlock)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
CoverAction cover = new CoverAction();
cover.addAction(new FlowerAction());
ActionHandler handler = new ActionHandler();
handler.loadAction(cover);
handler.initialize(this, parameters);
registerForUndo();
return handler.start(getCurrentCast(), parameters);
}
Aggregations