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

import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.action.SpellAction;
import com.elmakers.mine.bukkit.api.magic.Mage;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;

import java.util.Collection;

public abstract class DelayedCompoundAction extends BaseSpellAction
{
	private boolean usesBrush = false;
	private boolean undoable = false;
    private boolean requiresBuildPermission = false;
	protected ActionHandler actions = null;
    protected ConfigurationSection parameters;

    @Override
    public void prepare(CastContext context, ConfigurationSection parameters)
    {
        super.prepare(context, parameters);
        this.parameters = parameters;
    }

    @Override
	public void initialize(ConfigurationSection parameters)
	{
		super.initialize(parameters);

		usesBrush = false;
		undoable = false;
        requiresBuildPermission = false;
        if (parameters != null)
        {
            if (parameters.contains("actions"))
            {
                actions = new ActionHandler();
                actions.load(parameters, "actions");
            }
        }
        if (actions != null)
        {
            actions.initialize(parameters);
            updateFlags();
        }
    }

    protected void updateFlags() {
        usesBrush = usesBrush || actions.usesBrush();
        undoable = undoable || actions.isUndoable();
        requiresBuildPermission = requiresBuildPermission || actions.requiresBuildPermission();
    }

    public void addAction(SpellAction action) {
        addAction(action, null);
    }

    public void addAction(SpellAction action, ConfigurationSection parameters) {
        if (actions == null) {
            actions = new ActionHandler();
        }
        actions.loadAction(action, parameters);
        updateFlags();
    }

    @Override
    public void load(Mage mage, ConfigurationSection data)
    {
        if (actions != null)
        {
            actions.loadData(mage, data);
        }
    }

    @Override
    public void save(Mage mage, ConfigurationSection data)
    {
        if (actions != null)
        {
            actions.saveData(mage, data);
        }
    }

	@Override
	public boolean isUndoable()
	{
		return undoable;
	}

	@Override
	public boolean usesBrush()
	{
		return usesBrush;
	}

    @Override
    public boolean requiresBuildPermission()
    {
        return requiresBuildPermission;
    }

	@Override
	public void getParameterNames(Collection<String> parameters)
	{
		if (actions != null)
		{
			actions.getParameterNames(parameters);
		}
	}

	@Override
	public void getParameterOptions(Collection<String> examples, String parameterKey)
	{
		if (actions != null)
		{
			actions.getParameterOptions(examples, parameterKey);
		}
	}

	@Override
	public String transformMessage(String message)
	{
		if (actions == null)
		{
			return message;
		}
		return actions.transformMessage(message);
	}

    public CastContext createContext(CastContext context) {
        return new com.elmakers.mine.bukkit.action.CastContext(context);
    }

    public CastContext createContext(CastContext context, Entity sourceEntity, Location sourceLocation) {
        return new com.elmakers.mine.bukkit.action.CastContext(context, sourceEntity, sourceLocation);
    }

    public CastContext createContext(CastContext context, Entity sourceEntity, Location sourceLocation, Entity targetEntity, Location targetLocation) {
        CastContext newContext = new com.elmakers.mine.bukkit.action.CastContext(context, sourceEntity, sourceLocation);
        newContext.setTargetEntity(targetEntity);
        newContext.setTargetLocation(targetLocation);
        return newContext;
    }

    @Override
    public int getActionCount() {
        return actions.getActionCount();
    }

    protected void skippedActions(CastContext context) {
        int actionCount = actions.getActionCount();
        context.performedActions(actionCount);
        context.addWork(actionCount);
    }
}<commit_msg>Clone action handler when cloning a compound action<commit_after>package com.elmakers.mine.bukkit.action;

import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.action.SpellAction;
import com.elmakers.mine.bukkit.api.magic.Mage;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;

import java.util.Collection;

public abstract class DelayedCompoundAction extends BaseSpellAction implements Cloneable
{
	private boolean usesBrush = false;
	private boolean undoable = false;
    private boolean requiresBuildPermission = false;
	protected ActionHandler actions = null;
    protected ConfigurationSection parameters;

    @Override
    public void prepare(CastContext context, ConfigurationSection parameters)
    {
        super.prepare(context, parameters);
        this.parameters = parameters;
    }

    @Override
	public void initialize(ConfigurationSection parameters)
	{
		super.initialize(parameters);

		usesBrush = false;
		undoable = false;
        requiresBuildPermission = false;
        if (parameters != null)
        {
            if (parameters.contains("actions"))
            {
                actions = new ActionHandler();
                actions.load(parameters, "actions");
            }
        }
        if (actions != null)
        {
            actions.initialize(parameters);
            updateFlags();
        }
    }

    protected void updateFlags() {
        usesBrush = usesBrush || actions.usesBrush();
        undoable = undoable || actions.isUndoable();
        requiresBuildPermission = requiresBuildPermission || actions.requiresBuildPermission();
    }

    public void addAction(SpellAction action) {
        addAction(action, null);
    }

    public void addAction(SpellAction action, ConfigurationSection parameters) {
        if (actions == null) {
            actions = new ActionHandler();
        }
        actions.loadAction(action, parameters);
        updateFlags();
    }

    @Override
    public void load(Mage mage, ConfigurationSection data)
    {
        if (actions != null)
        {
            actions.loadData(mage, data);
        }
    }

    @Override
    public void save(Mage mage, ConfigurationSection data)
    {
        if (actions != null)
        {
            actions.saveData(mage, data);
        }
    }

	@Override
	public boolean isUndoable()
	{
		return undoable;
	}

	@Override
	public boolean usesBrush()
	{
		return usesBrush;
	}

    @Override
    public boolean requiresBuildPermission()
    {
        return requiresBuildPermission;
    }

	@Override
	public void getParameterNames(Collection<String> parameters)
	{
		if (actions != null)
		{
			actions.getParameterNames(parameters);
		}
	}

	@Override
	public void getParameterOptions(Collection<String> examples, String parameterKey)
	{
		if (actions != null)
		{
			actions.getParameterOptions(examples, parameterKey);
		}
	}

	@Override
	public String transformMessage(String message)
	{
		if (actions == null)
		{
			return message;
		}
		return actions.transformMessage(message);
	}

    public CastContext createContext(CastContext context) {
        return new com.elmakers.mine.bukkit.action.CastContext(context);
    }

    public CastContext createContext(CastContext context, Entity sourceEntity, Location sourceLocation) {
        return new com.elmakers.mine.bukkit.action.CastContext(context, sourceEntity, sourceLocation);
    }

    public CastContext createContext(CastContext context, Entity sourceEntity, Location sourceLocation, Entity targetEntity, Location targetLocation) {
        CastContext newContext = new com.elmakers.mine.bukkit.action.CastContext(context, sourceEntity, sourceLocation);
        newContext.setTargetEntity(targetEntity);
        newContext.setTargetLocation(targetLocation);
        return newContext;
    }

    @Override
    public int getActionCount() {
        return actions.getActionCount();
    }

    protected void skippedActions(CastContext context) {
        int actionCount = actions.getActionCount();
        context.performedActions(actionCount);
        context.addWork(actionCount);
    }

    @Override
    public Object clone()
    {
        DelayedCompoundAction action = (DelayedCompoundAction)super.clone();
        if (action != null) {
            action.actions = (ActionHandler)this.actions.clone();
        }
        return action;
    }
}
{'fraction_non_alphanumeric': 0.08817354793561931, 'fraction_numerical': 0.0, 'mean_word_length': 2.988372093023256, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4334608', 'n_tokens_mistral': 2350, 'n_tokens_neox': 2214, 'n_words': 511}