1
mirror of https://github.com/CarmJos/ScriptItems synced 2026-07-15 07:21:23 +08:00

测试时间限制

This commit is contained in:
2022-03-13 12:44:00 +08:00
parent d28dc5319e
commit b0b94a4b95
3 changed files with 11 additions and 6 deletions
@@ -1,6 +1,7 @@
package cc.carm.plugin.commanditem.item;
import cc.carm.lib.easysql.api.util.TimeDateUtils;
import cc.carm.plugin.commanditem.Main;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -17,6 +18,7 @@ public class ItemRestrictions {
public ItemRestrictions(long startTime, long endTime) {
this.startTime = startTime;
this.endTime = endTime;
Main.debugging("ItemRestrictions: " + startTime + " -> " + endTime);
}
/**
@@ -34,14 +36,17 @@ public class ItemRestrictions {
}
public CheckResult check() {
if (startTime > 0 && startTime > System.currentTimeMillis()) return CheckResult.NOT_STARTED;
if (endTime > 0 && endTime < System.currentTimeMillis()) return CheckResult.EXPIRED;
if (getStartTime() < 0 && getEndTime() < 0) return CheckResult.AVAILABLE;
if (getStartTime() > 0 && getEndTime() > 0 && getStartTime() > getEndTime()) return CheckResult.INVALID;
if (getStartTime() > 0 && getStartTime() > System.currentTimeMillis()) return CheckResult.NOT_STARTED;
if (getEndTime() > 0 && getEndTime() < System.currentTimeMillis()) return CheckResult.EXPIRED;
return CheckResult.AVAILABLE;
}
public enum CheckResult {
AVAILABLE,
INVALID,
NOT_STARTED,
EXPIRED;
@@ -54,8 +54,8 @@ public class ItemListener implements Listener {
ItemActionGroup actions = commandItem.getConfiguration().getPlayerActions(player);
if (actions == null) return;
actions.execute(player);
updateTime(player.getUniqueId());
actions.execute(player);
}
/**