diff --git a/src/main/java/io/github/simplexdev/simplexcore/CoreState.java b/src/main/java/io/github/simplexdev/simplexcore/CoreState.java index 2bcb306..11d09fe 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/CoreState.java +++ b/src/main/java/io/github/simplexdev/simplexcore/CoreState.java @@ -1,9 +1,11 @@ package io.github.simplexdev.simplexcore; public class CoreState { - String message; + private final SimplexCorePlugin plugin; + private String message; - public CoreState() { + public CoreState(SimplexCorePlugin plugin) { + this.plugin = plugin; switch (getState()) { case ON: message = "The Core is currently ON"; @@ -25,7 +27,7 @@ public class CoreState { return State.DEBUG; } - if (SimplexCorePlugin.getInstance().isEnabled()) { + if (this.plugin.isEnabled()) { return State.ON; } diff --git a/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java b/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java index 4e1f92a..8a4be05 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java +++ b/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java @@ -1,34 +1,25 @@ package io.github.simplexdev.simplexcore; -import io.github.simplexdev.simplexcore.command.CommandLoader; import io.github.simplexdev.simplexcore.command.defaults.Command_info; import io.github.simplexdev.simplexcore.config.Yaml; import io.github.simplexdev.simplexcore.config.YamlFactory; -import io.github.simplexdev.simplexcore.plugin.AddonRegistry; import io.github.simplexdev.simplexcore.plugin.DependencyManagement; import io.github.simplexdev.simplexcore.task.Announcer; import io.github.simplexdev.simplexcore.listener.DependencyListener; import io.github.simplexdev.simplexcore.listener.SimplexListener; import io.github.simplexdev.simplexcore.plugin.SimplexAddon; -import io.github.simplexdev.simplexcore.utils.TimeValues; -import org.bukkit.plugin.PluginManager; -import org.bukkit.scheduler.BukkitScheduler; - -import java.io.File; -import java.util.logging.Logger; public final class SimplexCorePlugin extends SimplexAddon { - protected static boolean debug = false; - protected static boolean suspended = false; + private static boolean debug = false; + private static boolean suspended = false; + private static SimplexCorePlugin instance; private DependencyManagement dpm; private Yaml config; - private TimeValues time; private Yaml internals; - protected static SimplexCorePlugin instance; public static SimplexCorePlugin getInstance() { return instance; - } // I understand this could be an issue. + } @Override public SimplexCorePlugin getPlugin() { @@ -37,10 +28,9 @@ public final class SimplexCorePlugin extends SimplexAddon { @Override public void init() { - instance = this; // However, if the module is written correctly, this wont be an issue. + SimplexCorePlugin.instance = this; this.dpm = new DependencyManagement(); this.config = new YamlFactory(this).setDefaultPathways(); - this.time = new TimeValues(); this.internals = new YamlFactory(this).from("internals.yml", getParentFolder(), "internals.yml"); } @@ -59,7 +49,7 @@ public final class SimplexCorePlugin extends SimplexAddon { // TODO: Write an output to a file with why it suspended. } - CoreState state = new CoreState(); + CoreState state = new CoreState(this); getLogger().info(state.getMessage()); } @@ -84,10 +74,6 @@ public final class SimplexCorePlugin extends SimplexAddon { return dpm; } - public TimeValues getTimeValues() { - return time; - } - public Yaml getYamlConfig() { return config; } diff --git a/src/main/java/io/github/simplexdev/simplexcore/ban/Ban.java b/src/main/java/io/github/simplexdev/simplexcore/ban/Ban.java index f70535d..63fd227 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/ban/Ban.java +++ b/src/main/java/io/github/simplexdev/simplexcore/ban/Ban.java @@ -5,6 +5,7 @@ import io.github.simplexdev.simplexcore.SimplexCorePlugin; import io.github.simplexdev.simplexcore.chat.Messages; import io.github.simplexdev.simplexcore.config.Yaml; import io.github.simplexdev.simplexcore.config.YamlFactory; +import io.github.simplexdev.simplexcore.utils.TickedTime; import io.github.simplexdev.simplexcore.utils.Utilities; import io.github.simplexdev.simplexcore.listener.SimplexListener; import org.bukkit.command.CommandSender; @@ -37,7 +38,7 @@ public abstract class Ban implements IBan { } public Ban(Player player, CommandSender sender, BanType type) { - this(player, sender, type, SimplexCorePlugin.getInstance().getTimeValues().DAY()); + this(player, sender, type, TickedTime.DAY); } public Ban(Player player, CommandSender sender, BanType type, long banDuration) { diff --git a/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java b/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java index 0e49615..38e0d62 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java +++ b/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java @@ -5,6 +5,7 @@ import io.github.simplexdev.api.func.VoidSupplier; import io.github.simplexdev.simplexcore.SimplexCorePlugin; import io.github.simplexdev.simplexcore.chat.Messages; import io.github.simplexdev.simplexcore.config.Yaml; +import io.github.simplexdev.simplexcore.utils.TickedTime; import io.github.simplexdev.simplexcore.utils.Utilities; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -126,11 +127,11 @@ public final class BanFactory { private VoidSupplier assignBanDuration() { return () -> { if (type.equals(BanType.PERMANENT)) { - banDuration = SimplexCorePlugin.getInstance().getTimeValues().YEAR() * 99; + banDuration = TickedTime.YEAR * 99; } else if (type.equals(BanType.TEMPORARY)) { - banDuration = SimplexCorePlugin.getInstance().getTimeValues().DAY(); + banDuration = TickedTime.DAY; } else { - banDuration = SimplexCorePlugin.getInstance().getTimeValues().MINUTE() * 5; + banDuration = TickedTime.MINUTE * 5; } }; } diff --git a/src/main/java/io/github/simplexdev/simplexcore/math/Cuboid.java b/src/main/java/io/github/simplexdev/simplexcore/math/Cuboid.java index d776e5a..3991174 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/math/Cuboid.java +++ b/src/main/java/io/github/simplexdev/simplexcore/math/Cuboid.java @@ -1,6 +1,7 @@ package io.github.simplexdev.simplexcore.math; import io.github.simplexdev.simplexcore.SimplexCorePlugin; +import io.github.simplexdev.simplexcore.utils.TickedTime; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.scheduler.BukkitTask; @@ -44,6 +45,7 @@ public final class Cuboid { }; - SimplexCorePlugin.getInstance().getScheduler().runTaskLaterAsynchronously(SimplexCorePlugin.getInstance(), task, SimplexCorePlugin.getInstance().getTimeValues().SECOND()); + SimplexCorePlugin.getInstance().getScheduler().runTaskLaterAsynchronously(SimplexCorePlugin.getInstance(), task, + TickedTime.SECOND); } } 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 648fab5..77f10f9 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java +++ b/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java @@ -3,6 +3,7 @@ package io.github.simplexdev.simplexcore.task; import io.github.simplexdev.api.func.VoidSupplier; import io.github.simplexdev.simplexcore.SimplexCorePlugin; import io.github.simplexdev.simplexcore.plugin.SimplexAddon; +import io.github.simplexdev.simplexcore.utils.TickedTime; import org.bukkit.scheduler.BukkitTask; import java.util.Date; @@ -28,8 +29,8 @@ public abstract class SimplexTask implements Consumer { } protected SimplexTask() { - DELAY = SimplexCorePlugin.getInstance().getTimeValues().SECOND() * 30; // 30 seconds until the task triggers for the first time. - INTERVAL = SimplexCorePlugin.getInstance().getTimeValues().MINUTE() * 5; // Task will run at 5 minute intervals once the first trigger has been called. + 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. } public void register(T task, SimplexAddon plugin, boolean repeating, boolean delayed) { diff --git a/src/main/java/io/github/simplexdev/simplexcore/utils/TickedTime.java b/src/main/java/io/github/simplexdev/simplexcore/utils/TickedTime.java new file mode 100644 index 0000000..4cb6ce9 --- /dev/null +++ b/src/main/java/io/github/simplexdev/simplexcore/utils/TickedTime.java @@ -0,0 +1,10 @@ +package io.github.simplexdev.simplexcore.utils; + +public final class TickedTime { + public static long SECOND = 20L; + public static long MINUTE = 1_200L; + public static long HOUR = 72_000L; + public static long DAY = 1_728_000L; + public static long MONTH = 51_840_000L; + public static long YEAR = 622_080_000L; +} diff --git a/src/main/java/io/github/simplexdev/simplexcore/utils/TimeValues.java b/src/main/java/io/github/simplexdev/simplexcore/utils/TimeValues.java deleted file mode 100644 index 98aea8f..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/utils/TimeValues.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.simplexdev.simplexcore.utils; - -public final class TimeValues { - public long SECOND() { - return 20L; - } - - public long MINUTE() { - return 1200L; - } - - public long HOUR() { - return 72000L; - } - - public long DAY() { - return 1728000L; - } - - public long MONTH() { - return 51840000L; - } - - public long YEAR() { - return 622080000L; - } -}