移除 WorldSettings 中的 Allow 配置

该功能本质上为 Limits.Amount,通过配置一个世界的数量为 0 可达到同样的效果。
This commit is contained in:
ZhangYuheng 2024-09-22 17:49:59 +08:00
parent ab0f2a95dd
commit e8271927ea
6 changed files with 16 additions and 12 deletions

View File

@ -406,11 +406,11 @@ public class ConfigManager {
XLogger.err(Translation.Config_Check_ToolNameError);
setTool("ARROW");
}
if (getAutoCreateRadius() == 0) {
if (getAutoCreateRadius() <= 0 && getAutoCreateRadius() != -1) {
XLogger.err(Translation.Config_Check_AutoCreateRadiusError);
setAutoCreateRadius(10);
}
if (getAutoCleanAfterDays() == 0) {
if (getAutoCleanAfterDays() <= 0 && getAutoCleanAfterDays() != -1) {
XLogger.err(Translation.Config_Check_AutoCleanAfterDaysError);
setAutoCleanAfterDays(180);
}

View File

@ -1,5 +1,6 @@
package cn.lunadeer.dominion.managers;
import cn.lunadeer.dominion.Dominion;
import cn.lunadeer.minecraftpluginutils.XLogger;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
@ -309,9 +310,17 @@ public class GroupLimit {
public List<String> getWorldBlackList() {
List<String> list = new ArrayList<>();
if (world_limits.getOrDefault("default", new WorldSetting("default")).amount == 0) {
list.addAll(Dominion.instance.getServer().getWorlds().stream().map(World::getName).toList());
}
for (Map.Entry<String, WorldSetting> entry : world_limits.entrySet()) {
if (!entry.getValue().allow) {
if (entry.getKey().equals("default")) {
continue;
}
if (entry.getValue().amount == 0) {
list.add(entry.getKey());
} else {
list.remove(entry.getKey());
}
}
return list;

View File

@ -15,7 +15,6 @@ public class WorldSetting {
public Integer amount;
public Integer depth;
public Boolean vert;
public Boolean allow = true;
private final String sourceName;
/**
@ -33,7 +32,6 @@ public class WorldSetting {
section.set("some_world_name.Amount", 10);
section.set("some_world_name.Depth", 3);
section.set("some_world_name.Vert", false);
section.set("some_world_name.Allow", false);
return section;
}
@ -53,7 +51,9 @@ public class WorldSetting {
setting.amount = worldSettings.getInt(worldName + ".Amount", 10);
setting.depth = worldSettings.getInt(worldName + ".Depth", 3);
setting.vert = worldSettings.getBoolean(worldName + ".Vert", false);
setting.allow = worldSettings.getBoolean(worldName + ".Allow", false);
if (worldSettings.contains(worldName + ".Allow") && !worldSettings.getBoolean(worldName + ".Allow")) {
setting.amount = 0;
}
world_limits.put(worldName, setting);
}
return world_limits;
@ -69,7 +69,6 @@ public class WorldSetting {
section.set("Amount", amount);
section.set("Depth", depth);
section.set("Vert", vert);
section.set("Allow", allow);
return section;
}
@ -91,7 +90,7 @@ public class WorldSetting {
XLogger.err(Translation.Config_Check_GroupSizeZError, sourceName);
size_z = 128;
}
if (amount <= 0 && amount != -1) {
if (amount < 0 && amount != -1) {
XLogger.err(Translation.Config_Check_GroupAmountError, sourceName);
amount = 10;
}

View File

@ -35,7 +35,6 @@ Limit:
Amount: 10
Depth: 3
Vert: false
Allow: false
Teleport:
Enable: true

View File

@ -19,4 +19,3 @@ WorldSettings:
Amount: 10
Depth: 3
Vert: false
Allow: false

View File

@ -45,7 +45,6 @@ Limit:
Amount: 10
Depth: 3
Vert: false
Allow: false
Teleport:
Enable: true
@ -135,7 +134,6 @@ Timer: false # 性能测试计时器
- Depth子领地深度、0表示不允许子领地、 -1表示不限制
- Vert当设置为 `true`玩家选择区域创建或者自动创建领地会自动将Y向下向上延伸到MinY和MaxY。**同时也会根据 MinY 和 MaxY 的设置自动调整 SizeY 的配置保证数值逻辑一致。**
- WorldSettings单独设置某个世界的圈地规则如不设置则使用上述默认规则
- Allow是否允许在此世界圈地
> 您服务器世界的名称应该避免使用 `default` 这样的特殊单词,否则会导致不可预料的意外错误。