v1.1.9: 增加现实时间限制,仅 11:00-22:00 允许开拓
这个提交包含在:
@@ -50,6 +50,10 @@ implements SubtitleChatMonitor.Listener, BaritoneBridge.PathListener {
|
||||
private static final int MAX_LOGS = 2000;
|
||||
/** 日志时间戳格式(时:分:秒) */
|
||||
private static final DateTimeFormatter LOG_TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
/** 允许开拓的现实时间起始小时(含,本地时区) */
|
||||
private static final int CLAIM_START_HOUR = 11;
|
||||
/** 允许开拓的现实时间结束小时(不含,本地时区),即 22:00 起停止开拓 */
|
||||
private static final int CLAIM_END_HOUR = 22;
|
||||
/** Baritone 寻路桥接(负责自动移动) */
|
||||
private final BaritoneBridge baritoneBridge = new BaritoneBridge();
|
||||
/** 扩地规划器(决定下一个目标区块) */
|
||||
@@ -135,6 +139,17 @@ implements SubtitleChatMonitor.Listener, BaritoneBridge.PathListener {
|
||||
return this.state != State.IDLE && this.state != State.COMPLETE && this.state != State.STOPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前现实时间(本地时区)是否在允许开拓的时间段内。
|
||||
* 仅 11:00(含)到 22:00(不含)允许开拓,其余时段服务器会拒绝开拓。
|
||||
*
|
||||
* @return true 表示当前在允许开拓时段内
|
||||
*/
|
||||
public static boolean isWithinClaimTime() {
|
||||
int hour = LocalTime.now().getHour();
|
||||
return hour >= CLAIM_START_HOUR && hour < CLAIM_END_HOUR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动自动扩地任务。
|
||||
*
|
||||
@@ -155,6 +170,13 @@ 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 允许开拓,其余时段服务器会拒绝开拓(等待超时)
|
||||
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));
|
||||
return false;
|
||||
}
|
||||
this.config = requestedConfig.copy();
|
||||
this.model = this.dataService.model();
|
||||
this.playerChunk = this.playerChunk(client);
|
||||
@@ -215,6 +237,13 @@ implements SubtitleChatMonitor.Listener, BaritoneBridge.PathListener {
|
||||
return;
|
||||
}
|
||||
this.playerChunk = this.playerChunk(client);
|
||||
// 现实时间限制:运行中超出 11:00-22:00 则自动停止,避免服务器拒绝开拓导致超时
|
||||
if (this.isRunning() && !ExpansionController.isWithinClaimTime()) {
|
||||
this.stop();
|
||||
this.status = "\u5df2\u5230\u5f00\u62d3\u65f6\u9650\u5916\uff0811:00-22:00\uff09\uff0c\u4efb\u52a1\u505c\u6b62";
|
||||
this.log("\u5df2\u5230\u5f00\u62d3\u65f6\u9650\u5916\uff0c\u505c\u6b62\u4efb\u52a1\uff08\u5f53\u524d\u73b0\u5b9e\u65f6\u95f4 " + LocalTime.now().format(LOG_TIME_FORMAT) + "\uff09");
|
||||
return;
|
||||
}
|
||||
if (this.tickAutoFood(client)) {
|
||||
return;
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户