Compare commits
No commits in common. "0.1" and "master" have entirely different histories.
|
@ -1,3 +1,5 @@
|
|||
.idea
|
||||
out
|
||||
Skooldown.iml
|
||||
target
|
||||
compile
|
|
@ -0,0 +1,47 @@
|
|||
# Skooldown
|
||||
The koolest skript addon for cooldowns
|
||||
|
||||
With this addon you can create cooldowns with good performance, without worrying of deleting variables, etc.
|
||||
Expired cooldowns will be automatically deleted in a very optimized way.
|
||||
Everything is made with maximum performance in mind, you should be able to safely have millions of cooldowns running simultaneously.
|
||||
|
||||
# Syntaxes
|
||||
|
||||
Start a cooldown
|
||||
```
|
||||
(create|start) [a] cooldown %string% for %timespan%
|
||||
|
||||
Example: start cooldown "example%player%" for 45 seconds
|
||||
```
|
||||
Stop a cooldown
|
||||
```
|
||||
(reset|stop|delete|clear) cooldown %string%"
|
||||
|
||||
Example: stop cooldown "example%player%"
|
||||
```
|
||||
Check if cooldown is over
|
||||
```
|
||||
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
|
||||
|
||||
Example:
|
||||
cooldown "example%player%" is over
|
||||
```
|
||||
Display cooldown time
|
||||
```
|
||||
set {_cd} to cooldown "example%player%"
|
||||
send "This cooldown will be over in %{_cd}%"
|
||||
```
|
||||
Extend/Reduce existing cooldown
|
||||
```
|
||||
add 5 seconds to cooldown "example%player%"
|
||||
if cooldown "example%player%" is not higher than 5 seconds:
|
||||
remove 5 seconds from cooldown "example%player%"
|
||||
```
|
||||
|
||||
|
||||
# Compatibility
|
||||
- Should work on about any Minecraft version on which Skript works, cooldowns do not interact with Minecraft code in any way
|
||||
- Incompatible with WolvSK addon cooldowns due to syntax conflict, just use Skooldown instead
|
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.govindas</groupId>
|
||||
<artifactId>Skooldown</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<outputDirectory>${project.basedir}/compile</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>commons-pool2</id>
|
||||
<url>https://mvnrepository.com/artifact/org.apache.commons/commons-pool2</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>PaperMC</id>
|
||||
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q</id>
|
||||
<url>http://maven.sk89q.com/repo</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.SkriptLang</groupId>
|
||||
<artifactId>Skript</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,24 +1,26 @@
|
|||
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.Timer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public final class Skooldown extends JavaPlugin {
|
||||
public static HashMap<String, Long> cooldowns = new HashMap<String, Long>();
|
||||
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<>();
|
||||
private Timer cleanupTimer;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Skript.registerAddon(this);
|
||||
Skript.registerEffect(EffStartCooldown.class, "(create|start) [a] cooldown %string% for %timespan%", "(create|start) [a] cooldown %string% for %timespan%");
|
||||
Skript.registerEffect(EffStartCooldown.class, "(create|start) [a] cooldown %string% for %timespan%");
|
||||
|
||||
|
||||
Skript.registerEffect(EffEndCooldown.class, "(reset|stop|delete|clear) cooldown %string%");
|
||||
|
@ -27,11 +29,16 @@ public final class Skooldown extends JavaPlugin {
|
|||
Skript.registerExpression(ExprCooldown.class, Timespan.class, ExpressionType.PROPERTY, "cooldown %string%");
|
||||
|
||||
getLogger().info("Skript addon enabled!");
|
||||
new CleanupTimer();
|
||||
|
||||
|
||||
cleanupTimer = new CleanupTimer().start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
cooldowns = null;
|
||||
getLogger().info("Skript addon disabled!");
|
||||
cleanupTimer.cancel();
|
||||
cleanupTimer = null;
|
||||
}
|
||||
}
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -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 {
|
|
@ -1,4 +1,4 @@
|
|||
package lt.govindas.skooldown.expressions;
|
||||
package net.govindas.skooldown.expressions;
|
||||
|
||||
public class ExprAllCooldowns {
|
||||
//TODO
|
|
@ -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<Timespan> {
|
|
@ -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;
|
||||
|
@ -11,19 +11,20 @@ import java.util.logging.Level;
|
|||
|
||||
public class CleanupTimer {
|
||||
//Regular Cleanup Timer to prevent memory leaks
|
||||
public CleanupTimer() {
|
||||
public CleanupTimer() {}
|
||||
public Timer start() {
|
||||
Timer timer = new Timer();
|
||||
TimerTask regularTask = new TimerTask() {
|
||||
int i = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Iterator it = Skooldown.cooldowns.entrySet().iterator();
|
||||
Iterator<Map.Entry<String, Long>> it = Skooldown.cooldowns.entrySet().iterator();
|
||||
i = 0;
|
||||
while (it.hasNext()) {
|
||||
Map.Entry pair = (Map.Entry) it.next();
|
||||
Map.Entry<String, Long> pair = it.next();
|
||||
|
||||
long value = (long) pair.getValue();
|
||||
long value = pair.getValue();
|
||||
if (value < System.currentTimeMillis()) {
|
||||
i++;
|
||||
|
||||
|
@ -39,5 +40,6 @@ public class CleanupTimer {
|
|||
//regular schedule
|
||||
int minutes = 30;
|
||||
timer.schedule(regularTask, 100, 1000 * 60 * minutes);
|
||||
return timer;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
name: Skooldown
|
||||
main: net.govindas.skooldown.Skooldown
|
||||
version: 1.2.1
|
||||
author: Govindas
|
||||
depend: [Skript]
|
||||
api-version: 1.13
|
|
@ -1,5 +0,0 @@
|
|||
name: Skooldown
|
||||
main: lt.govindas.skooldown.Skooldown
|
||||
version: 1.1.0
|
||||
author: Govindas
|
||||
depend: [Skript]
|
Loading…
Reference in New Issue