mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 08:37:37 +00:00
Convert into constants
This commit is contained in:
parent
9b60b20a0f
commit
ae95b89641
@ -1,9 +1,11 @@
|
|||||||
package io.github.simplexdev.simplexcore;
|
package io.github.simplexdev.simplexcore;
|
||||||
|
|
||||||
public class CoreState {
|
public class CoreState {
|
||||||
String message;
|
private final SimplexCorePlugin plugin;
|
||||||
|
private String message;
|
||||||
|
|
||||||
public CoreState() {
|
public CoreState(SimplexCorePlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
switch (getState()) {
|
switch (getState()) {
|
||||||
case ON:
|
case ON:
|
||||||
message = "The Core is currently ON";
|
message = "The Core is currently ON";
|
||||||
@ -25,7 +27,7 @@ public class CoreState {
|
|||||||
return State.DEBUG;
|
return State.DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SimplexCorePlugin.getInstance().isEnabled()) {
|
if (this.plugin.isEnabled()) {
|
||||||
return State.ON;
|
return State.ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,34 +1,25 @@
|
|||||||
package io.github.simplexdev.simplexcore;
|
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.command.defaults.Command_info;
|
||||||
import io.github.simplexdev.simplexcore.config.Yaml;
|
import io.github.simplexdev.simplexcore.config.Yaml;
|
||||||
import io.github.simplexdev.simplexcore.config.YamlFactory;
|
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.plugin.DependencyManagement;
|
||||||
import io.github.simplexdev.simplexcore.task.Announcer;
|
import io.github.simplexdev.simplexcore.task.Announcer;
|
||||||
import io.github.simplexdev.simplexcore.listener.DependencyListener;
|
import io.github.simplexdev.simplexcore.listener.DependencyListener;
|
||||||
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
||||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
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<SimplexCorePlugin> {
|
public final class SimplexCorePlugin extends SimplexAddon<SimplexCorePlugin> {
|
||||||
protected static boolean debug = false;
|
private static boolean debug = false;
|
||||||
protected static boolean suspended = false;
|
private static boolean suspended = false;
|
||||||
|
private static SimplexCorePlugin instance;
|
||||||
private DependencyManagement dpm;
|
private DependencyManagement dpm;
|
||||||
private Yaml config;
|
private Yaml config;
|
||||||
private TimeValues time;
|
|
||||||
private Yaml internals;
|
private Yaml internals;
|
||||||
|
|
||||||
protected static SimplexCorePlugin instance;
|
|
||||||
public static SimplexCorePlugin getInstance() {
|
public static SimplexCorePlugin getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
} // I understand this could be an issue.
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SimplexCorePlugin getPlugin() {
|
public SimplexCorePlugin getPlugin() {
|
||||||
@ -37,10 +28,9 @@ public final class SimplexCorePlugin extends SimplexAddon<SimplexCorePlugin> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
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.dpm = new DependencyManagement();
|
||||||
this.config = new YamlFactory(this).setDefaultPathways();
|
this.config = new YamlFactory(this).setDefaultPathways();
|
||||||
this.time = new TimeValues();
|
|
||||||
this.internals = new YamlFactory(this).from("internals.yml", getParentFolder(), "internals.yml");
|
this.internals = new YamlFactory(this).from("internals.yml", getParentFolder(), "internals.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +49,7 @@ public final class SimplexCorePlugin extends SimplexAddon<SimplexCorePlugin> {
|
|||||||
// TODO: Write an output to a file with why it suspended.
|
// TODO: Write an output to a file with why it suspended.
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreState state = new CoreState();
|
CoreState state = new CoreState(this);
|
||||||
getLogger().info(state.getMessage());
|
getLogger().info(state.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,10 +74,6 @@ public final class SimplexCorePlugin extends SimplexAddon<SimplexCorePlugin> {
|
|||||||
return dpm;
|
return dpm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeValues getTimeValues() {
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Yaml getYamlConfig() {
|
public Yaml getYamlConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
|||||||
import io.github.simplexdev.simplexcore.chat.Messages;
|
import io.github.simplexdev.simplexcore.chat.Messages;
|
||||||
import io.github.simplexdev.simplexcore.config.Yaml;
|
import io.github.simplexdev.simplexcore.config.Yaml;
|
||||||
import io.github.simplexdev.simplexcore.config.YamlFactory;
|
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.utils.Utilities;
|
||||||
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
import io.github.simplexdev.simplexcore.listener.SimplexListener;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -37,7 +38,7 @@ public abstract class Ban implements IBan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Ban(Player player, CommandSender sender, BanType type) {
|
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) {
|
public Ban(Player player, CommandSender sender, BanType type, long banDuration) {
|
||||||
|
@ -5,6 +5,7 @@ import io.github.simplexdev.api.func.VoidSupplier;
|
|||||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||||
import io.github.simplexdev.simplexcore.chat.Messages;
|
import io.github.simplexdev.simplexcore.chat.Messages;
|
||||||
import io.github.simplexdev.simplexcore.config.Yaml;
|
import io.github.simplexdev.simplexcore.config.Yaml;
|
||||||
|
import io.github.simplexdev.simplexcore.utils.TickedTime;
|
||||||
import io.github.simplexdev.simplexcore.utils.Utilities;
|
import io.github.simplexdev.simplexcore.utils.Utilities;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -126,11 +127,11 @@ public final class BanFactory {
|
|||||||
private VoidSupplier assignBanDuration() {
|
private VoidSupplier assignBanDuration() {
|
||||||
return () -> {
|
return () -> {
|
||||||
if (type.equals(BanType.PERMANENT)) {
|
if (type.equals(BanType.PERMANENT)) {
|
||||||
banDuration = SimplexCorePlugin.getInstance().getTimeValues().YEAR() * 99;
|
banDuration = TickedTime.YEAR * 99;
|
||||||
} else if (type.equals(BanType.TEMPORARY)) {
|
} else if (type.equals(BanType.TEMPORARY)) {
|
||||||
banDuration = SimplexCorePlugin.getInstance().getTimeValues().DAY();
|
banDuration = TickedTime.DAY;
|
||||||
} else {
|
} else {
|
||||||
banDuration = SimplexCorePlugin.getInstance().getTimeValues().MINUTE() * 5;
|
banDuration = TickedTime.MINUTE * 5;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package io.github.simplexdev.simplexcore.math;
|
package io.github.simplexdev.simplexcore.math;
|
||||||
|
|
||||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||||
|
import io.github.simplexdev.simplexcore.utils.TickedTime;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package io.github.simplexdev.simplexcore.task;
|
|||||||
import io.github.simplexdev.api.func.VoidSupplier;
|
import io.github.simplexdev.api.func.VoidSupplier;
|
||||||
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||||
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
import io.github.simplexdev.simplexcore.plugin.SimplexAddon;
|
||||||
|
import io.github.simplexdev.simplexcore.utils.TickedTime;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -28,8 +29,8 @@ public abstract class SimplexTask implements Consumer<BukkitTask> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected SimplexTask() {
|
protected SimplexTask() {
|
||||||
DELAY = SimplexCorePlugin.getInstance().getTimeValues().SECOND() * 30; // 30 seconds until the task triggers for the first time.
|
DELAY = TickedTime.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.
|
INTERVAL = TickedTime.MINUTE * 5; // Task will run at 5 minute intervals once the first trigger has been called.
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends SimplexTask> void register(T task, SimplexAddon<?> plugin, boolean repeating, boolean delayed) {
|
public <T extends SimplexTask> void register(T task, SimplexAddon<?> plugin, boolean repeating, boolean delayed) {
|
||||||
|
@ -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;
|
||||||
|
}
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user