Some more work..
This commit is contained in:
parent
c8ad91bd49
commit
51a6e36e1f
@ -1,12 +1,9 @@
|
|||||||
package lt.govindas.skooldown.events;
|
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.Literal;
|
||||||
import ch.njol.skript.lang.SkriptEvent;
|
import ch.njol.skript.lang.SkriptEvent;
|
||||||
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -38,7 +38,7 @@ public class ExprCooldown extends SimpleExpression<Timespan> {
|
|||||||
name = (Expression<String>) expr[0];
|
name = (Expression<String>) expr[0];
|
||||||
int mark = paramParseResult.mark;
|
int mark = paramParseResult.mark;
|
||||||
if (mark == 1) { eventCooldown = true; }
|
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]; }
|
if (expr.length > 2) { data = (Expression<String>) expr[1]; }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -102,6 +102,7 @@ public class ExprCooldown extends SimpleExpression<Timespan> {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ADD:
|
case ADD:
|
||||||
|
if (!eventCooldown) {
|
||||||
Long cooldown = Skooldown.cooldowns.get(name.getSingle(e));
|
Long cooldown = Skooldown.cooldowns.get(name.getSingle(e));
|
||||||
if (cooldown == null) {
|
if (cooldown == null) {
|
||||||
Skooldown.cooldowns.put(name.getSingle(e), System.currentTimeMillis() + ((Timespan) changer[0]).getMilliSeconds());
|
Skooldown.cooldowns.put(name.getSingle(e), System.currentTimeMillis() + ((Timespan) changer[0]).getMilliSeconds());
|
||||||
@ -109,8 +110,11 @@ public class ExprCooldown extends SimpleExpression<Timespan> {
|
|||||||
}
|
}
|
||||||
Skooldown.cooldowns.put(name.getSingle(e), cooldown + ((Timespan) changer[0]).getMilliSeconds());
|
Skooldown.cooldowns.put(name.getSingle(e), cooldown + ((Timespan) changer[0]).getMilliSeconds());
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
//todo make this stop the timer without calling event & start it with another time fitting to time elapsed and added time
|
||||||
|
}
|
||||||
case REMOVE:
|
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 removing from non-existent cooldown, do nothing
|
||||||
if (cooldown == null) return;
|
if (cooldown == null) return;
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import lt.govindas.skooldown.events.CooldownEndEvent;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
//TODO add event cooldown editing support, such as remove/add time
|
|
||||||
public class ExprCooldownData extends SimpleExpression<String> {
|
public class ExprCooldownData extends SimpleExpression<String> {
|
||||||
@Override
|
@Override
|
||||||
public boolean isSingle() {
|
public boolean isSingle() {
|
||||||
|
Loading…
Reference in New Issue
Block a user