|
|
|
@@ -93,6 +93,8 @@ implements SubtitleChatMonitor.Listener, BaritoneBridge.PathListener {
|
|
|
|
|
private boolean eating;
|
|
|
|
|
/** Baritone 最近一次路径计算是否失败(目标不可达);由事件监听设置,寻路阶段消费 */
|
|
|
|
|
private volatile boolean pathCalcFailed;
|
|
|
|
|
/** 等待开拓时段自动开始:不在 11:00-22:00 时点击开始会暂存配置,进入时段后自动启动(null 表示无等待任务) */
|
|
|
|
|
private ExpansionConfig pendingStart;
|
|
|
|
|
|
|
|
|
|
public ExpansionController(TerritoryDataService dataService) {
|
|
|
|
|
this.dataService = dataService;
|
|
|
|
@@ -140,6 +142,11 @@ implements SubtitleChatMonitor.Listener, BaritoneBridge.PathListener {
|
|
|
|
|
return this.state != State.IDLE && this.state != State.COMPLETE && this.state != State.STOPPED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @return 是否处于"等待开拓时段自动开始"状态 */
|
|
|
|
|
public boolean isWaitingForClaimTime() {
|
|
|
|
|
return this.pendingStart != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断当前现实时间(本地时区)是否在允许开拓的时间段内。
|
|
|
|
|
* 仅 11:00(含)到 22:00(不含)允许开拓,其余时段服务器会拒绝开拓。
|
|
|
|
@@ -171,14 +178,15 @@ implements SubtitleChatMonitor.Listener, BaritoneBridge.PathListener {
|
|
|
|
|
this.status = "Baritone \u5c1a\u672a\u521d\u59cb\u5316\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// 现实时间限制:仅 11:00-22:00 允许开拓,其余时段服务器会拒绝开拓(等待超时)
|
|
|
|
|
// 现实时间限制:仅 11:00-22:00 允许开拓,其余时段服务器会拒绝开拓(等待超时)。
|
|
|
|
|
// 不在时段时不再直接拒绝,而是登记"等待自动开始":进入时段后由 tick() 自动启动。
|
|
|
|
|
if (!ExpansionController.isWithinClaimTime()) {
|
|
|
|
|
this.status = "\u4e0d\u5728\u5f00\u62d3\u65f6\u9650\u5185\uff0811:00-22:00\uff09\uff0c\u65e0\u6cd5\u5f00\u62d3";
|
|
|
|
|
this.setState(State.IDLE, this.status);
|
|
|
|
|
this.log("\u542f\u52a8\u5931\u8d25\uff1a\u4e0d\u5728\u5f00\u62d3\u65f6\u9650\u5185\uff0c\u5f53\u524d\u73b0\u5b9e\u65f6\u95f4 " + LocalTime.now().format(LOG_TIME_FORMAT));
|
|
|
|
|
this.pendingStart = requestedConfig.copy();
|
|
|
|
|
this.setState(State.IDLE, "\u7b49\u5f85\u5f00\u62d3\u65f6\u6bb5\uff0c11:00 \u81ea\u52a8\u5f00\u59cb");
|
|
|
|
|
this.log("\u4e0d\u5728\u5f00\u62d3\u65f6\u6bb5\u5185\uff0811:00-22:00\uff09\uff0c\u5df2\u767b\u8bb0\u81ea\u52a8\u5f00\u59cb\uff0c\u5f53\u524d\u73b0\u5b9e\u65f6\u95f4 " + LocalTime.now().format(LOG_TIME_FORMAT));
|
|
|
|
|
// 给玩家发送聊天栏提示,避免玩家未打开 GUI 时看不到原因
|
|
|
|
|
client.player.sendMessage(Text.literal("[AutoStore] \u4e0d\u5728\u5f00\u62d3\u65f6\u9650\u5185\uff0811:00-22:00\uff09\uff0c\u65e0\u6cd5\u5f00\u62d3"), false);
|
|
|
|
|
return false;
|
|
|
|
|
client.player.sendMessage(Text.literal("[AutoStore] \u4e0d\u5728\u5f00\u62d3\u65f6\u6bb5\u5185\uff0811:00-22:00\uff09\uff0c\u5df2\u767b\u8bb0\uff1a\u8fdb\u5165\u65f6\u6bb5\u540e\u81ea\u52a8\u5f00\u59cb"), false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
this.config = requestedConfig.copy();
|
|
|
|
|
this.model = this.dataService.model();
|
|
|
|
@@ -214,8 +222,14 @@ implements SubtitleChatMonitor.Listener, BaritoneBridge.PathListener {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 手动停止任务:取消 Baritone 寻路并进入 STOPPED 状态 */
|
|
|
|
|
/** 手动停止任务:取消 Baritone 寻路并进入 STOPPED 状态;若处于等待自动开始,则取消等待 */
|
|
|
|
|
public void stop() {
|
|
|
|
|
if (this.pendingStart != null) {
|
|
|
|
|
this.pendingStart = null;
|
|
|
|
|
this.setState(State.IDLE, "\u5df2\u53d6\u6d88\u81ea\u52a8\u5f00\u59cb");
|
|
|
|
|
this.log("\u5df2\u53d6\u6d88\u7b49\u5f85\u81ea\u52a8\u5f00\u59cb");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (this.state == State.IDLE || this.state == State.COMPLETE || this.state == State.STOPPED) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@@ -240,6 +254,13 @@ implements SubtitleChatMonitor.Listener, BaritoneBridge.PathListener {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.playerChunk = this.playerChunk(client);
|
|
|
|
|
// 等待开拓时段自动开始:进入 11:00-22:00 后自动启动已登记的任务
|
|
|
|
|
if (this.pendingStart != null && ExpansionController.isWithinClaimTime()) {
|
|
|
|
|
ExpansionConfig pending = this.pendingStart;
|
|
|
|
|
this.pendingStart = null;
|
|
|
|
|
this.log("\u5df2\u8fdb\u5165\u5f00\u62d3\u65f6\u6bb5\uff0c\u81ea\u52a8\u5f00\u59cb");
|
|
|
|
|
this.start(pending);
|
|
|
|
|
}
|
|
|
|
|
// 现实时间限制:运行中超出 11:00-22:00 则自动停止,避免服务器拒绝开拓导致超时
|
|
|
|
|
if (this.isRunning() && !ExpansionController.isWithinClaimTime()) {
|
|
|
|
|
this.stop();
|
|
|
|
|