2021-04-09 09:50:14 +00:00
|
|
|
package net.govindas.skooldown;
|
2020-02-15 15:39:44 +00:00
|
|
|
|
|
|
|
import ch.njol.skript.Skript;
|
|
|
|
import ch.njol.skript.lang.ExpressionType;
|
|
|
|
import ch.njol.skript.util.Timespan;
|
2021-04-09 09:50:14 +00:00
|
|
|
import net.govindas.skooldown.conditions.CondIsCooldownOver;
|
|
|
|
import net.govindas.skooldown.effects.EffEndCooldown;
|
|
|
|
import net.govindas.skooldown.effects.EffStartCooldown;
|
|
|
|
import net.govindas.skooldown.expressions.ExprCooldown;
|
|
|
|
import net.govindas.skooldown.utilities.CleanupTimer;
|
2020-02-15 15:39:44 +00:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
2020-11-02 08:37:42 +00:00
|
|
|
|
2021-04-09 09:56:18 +00:00
|
|
|
import java.util.Timer;
|
2021-04-09 09:50:14 +00:00
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
2020-02-15 15:39:44 +00:00
|
|
|
|
|
|
|
public final class Skooldown extends JavaPlugin {
|
2021-04-17 07:17:32 +00:00
|
|
|
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<>();
|
2021-04-09 09:56:18 +00:00
|
|
|
private Timer cleanupTimer;
|
2020-02-15 15:39:44 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
2020-11-02 08:37:42 +00:00
|
|
|
Skript.registerAddon(this);
|
2021-04-17 07:02:09 +00:00
|
|
|
Skript.registerEffect(EffStartCooldown.class, "(create|start) [a] cooldown %string% for %timespan%");
|
2020-02-24 18:13:11 +00:00
|
|
|
|
|
|
|
|
2020-11-02 08:37:42 +00:00
|
|
|
Skript.registerEffect(EffEndCooldown.class, "(reset|stop|delete|clear) cooldown %string%");
|
2020-02-24 18:13:11 +00:00
|
|
|
|
2020-11-02 08:37:42 +00:00
|
|
|
Skript.registerCondition(CondIsCooldownOver.class, "cooldown %string% (is|has) (finished|over|done)", "cooldown %string% is(n't| not) unfinished)", "cooldown %string% is(n't| not) (finished|over|done)", "cooldown %string% is unfinished");
|
|
|
|
Skript.registerExpression(ExprCooldown.class, Timespan.class, ExpressionType.PROPERTY, "cooldown %string%");
|
2020-04-24 06:27:20 +00:00
|
|
|
|
2020-11-02 08:37:42 +00:00
|
|
|
getLogger().info("Skript addon enabled!");
|
2021-04-09 09:56:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
cleanupTimer = new CleanupTimer().start();
|
2020-02-15 15:39:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
2021-04-09 09:50:14 +00:00
|
|
|
cooldowns = null;
|
2020-11-02 08:37:42 +00:00
|
|
|
getLogger().info("Skript addon disabled!");
|
2021-04-09 09:56:18 +00:00
|
|
|
cleanupTimer.cancel();
|
|
|
|
cleanupTimer = null;
|
2020-02-15 15:39:44 +00:00
|
|
|
}
|
|
|
|
}
|