From e9479e59b1199b6a7c60af612b1ef4f2dadb2f1b Mon Sep 17 00:00:00 2001 From: Govindass Date: Thu, 27 Feb 2020 15:58:17 +0200 Subject: [PATCH] Some more work.. --- .../govindas/skooldown/events/EvtCooldown.java | 5 +---- .../skooldown/expressions/ExprCooldown.java | 18 +++++++++++------- .../expressions/ExprCooldownData.java | 1 - 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lt/govindas/skooldown/events/EvtCooldown.java b/src/lt/govindas/skooldown/events/EvtCooldown.java index 6319e17..d7cc40a 100644 --- a/src/lt/govindas/skooldown/events/EvtCooldown.java +++ b/src/lt/govindas/skooldown/events/EvtCooldown.java @@ -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; diff --git a/src/lt/govindas/skooldown/expressions/ExprCooldown.java b/src/lt/govindas/skooldown/expressions/ExprCooldown.java index c89fe88..09783ca 100644 --- a/src/lt/govindas/skooldown/expressions/ExprCooldown.java +++ b/src/lt/govindas/skooldown/expressions/ExprCooldown.java @@ -38,7 +38,7 @@ public class ExprCooldown extends SimpleExpression { name = (Expression) 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) expr[1]; } return true; } @@ -102,15 +102,19 @@ public class ExprCooldown extends SimpleExpression { } 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; diff --git a/src/lt/govindas/skooldown/expressions/ExprCooldownData.java b/src/lt/govindas/skooldown/expressions/ExprCooldownData.java index 0484c78..410ca24 100644 --- a/src/lt/govindas/skooldown/expressions/ExprCooldownData.java +++ b/src/lt/govindas/skooldown/expressions/ExprCooldownData.java @@ -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 { @Override public boolean isSingle() {