diff --git a/pom.xml b/pom.xml
index 38e5229..2d1035b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.skymc
TabooLib
- 4.14
+ 4.15
UTF-8
diff --git a/src/main/java/me/skymc/taboolib/commands/TabooLibMainCommand.java b/src/main/java/me/skymc/taboolib/commands/TabooLibMainCommand.java
index 705133c..3e0d80b 100644
--- a/src/main/java/me/skymc/taboolib/commands/TabooLibMainCommand.java
+++ b/src/main/java/me/skymc/taboolib/commands/TabooLibMainCommand.java
@@ -9,11 +9,17 @@ import me.skymc.taboolib.commands.internal.type.CommandArgument;
import me.skymc.taboolib.commands.internal.type.CommandRegister;
import me.skymc.taboolib.commands.internal.type.CommandType;
import me.skymc.taboolib.commands.taboolib.*;
+import me.skymc.taboolib.database.GlobalDataManager;
import me.skymc.taboolib.fileutils.FileUtils;
import me.skymc.taboolib.inventory.ItemUtils;
+import me.skymc.taboolib.other.DateUtils;
import me.skymc.taboolib.other.NumberUtils;
import me.skymc.taboolib.player.PlayerUtils;
import me.skymc.taboolib.plugin.PluginUtils;
+import me.skymc.taboolib.timecycle.TimeCycle;
+import me.skymc.taboolib.timecycle.TimeCycleEvent;
+import me.skymc.taboolib.timecycle.TimeCycleInitializeEvent;
+import me.skymc.taboolib.timecycle.TimeCycleManager;
import me.skymc.taboolib.update.UpdateTask;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@@ -21,6 +27,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
+import java.util.concurrent.TimeUnit;
/**
* @Author sky
@@ -417,7 +424,9 @@ public class TabooLibMainCommand extends BaseMainCommand {
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
- new CycleListCommand(sender, args);
+ TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.HEAD");
+ TimeCycleManager.getTimeCycles().forEach(cycle -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.BODY", cycle.getName()));
+ TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.FOOT");
}
};
@@ -443,12 +452,24 @@ public class TabooLibMainCommand extends BaseMainCommand {
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
- new CycleInfoCommand(sender, args);
+ TimeCycle cycle = TimeCycleManager.getTimeCycle(args[0]);
+ if (cycle == null) {
+ TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[0]);
+ } else {
+ TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-INFO",
+ asString(cycle.getCycle() / 1000L),
+ cycle.getPlugin().getName(),
+ DateUtils.CH_ALL.format(TimeCycleManager.getBeforeTimeline(cycle.getName())),
+ DateUtils.CH_ALL.format(TimeCycleManager.getAfterTimeline(cycle.getName())));
+ }
}
- @Override
- public boolean ignoredLabel() {
- return false;
+ private String asString(long seconds) {
+ long day = TimeUnit.SECONDS.toDays(seconds);
+ long hours = TimeUnit.SECONDS.toHours(seconds) - day * 24;
+ long minute = TimeUnit.SECONDS.toMinutes(seconds) - TimeUnit.SECONDS.toHours(seconds) * 60L;
+ long second = TimeUnit.SECONDS.toSeconds(seconds) - TimeUnit.SECONDS.toMinutes(seconds) * 60L;
+ return "§f" + day + "§7 天, §f" + hours + "§7 小时, §f" + minute + "§7 分钟, §f" + second + "§7 秒";
}
};
@@ -474,12 +495,24 @@ public class TabooLibMainCommand extends BaseMainCommand {
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
- new CycleResetCommand(sender, args);
- }
+ TimeCycle cycle = TimeCycleManager.getTimeCycle(args[0]);
+ if (cycle == null) {
+ TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[0]);
+ return;
+ }
+ new BukkitRunnable() {
- @Override
- public boolean ignoredLabel() {
- return false;
+ @Override
+ public void run() {
+ long time = new TimeCycleInitializeEvent(cycle, System.currentTimeMillis()).call().getTimeline();
+ // 初始化
+ GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(time));
+ // 触发器
+ Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
+ // 提示
+ TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-RESET", args[0]);
+ }
+ }.runTaskAsynchronously(Main.getInst());
}
};
@@ -505,12 +538,23 @@ public class TabooLibMainCommand extends BaseMainCommand {
@Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) {
- new CycleUpdateCommand(sender, args);
- }
+ TimeCycle cycle = TimeCycleManager.getTimeCycle(args[0]);
+ if (cycle == null) {
+ TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[0]);
+ return;
+ }
+ new BukkitRunnable() {
- @Override
- public boolean ignoredLabel() {
- return false;
+ @Override
+ public void run() {
+ // 重置
+ GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(System.currentTimeMillis()));
+ // 触发器
+ Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
+ // 提示
+ TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-UPDATE", args[0]);
+ }
+ }.runTaskAsynchronously(Main.getInst());
}
};
diff --git a/src/main/java/me/skymc/taboolib/commands/taboolib/CycleInfoCommand.java b/src/main/java/me/skymc/taboolib/commands/taboolib/CycleInfoCommand.java
deleted file mode 100644
index 6307c0c..0000000
--- a/src/main/java/me/skymc/taboolib/commands/taboolib/CycleInfoCommand.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package me.skymc.taboolib.commands.taboolib;
-
-import com.ilummc.tlib.resources.TLocale;
-import me.skymc.taboolib.commands.SubCommand;
-import me.skymc.taboolib.other.DateUtils;
-import me.skymc.taboolib.timecycle.TimeCycle;
-import me.skymc.taboolib.timecycle.TimeCycleManager;
-import org.bukkit.command.CommandSender;
-
-import java.util.concurrent.TimeUnit;
-
-public class CycleInfoCommand extends SubCommand {
-
- public CycleInfoCommand(CommandSender sender, String[] args) {
- super(sender, args);
- if (args.length < 2) {
- TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
- return;
- }
-
- TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]);
- if (cycle == null) {
- TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[2]);
- return;
- }
-
- TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-INFO",
- asString(cycle.getCycle() / 1000L),
- cycle.getPlugin().getName(),
- DateUtils.CH_ALL.format(TimeCycleManager.getBeforeTimeline(cycle.getName())),
- DateUtils.CH_ALL.format(TimeCycleManager.getAfterTimeline(cycle.getName())));
- }
-
- public String asString(long seconds) {
- long day = TimeUnit.SECONDS.toDays(seconds);
- long hours = TimeUnit.SECONDS.toHours(seconds) - day * 24;
- long minute = TimeUnit.SECONDS.toMinutes(seconds) - TimeUnit.SECONDS.toHours(seconds) * 60L;
- long second = TimeUnit.SECONDS.toSeconds(seconds) - TimeUnit.SECONDS.toMinutes(seconds) * 60L;
- return "§f" + day + "§7 天, §f" + hours + "§7 小时, §f" + minute + "§7 分钟, §f" + second + "§7 秒";
- }
-
- @Override
- public boolean command() {
- return true;
- }
-}
diff --git a/src/main/java/me/skymc/taboolib/commands/taboolib/CycleListCommand.java b/src/main/java/me/skymc/taboolib/commands/taboolib/CycleListCommand.java
deleted file mode 100644
index 63561e5..0000000
--- a/src/main/java/me/skymc/taboolib/commands/taboolib/CycleListCommand.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package me.skymc.taboolib.commands.taboolib;
-
-import com.ilummc.tlib.resources.TLocale;
-import me.skymc.taboolib.commands.SubCommand;
-import me.skymc.taboolib.timecycle.TimeCycleManager;
-import org.bukkit.command.CommandSender;
-
-public class CycleListCommand extends SubCommand {
-
- public CycleListCommand(CommandSender sender, String[] args) {
- super(sender, args);
-
- TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.HEAD");
-
- TimeCycleManager.getTimeCycles().forEach(cycle -> TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.BODY", cycle.getName()));
-
- TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.LIST.FOOT");
- }
-
- @Override
- public boolean command() {
- return true;
- }
-
-}
diff --git a/src/main/java/me/skymc/taboolib/commands/taboolib/CycleResetCommand.java b/src/main/java/me/skymc/taboolib/commands/taboolib/CycleResetCommand.java
deleted file mode 100644
index 5af4875..0000000
--- a/src/main/java/me/skymc/taboolib/commands/taboolib/CycleResetCommand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package me.skymc.taboolib.commands.taboolib;
-
-import com.ilummc.tlib.resources.TLocale;
-import me.skymc.taboolib.Main;
-import me.skymc.taboolib.commands.SubCommand;
-import me.skymc.taboolib.database.GlobalDataManager;
-import me.skymc.taboolib.timecycle.TimeCycle;
-import me.skymc.taboolib.timecycle.TimeCycleEvent;
-import me.skymc.taboolib.timecycle.TimeCycleInitializeEvent;
-import me.skymc.taboolib.timecycle.TimeCycleManager;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.scheduler.BukkitRunnable;
-
-public class CycleResetCommand extends SubCommand {
-
- public CycleResetCommand(CommandSender sender, String[] args) {
- super(sender, args);
- if (args.length < 2) {
- TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
- return;
- }
-
- TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]);
- if (cycle == null) {
- TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[2]);
- return;
- }
-
- new BukkitRunnable() {
-
- @Override
- public void run() {
- long time = new TimeCycleInitializeEvent(cycle, System.currentTimeMillis()).call().getTimeline();
- // 初始化
- GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(time));
- // 触发器
- Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
- // 提示
- TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-RESET", args[2]);
- }
- }.runTaskAsynchronously(Main.getInst());
- }
-
- @Override
- public boolean command() {
- return true;
- }
-
-}
diff --git a/src/main/java/me/skymc/taboolib/commands/taboolib/CycleUpdateCommand.java b/src/main/java/me/skymc/taboolib/commands/taboolib/CycleUpdateCommand.java
deleted file mode 100644
index ad2ff66..0000000
--- a/src/main/java/me/skymc/taboolib/commands/taboolib/CycleUpdateCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package me.skymc.taboolib.commands.taboolib;
-
-import com.ilummc.tlib.resources.TLocale;
-import me.skymc.taboolib.Main;
-import me.skymc.taboolib.commands.SubCommand;
-import me.skymc.taboolib.database.GlobalDataManager;
-import me.skymc.taboolib.timecycle.TimeCycle;
-import me.skymc.taboolib.timecycle.TimeCycleEvent;
-import me.skymc.taboolib.timecycle.TimeCycleManager;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.scheduler.BukkitRunnable;
-
-public class CycleUpdateCommand extends SubCommand {
-
- public CycleUpdateCommand(CommandSender sender, String[] args) {
- super(sender, args);
- if (args.length < 2) {
- TLocale.sendTo(sender, "COMMANDS.PARAMETER.UNKNOWN");
- return;
- }
-
- TimeCycle cycle = TimeCycleManager.getTimeCycle(args[2]);
- if (cycle == null) {
- TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.INVALID-CYCLE", args[2]);
- return;
- }
-
- new BukkitRunnable() {
-
- @Override
- public void run() {
- // 重置
- GlobalDataManager.setVariable("timecycle:" + cycle.getName(), String.valueOf(System.currentTimeMillis()));
- // 触发器
- Bukkit.getPluginManager().callEvent(new TimeCycleEvent(cycle));
- // 提示
- TLocale.sendTo(sender, "COMMANDS.TABOOLIB.TIMECYCLE.CYCLE-UPDATE", args[2]);
- }
- }.runTaskAsynchronously(Main.getInst());
- }
-
- @Override
- public boolean command() {
- return true;
- }
-
-}