<commit_before>package com.elmakers.mine.bukkit.action.builtin;

import com.elmakers.mine.bukkit.action.BaseSpellAction;
import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.batch.Batch;
import com.elmakers.mine.bukkit.api.magic.Mage;
import com.elmakers.mine.bukkit.api.magic.MageController;
import com.elmakers.mine.bukkit.api.spell.SpellResult;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;

public class CancelAction extends BaseSpellAction
{
	private String undoListName;
    private String targetSpellKey;

    @Override
    public void prepare(CastContext context, ConfigurationSection parameters)
    {
        super.prepare(context, parameters);
        targetSpellKey = parameters.getString("spell", null);
    }

    @Override
	public SpellResult perform(CastContext context)
	{
		Entity targetEntity = context.getTargetEntity();
        MageController controller = context.getController();
		if (targetEntity == null || !controller.isMage(targetEntity)) {
            return SpellResult.NO_TARGET;
        }

        Mage targetMage = controller.getMage(targetEntity);
        Batch batch = (targetSpellKey == null || targetSpellKey.isEmpty())
                ? targetMage.cancelPending(true)
                : targetMage.cancelPending(targetSpellKey);
        if (batch == null) {
            return SpellResult.NO_TARGET;
        }
        undoListName = batch.getName();

        return SpellResult.CAST;
	}

    @Override
    public boolean requiresTargetEntity() {
        return true;
    }

    @Override
    public String transformMessage(String message) {
		return message.replace("$spell", undoListName == null ? "Unknown" : undoListName);
	}
}<commit_msg>Add "spells" parameter to Cancel action<commit_after>package com.elmakers.mine.bukkit.action.builtin;

import com.elmakers.mine.bukkit.action.BaseSpellAction;
import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.batch.Batch;
import com.elmakers.mine.bukkit.api.magic.Mage;
import com.elmakers.mine.bukkit.api.magic.MageController;
import com.elmakers.mine.bukkit.api.spell.SpellResult;
import com.elmakers.mine.bukkit.utility.ConfigurationUtils;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;

import java.util.ArrayList;
import java.util.Collection;

public class CancelAction extends BaseSpellAction
{
	private String undoListName;
    private Collection<String> spellKeys;

    @Override
    public void prepare(CastContext context, ConfigurationSection parameters)
    {
        super.prepare(context, parameters);
        if (parameters.contains("spells")) {
            spellKeys = ConfigurationUtils.getStringList(parameters, "spells");
        } else if (parameters.contains("spell")) {
            String targetSpellKey = parameters.getString("spell", null);
            if (targetSpellKey != null && !targetSpellKey.isEmpty()) {
                spellKeys = new ArrayList<String>();
                spellKeys.add(targetSpellKey);
            }
        }
    }

    @Override
	public SpellResult perform(CastContext context)
	{
		Entity targetEntity = context.getTargetEntity();
        MageController controller = context.getController();
		if (targetEntity == null || !controller.isMage(targetEntity)) {
            return SpellResult.NO_TARGET;
        }

        SpellResult result = SpellResult.NO_TARGET;
        Mage targetMage = controller.getMage(targetEntity);
        if (spellKeys == null) {
            Batch batch = targetMage.cancelPending(true);
            if (batch != null) {
                result = SpellResult.CAST;
                undoListName = batch.getName();
            }
        } else {
            for (String spellKey : spellKeys) {
                Batch batch = targetMage.cancelPending(spellKey);
                if (batch != null) {
                    result = SpellResult.CAST;
                    undoListName = batch.getName();
                }
            }
        }
        return result;
	}

    @Override
    public boolean requiresTargetEntity() {
        return true;
    }

    @Override
    public String transformMessage(String message) {
		return message.replace("$undo", undoListName == null ? "Unknown" : undoListName);
	}
}
{'fraction_non_alphanumeric': 0.1001850994909764, 'fraction_numerical': 0.0, 'mean_word_length': 2.947945205479452, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6347620', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1195, 'n_words': 233}