diff --git a/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java b/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java
index 08c4423..844e3a3 100644
--- a/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java
+++ b/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java
@@ -40,6 +40,7 @@ public final class CommandLoader {
* If the class provided does not extend {@link SimplexCommand}, the loader will throw a new
* {@link RuntimeException} and your commands will not be loaded.
*
+ *
* @param clazz The command class to load from
* @return An instance of this where the classpath has been prepared for loading the commands.
*/
@@ -56,7 +57,7 @@ public final class CommandLoader {
throw new RuntimeException("Your command must extend SimplexCommand.class for it to be used as the reference point for loading commands.");
}
- reflections = new Reflections(clazz);
+ reflections = ReflectionTools.reflect(clazz);
return this;
}
@@ -92,6 +93,7 @@ public final class CommandLoader {
* Gets the command class as a child of {@link CommandExecutor} from the {@link CommandInfo#name()} annotation.
* This is for registering the CommandExecutor of the provided command with Bukkit.
* This should only be used by the CommandLoader.
+ *
* @param name The name of the command.
* @return An instance of the command class as a CommandExecutor.
*/
@@ -120,6 +122,7 @@ public final class CommandLoader {
* Gets the command class as a child of {@link TabCompleter} from the {@link CommandInfo#name()} annotation.
* This is for registering the TabCompleter of the provided command with Bukkit.
* This should only be used by the CommandLoader.
+ *
* @param name The name of the command
* @return The command as an instance of TabCompleter
*/
diff --git a/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java b/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java
index 77f10f9..387401a 100644
--- a/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java
+++ b/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java
@@ -17,22 +17,50 @@ public abstract class SimplexTask implements Consumer {
protected final long INTERVAL;
protected Date lastRan = new Date();
protected Timer timer = new Timer();
+ protected int taskId;
+ /**
+ * Creates a new instance of this class, with a custom defined DELAY and INTERVAL.
+ *
+ * @param initialDelay How long before the first time the task executes.
+ * @param interval How long before the task repeats itself.
+ */
protected SimplexTask(long initialDelay, long interval) {
DELAY = initialDelay;
INTERVAL = interval;
}
-
+
+ /**
+ * Constructor which automatically registers the DELAY as 0 seconds (NO DELAY)
+ * and assigns a custom INTERVAL at which it executes.
+ *
+ * @param interval How often the task should repeat. Every 20L is 1 second.
+ * You should use {@link TickedTime} for determining the related server timings.
+ */
protected SimplexTask(long interval) {
DELAY = 0L;
INTERVAL = interval;
}
+ /**
+ * Constructor which automatically registers the DELAY as 30 seconds
+ * and the INTERVAL at which it executes as 5 minutes.
+ */
protected SimplexTask() {
DELAY = TickedTime.SECOND * 30; // 30 seconds until the task triggers for the first time.
INTERVAL = TickedTime.MINUTE * 5; // Task will run at 5 minute intervals once the first trigger has been called.
}
+ /**
+ * Registers the parent interface {@link Consumer} with the
+ * {@link org.bukkit.scheduler.BukkitScheduler}.
+ *
+ * @param task The instance of a subclass of this class.
+ * @param plugin Your plugin instance.
+ * @param repeating Whether or not the task should repeat.
+ * @param delayed Whether or not to delay the first time the task runs.
+ * @param A subclass of SimplexTask.
+ */
public void register(T task, SimplexAddon> plugin, boolean repeating, boolean delayed) {
if (delayed && repeating) {
SimplexCorePlugin.getInstance().getScheduler().runTaskTimer(plugin, task, DELAY, INTERVAL);
@@ -45,26 +73,69 @@ public abstract class SimplexTask implements Consumer {
}
}
+
+ /**
+ * Registers the parent interface {@link Consumer} with the
+ * {@link org.bukkit.scheduler.BukkitScheduler}.
+ * This version of this method will not create a repeating task..
+ *
+ * @param task The instance of a subclass of this class.
+ * @param plugin Your plugin instance.
+ * @param delayed Whether or not to delay the start of the task.
+ * @param A subclass of SimplexTask.
+ */
public void register(T task, SimplexAddon> plugin, boolean delayed) {
register(task, plugin, false, delayed);
}
+ /**
+ * Registers the parent interface {@link Consumer} with the
+ * {@link org.bukkit.scheduler.BukkitScheduler}.
+ * This version of this method will not create a delayed or repeating task.
+ *
+ * @param task The instance of a subclass of this class.
+ * @param plugin Your plugin instance.
+ * @param A subclass of SimplexTask.
+ */
public void register(T task, SimplexAddon> plugin) {
register(task, plugin, false, false);
}
+ /**
+ * Gets the last time the task ran.
+ *
+ * @return The last time as a {@link Date} this task last ran.
+ */
public Date getLastRan() {
return lastRan;
}
+ /**
+ * Sets the last time this task ran. This should be done in a subclass inside of the
+ * {@link Consumer#accept(Object)} method.
+ *
+ * @param lastRan An instance of {@link Date} returning the last time this task ran.
+ */
public void setLastRan(Date lastRan) {
this.lastRan = lastRan;
}
+ /**
+ * Gets the {@link Timer} instance associated with this class.
+ * This is for creating and running tasks separate from the {@link org.bukkit.scheduler.BukkitScheduler}.
+ *
+ * @return A {@link Timer} object.
+ */
protected Timer getTimer() {
return timer;
}
+ /**
+ * Creates a new {@link TimerTask} to run with the {@link Timer}
+ *
+ * @param supplier A task to complete.
+ * @return A new instance of TimerTask.
+ */
protected TimerTask newTimer(VoidSupplier supplier) {
return new TimerTask() {
@Override
@@ -73,4 +144,8 @@ public abstract class SimplexTask implements Consumer {
}
};
}
+
+ private void setTaskId(int taskId) {
+ this.taskId = taskId;
+ }
}
diff --git a/src/main/java/io/github/simplexdev/simplexcore/utils/Utilities.java b/src/main/java/io/github/simplexdev/simplexcore/utils/Utilities.java
index 40fb52e..aed48e7 100644
--- a/src/main/java/io/github/simplexdev/simplexcore/utils/Utilities.java
+++ b/src/main/java/io/github/simplexdev/simplexcore/utils/Utilities.java
@@ -10,7 +10,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.SplittableRandom;
import java.util.function.Consumer;
-import java.util.regex.Pattern;
import java.util.stream.Stream;
public final class Utilities {