Some more work..

This commit is contained in:
Govindas 2020-02-27 15:58:17 +02:00
parent c8ad91bd49
commit 51a6e36e1f
3 changed files with 12 additions and 12 deletions

View File

@ -1,12 +1,9 @@
package lt.govindas.skooldown.events;
import ch.njol.skript.lang.Expression;
import lt.govindas.skooldown.Skooldown;
import org.bukkit.event.Event;
import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptEvent;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;

View File

@ -38,7 +38,7 @@ public class ExprCooldown extends SimpleExpression<Timespan> {
name = (Expression<String>) expr[0];
int mark = paramParseResult.mark;
if (mark == 1) { eventCooldown = true; }
//TODO test if this is right, maybe expression IDs are solid
if (expr.length > 2) { data = (Expression<String>) expr[1]; }
return true;
}
@ -102,15 +102,19 @@ public class ExprCooldown extends SimpleExpression<Timespan> {
}
break;
case ADD:
Long cooldown = Skooldown.cooldowns.get(name.getSingle(e));
if (cooldown == null) {
Skooldown.cooldowns.put(name.getSingle(e), System.currentTimeMillis() + ((Timespan) changer[0]).getMilliSeconds());
if (!eventCooldown) {
Long cooldown = Skooldown.cooldowns.get(name.getSingle(e));
if (cooldown == null) {
Skooldown.cooldowns.put(name.getSingle(e), System.currentTimeMillis() + ((Timespan) changer[0]).getMilliSeconds());
break;
}
Skooldown.cooldowns.put(name.getSingle(e), cooldown + ((Timespan) changer[0]).getMilliSeconds());
break;
} else {
//todo make this stop the timer without calling event & start it with another time fitting to time elapsed and added time
}
Skooldown.cooldowns.put(name.getSingle(e), cooldown + ((Timespan) changer[0]).getMilliSeconds());
break;
case REMOVE:
cooldown = Skooldown.cooldowns.get(name.getSingle(e));
Long cooldown = Skooldown.cooldowns.get(name.getSingle(e));
//if removing from non-existent cooldown, do nothing
if (cooldown == null) return;

View File

@ -10,7 +10,6 @@ import lt.govindas.skooldown.events.CooldownEndEvent;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
//TODO add event cooldown editing support, such as remove/add time
public class ExprCooldownData extends SimpleExpression<String> {
@Override
public boolean isSingle() {