package org.inspire.guide.metadata;

import java.util.ArrayList;
import java.util.List;

/**
 * Actions that can be performed within the
 * Bukkit scheduler framework.
 * <p/>
 * These actions are self-contained, so when run() is
 * executed, any action that will be performed does NOT require
 * any additional outside information.
 * <p/>
 * User: InspiredIdealist
 * Date: 1/11/14
 */
public abstract class Action implements Runnable {

    private static List<Action> ACTIONS_AVAILABLE = new ArrayList<Action>();
    private Type type;
    private String description;

    public Action(Type type, String description) {
        this.type = type;
        this.description = description;
        ACTIONS_AVAILABLE.add(this); //May need to place this elsewhere. But this should work for now.
    }

    public Type getType() {
        return type;
    }

    @Override
    public abstract String toString();

    public String getDescription() {
        return description;
    }

    public static List<Action> getActionsAvailable() {
        return ACTIONS_AVAILABLE;
    }

    /**
     * Flag that denotes whether or not the rule can execute without
     * the user specifying it.
     *
     * @return true if it is autonomous, false if not
     */
    public abstract boolean isAutonomous();

    /**
     * The action to run. Call this to do the action.
     */
    public abstract void run();
}
