From b18fc1f8cfbe8b4c615f33489cddd8661baf93b4 Mon Sep 17 00:00:00 2001 From: Govindas Date: Fri, 9 Apr 2021 12:50:14 +0300 Subject: [PATCH] refactor & thread-safe cooldowns --- pom.xml | 94 +++++++++++++++++++ .../govindas/skooldown/Skooldown.java | 17 ++-- .../conditions/CondIsCooldownOver.java | 4 +- .../skooldown/effects/EffEndCooldown.java | 4 +- .../skooldown/effects/EffStartCooldown.java | 4 +- .../expressions/ExprAllCooldowns.java | 2 +- .../skooldown/expressions/ExprCooldown.java | 4 +- .../skooldown/utilities/CleanupTimer.java | 4 +- src/plugin.yml | 2 +- 9 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 pom.xml rename src/{lt => net}/govindas/skooldown/Skooldown.java (69%) rename src/{lt => net}/govindas/skooldown/conditions/CondIsCooldownOver.java (93%) rename src/{lt => net}/govindas/skooldown/effects/EffEndCooldown.java (90%) rename src/{lt => net}/govindas/skooldown/effects/EffStartCooldown.java (92%) rename src/{lt => net}/govindas/skooldown/expressions/ExprAllCooldowns.java (51%) rename src/{lt => net}/govindas/skooldown/expressions/ExprCooldown.java (97%) rename src/{lt => net}/govindas/skooldown/utilities/CleanupTimer.java (93%) diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..0c26851 --- /dev/null +++ b/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + + net.govindas + Skooldown + 1.2.0 + jar + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + UTF-8 + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.3 + + false + + + + package + + shade + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + ${project.basedir}/compile + + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/ + + + jitpack.io + https://jitpack.io + + + commons-pool2 + https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 + + + PaperMC + https://repo.destroystokyo.com/repository/maven-public/ + + + sk89q + http://maven.sk89q.com/repo + + '' + + + + com.github.SkriptLang + Skript + 2.5.1 + provided + + + org.spigotmc + spigot-api + 1.16.5-R0.1-SNAPSHOT + provided + + + \ No newline at end of file diff --git a/src/lt/govindas/skooldown/Skooldown.java b/src/net/govindas/skooldown/Skooldown.java similarity index 69% rename from src/lt/govindas/skooldown/Skooldown.java rename to src/net/govindas/skooldown/Skooldown.java index d0ab9b2..e08ab2f 100644 --- a/src/lt/govindas/skooldown/Skooldown.java +++ b/src/net/govindas/skooldown/Skooldown.java @@ -1,19 +1,19 @@ -package lt.govindas.skooldown; +package net.govindas.skooldown; import ch.njol.skript.Skript; import ch.njol.skript.lang.ExpressionType; import ch.njol.skript.util.Timespan; -import lt.govindas.skooldown.conditions.CondIsCooldownOver; -import lt.govindas.skooldown.effects.EffEndCooldown; -import lt.govindas.skooldown.effects.EffStartCooldown; -import lt.govindas.skooldown.expressions.ExprCooldown; -import lt.govindas.skooldown.utilities.CleanupTimer; +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; import org.bukkit.plugin.java.JavaPlugin; -import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; public final class Skooldown extends JavaPlugin { - public static HashMap cooldowns = new HashMap(); + public static ConcurrentHashMap cooldowns = new ConcurrentHashMap(); @Override public void onEnable() { @@ -32,6 +32,7 @@ public final class Skooldown extends JavaPlugin { @Override public void onDisable() { + cooldowns = null; getLogger().info("Skript addon disabled!"); } } diff --git a/src/lt/govindas/skooldown/conditions/CondIsCooldownOver.java b/src/net/govindas/skooldown/conditions/CondIsCooldownOver.java similarity index 93% rename from src/lt/govindas/skooldown/conditions/CondIsCooldownOver.java rename to src/net/govindas/skooldown/conditions/CondIsCooldownOver.java index 147ba78..f15e6f9 100644 --- a/src/lt/govindas/skooldown/conditions/CondIsCooldownOver.java +++ b/src/net/govindas/skooldown/conditions/CondIsCooldownOver.java @@ -1,10 +1,10 @@ -package lt.govindas.skooldown.conditions; +package net.govindas.skooldown.conditions; import ch.njol.skript.lang.Condition; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.util.Kleenean; -import lt.govindas.skooldown.Skooldown; +import net.govindas.skooldown.Skooldown; import org.bukkit.event.Event; public class CondIsCooldownOver extends Condition { diff --git a/src/lt/govindas/skooldown/effects/EffEndCooldown.java b/src/net/govindas/skooldown/effects/EffEndCooldown.java similarity index 90% rename from src/lt/govindas/skooldown/effects/EffEndCooldown.java rename to src/net/govindas/skooldown/effects/EffEndCooldown.java index f1e0d1d..5fd40d4 100644 --- a/src/lt/govindas/skooldown/effects/EffEndCooldown.java +++ b/src/net/govindas/skooldown/effects/EffEndCooldown.java @@ -1,10 +1,10 @@ -package lt.govindas.skooldown.effects; +package net.govindas.skooldown.effects; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.util.Kleenean; -import lt.govindas.skooldown.Skooldown; +import net.govindas.skooldown.Skooldown; import org.bukkit.event.Event; public class EffEndCooldown extends Effect { diff --git a/src/lt/govindas/skooldown/effects/EffStartCooldown.java b/src/net/govindas/skooldown/effects/EffStartCooldown.java similarity index 92% rename from src/lt/govindas/skooldown/effects/EffStartCooldown.java rename to src/net/govindas/skooldown/effects/EffStartCooldown.java index d1552cb..56a824a 100644 --- a/src/lt/govindas/skooldown/effects/EffStartCooldown.java +++ b/src/net/govindas/skooldown/effects/EffStartCooldown.java @@ -1,11 +1,11 @@ -package lt.govindas.skooldown.effects; +package net.govindas.skooldown.effects; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.util.Timespan; import ch.njol.util.Kleenean; -import lt.govindas.skooldown.Skooldown; +import net.govindas.skooldown.Skooldown; import org.bukkit.event.Event; public class EffStartCooldown extends Effect { diff --git a/src/lt/govindas/skooldown/expressions/ExprAllCooldowns.java b/src/net/govindas/skooldown/expressions/ExprAllCooldowns.java similarity index 51% rename from src/lt/govindas/skooldown/expressions/ExprAllCooldowns.java rename to src/net/govindas/skooldown/expressions/ExprAllCooldowns.java index a5f8a04..377a8e4 100644 --- a/src/lt/govindas/skooldown/expressions/ExprAllCooldowns.java +++ b/src/net/govindas/skooldown/expressions/ExprAllCooldowns.java @@ -1,4 +1,4 @@ -package lt.govindas.skooldown.expressions; +package net.govindas.skooldown.expressions; public class ExprAllCooldowns { //TODO diff --git a/src/lt/govindas/skooldown/expressions/ExprCooldown.java b/src/net/govindas/skooldown/expressions/ExprCooldown.java similarity index 97% rename from src/lt/govindas/skooldown/expressions/ExprCooldown.java rename to src/net/govindas/skooldown/expressions/ExprCooldown.java index 9e0acb5..95f594d 100644 --- a/src/lt/govindas/skooldown/expressions/ExprCooldown.java +++ b/src/net/govindas/skooldown/expressions/ExprCooldown.java @@ -1,4 +1,4 @@ -package lt.govindas.skooldown.expressions; +package net.govindas.skooldown.expressions; import ch.njol.skript.classes.Changer; @@ -9,7 +9,7 @@ import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.skript.util.Timespan; import ch.njol.util.Kleenean; import ch.njol.util.coll.CollectionUtils; -import lt.govindas.skooldown.Skooldown; +import net.govindas.skooldown.Skooldown; import org.bukkit.event.Event; public class ExprCooldown extends SimpleExpression { diff --git a/src/lt/govindas/skooldown/utilities/CleanupTimer.java b/src/net/govindas/skooldown/utilities/CleanupTimer.java similarity index 93% rename from src/lt/govindas/skooldown/utilities/CleanupTimer.java rename to src/net/govindas/skooldown/utilities/CleanupTimer.java index c303f83..6df022b 100644 --- a/src/lt/govindas/skooldown/utilities/CleanupTimer.java +++ b/src/net/govindas/skooldown/utilities/CleanupTimer.java @@ -1,6 +1,6 @@ -package lt.govindas.skooldown.utilities; +package net.govindas.skooldown.utilities; -import lt.govindas.skooldown.Skooldown; +import net.govindas.skooldown.Skooldown; import org.bukkit.Bukkit; import java.util.Iterator; diff --git a/src/plugin.yml b/src/plugin.yml index 4f17523..3824473 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,5 +1,5 @@ name: Skooldown main: lt.govindas.skooldown.Skooldown -version: 1.1.0 +version: 1.2.0 author: Govindas depend: [Skript] \ No newline at end of file