package com.elmakers.mine.bukkit.action.builtin;

import java.util.Collection;

import org.bukkit.configuration.ConfigurationSection;

import com.elmakers.mine.bukkit.action.CheckAction;
import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.spell.Spell;

public class CheckTriggerAction extends CheckAction {
    private boolean sinceStartOfCast;
    private long startTime;
    private String trigger;

    @Override
    public void prepare(CastContext context, ConfigurationSection parameters)
    {
        super.prepare(context, parameters);
        trigger = parameters.getString("trigger", "");
        sinceStartOfCast = parameters.getBoolean("since_start_of_cast", false);
    }

    @Override
    public void reset(CastContext context) {
        startTime = System.currentTimeMillis();
    }

    @Override
    protected boolean isAllowed(CastContext context) {
        Long lastTrigger = context.getMage().getLastTrigger(trigger);
        long startTime = sinceStartOfCast ? context.getStartTime() : this.startTime;
        return (lastTrigger != null && lastTrigger > startTime);
    }

    @Override
    public void getParameterNames(Spell spell, Collection<String> parameters) {
        super.getParameterNames(spell, parameters);
        parameters.add("trigger");
    }
}

@@ -344,46 +344,8 @@
 n %7B%0A
-    private boolean sinceStartOfCast;%0A
     
@@ -598,202 +598,8 @@
 %22);%0A
-        sinceStartOfCast = parameters.getBoolean(%22since_start_of_cast%22, false);%0A    %7D%0A%0A    @Override%0A    public void reset(CastContext context) %7B%0A        startTime = System.currentTimeMillis();%0A
     
@@ -748,21 +748,20 @@
         
-long 
+if (
 startTim
@@ -767,132 +767,268 @@
 me =
- sinceStartOfCast ? context.getStartTime() : this.startTime;%0A        return (lastTrigger != null && lastTrigger %3E startTime)
+= 0) %7B%0A            startTime = context.getStartTime();%0A        %7D%0A        boolean isTriggered = (lastTrigger != null && lastTrigger %3E startTime);%0A        if (isTriggered) %7B%0A            startTime = System.currentTimeMillis();%0A        %7D%0A        return isTriggered
 ;%0A  

Fix CheckTrigger action resetting