修复了区块强加前的清理操作因为世界未加载完成导致报错的问题
All checks were successful
Java CI-CD with Maven / build (push) Successful in 3m44s
All checks were successful
Java CI-CD with Maven / build (push) Successful in 3m44s
This commit is contained in:
parent
9f617e046e
commit
b6ea705fd6
@ -154,12 +154,19 @@ ForceLoadChunks:
|
||||
## 配置文件参考
|
||||
|
||||
```yaml
|
||||
# 附魔瓶经验值倍率
|
||||
ExpBottleRatio: 1.0
|
||||
|
||||
# 强加载区块列表
|
||||
ForceLoadChunks:
|
||||
# - world:0:0
|
||||
# - world_the_end:-12:12
|
||||
|
||||
# 区块操作延迟(强加载清理、设置) 秒
|
||||
# 过低可能导致世界未加载完成时触发操作引起报错
|
||||
# -1 为禁用强加载区块操作
|
||||
ChunkOperateDelay: 10
|
||||
|
||||
Debug: false
|
||||
```
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>EssentialsD</artifactId>
|
||||
<version>1.12.8</version>
|
||||
<version>1.12.10</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EssentialsD</name>
|
||||
|
@ -23,6 +23,7 @@ public class ConfigManager {
|
||||
_debug = _file.getBoolean("Debug", false);
|
||||
_exp_bottle_ratio = (float) _file.getDouble("ExpBottleRatio", 1.0);
|
||||
_force_load_chunks = _file.getStringList("ForceLoadChunks");
|
||||
_chunk_operate_delay = _file.getInt("ChunkOperateDelay", 10);
|
||||
}
|
||||
|
||||
public Boolean isDebug() {
|
||||
@ -45,40 +46,52 @@ public class ConfigManager {
|
||||
_plugin.saveConfig();
|
||||
}
|
||||
|
||||
public Integer getChunkOperateDelay() {
|
||||
return _chunk_operate_delay;
|
||||
}
|
||||
|
||||
public void setChunkOperateDelay(Integer delay) {
|
||||
_chunk_operate_delay = delay;
|
||||
_file.set("ChunkOperateDelay", delay);
|
||||
_plugin.saveConfig();
|
||||
}
|
||||
|
||||
public void ApplyForceLoadChunks() {
|
||||
// remove all force loaded chunks
|
||||
EssentialsD.globalScheduler.run(EssentialsD.instance, (instance) -> {
|
||||
if (_chunk_operate_delay < 0) {
|
||||
XLogger.info("加载区块操作已禁用");
|
||||
return;
|
||||
}
|
||||
EssentialsD.globalScheduler.runDelayed(EssentialsD.instance, (instance) -> {
|
||||
// remove all force loaded chunks
|
||||
int count = 0;
|
||||
for (World world : EssentialsD.instance.getServer().getWorlds()) {
|
||||
XLogger.debug("清除所有强加载区块: " + world.getName());
|
||||
Collection<Chunk> chunks = world.getForceLoadedChunks(); // todo 这里有问题
|
||||
Collection<Chunk> chunks = world.getForceLoadedChunks();
|
||||
for (Chunk chunk : chunks) {
|
||||
count++;
|
||||
world.setChunkForceLoaded(chunk.getX(), chunk.getZ(), false);
|
||||
}
|
||||
}
|
||||
XLogger.info("清除所有强加载区块: " + count);
|
||||
});
|
||||
// world:0:0
|
||||
for (String s : _force_load_chunks) {
|
||||
String[] split = s.split(":");
|
||||
if (split.length != 3) {
|
||||
XLogger.warn("ForceLoadChunks 配置错误: " + s);
|
||||
continue;
|
||||
}
|
||||
String world_name = split[0];
|
||||
int x = Integer.parseInt(split[1]);
|
||||
int z = Integer.parseInt(split[2]);
|
||||
World world = _plugin.getServer().getWorld(world_name);
|
||||
if (world == null) {
|
||||
XLogger.warn("ForceLoadChunks 配置错误: 世界 " + world_name + " 不存在");
|
||||
continue;
|
||||
}
|
||||
EssentialsD.globalScheduler.run(EssentialsD.instance, (instance) -> {
|
||||
// world:0:0
|
||||
for (String s : _force_load_chunks) {
|
||||
String[] split = s.split(":");
|
||||
if (split.length != 3) {
|
||||
XLogger.warn("ForceLoadChunks 配置错误: " + s);
|
||||
continue;
|
||||
}
|
||||
String world_name = split[0];
|
||||
int x = Integer.parseInt(split[1]);
|
||||
int z = Integer.parseInt(split[2]);
|
||||
World world = _plugin.getServer().getWorld(world_name);
|
||||
if (world == null) {
|
||||
XLogger.warn("ForceLoadChunks 配置错误: 世界 " + world_name + " 不存在");
|
||||
continue;
|
||||
}
|
||||
world.setChunkForceLoaded(x, z, true);
|
||||
XLogger.info("标记强加载区块: " + world_name + " " + x + " " + z);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, _chunk_operate_delay * 20);
|
||||
}
|
||||
|
||||
|
||||
@ -87,5 +100,6 @@ public class ConfigManager {
|
||||
private boolean _debug;
|
||||
private float _exp_bottle_ratio;
|
||||
private List<String> _force_load_chunks;
|
||||
private Integer _chunk_operate_delay;
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,14 @@
|
||||
# 附魔瓶经验值倍率
|
||||
ExpBottleRatio: 1.0
|
||||
|
||||
# 强加载区块列表
|
||||
ForceLoadChunks:
|
||||
# - world:0:0
|
||||
# - world_the_end:-12:12
|
||||
|
||||
# 区块操作延迟(强加载清理、设置) 秒
|
||||
# 过低可能导致世界未加载完成时触发操作引起报错
|
||||
# -1 为禁用强加载区块操作
|
||||
ChunkOperateDelay: 10
|
||||
|
||||
Debug: false
|
Loading…
Reference in New Issue
Block a user