diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 2eaed961..74b860f1 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -715,6 +715,47 @@ public class CarpetSettings ) public static int viewDistance = 0; + private static class SimulationDistanceValidator extends Validator + { + @Override public Integer validate(ServerCommandSource source, ParsedRule currentRule, Integer newValue, String string) + { + if (currentRule.get().equals(newValue) || source == null) + { + return newValue; + } + if (newValue < 0 || newValue > 32) + { + Messenger.m(source, "r simulation distance has to be between 0 and 32"); + return null; + } + MinecraftServer server = source.getServer(); + + if (server.isDedicated()) + { + int vd = (newValue >= 2)?newValue:((DedicatedServer) server).getProperties().simulationDistance; + if (vd != server.getPlayerManager().getSimulationDistance()) + server.getPlayerManager().setSimulationDistance(vd); + return newValue; + } + else + { + Messenger.m(source, "r simulation distance can only be changed on a server"); + return 0; + } + } + @Override + public String description() { return "You must choose a value from 0 (use server settings) to 32";} + } + @Rule( + desc = "Changes the simulation distance of the server.", + extra = "Set to 0 to not override the value in server settings.", + options = {"0", "12", "16", "32"}, + category = CREATIVE, + strict = false, + validate = SimulationDistanceValidator.class + ) + public static int simulationDistance = 0; + public static class ChangeSpawnChunksValidator extends Validator { public static void changeSpawnSize(int size) { diff --git a/src/main/resources/assets/carpet/lang/zh_cn.json b/src/main/resources/assets/carpet/lang/zh_cn.json index fd15f51c..7746790a 100644 --- a/src/main/resources/assets/carpet/lang/zh_cn.json +++ b/src/main/resources/assets/carpet/lang/zh_cn.json @@ -187,6 +187,10 @@ "rule.viewDistance.desc": "改变服务器视距,设为0以使用默认值", "rule.viewDistance.extra.0": "你必须在0(使用服务器默认设置)-32取一个整数", + "rule.simulationDistance.name": "自定义模拟视距", + "rule.simulationDistance.desc": "改变服务器模拟视距,设为0以使用默认值", + "rule.simulationDistance.extra.0": "你必须在0(使用服务器默认设置)-32取一个整数", + "rule.xpNoCooldown.name": "经验吸收无冷却", "rule.xpNoCooldown.desc": "玩家吸收经验球时不会有冷却时间",