Merge remote-tracking branch 'origin/master'

# Conflicts:
#	build.gradle.kts
This commit is contained in:
zhangyuheng 2024-09-08 18:12:30 +08:00
commit 9a402199d1
16 changed files with 537 additions and 725 deletions

View File

@ -7,7 +7,7 @@
[![bStats](https://img.shields.io/badge/bStats-Statistics-eacd76?logo=google-analytics)](https://bstats.org/plugin/bukkit/Dominion/21445)
[![Hangar](https://img.shields.io/badge/Hangar-Project-bacac6?logo=paper)](https://hangar.papermc.io/zhangyuheng/Dominion)
[![Documentation](https://img.shields.io/badge/在线文档-点击跳转-70f3ff?logo=readthedocs)](https://ssl.lunadeer.cn:14448/doc/23/)
[![Documentation](https://img.shields.io/badge/在线文档-点击跳转-70f3ff?logo=readthedocs)](https://dominion.lunadeer.cn/)
[![Latest Build](https://img.shields.io/github/v/release/ColdeZhang/Dominion?label=%E6%9C%80%E6%96%B0%E6%9E%84%E5%BB%BA%E4%B8%8B%E8%BD%BD&logo=github&color=0aa344)](https://github.com/ColdeZhang/Dominion/releases/latest)
[![Latest Build](https://img.shields.io/github/v/release/ColdeZhang/Dominion?label=%E5%A4%87%E7%94%A8%E4%B8%8B%E8%BD%BD%E5%9C%B0%E5%9D%80&logo=gitea&color=0aa344)](https://ssl.lunadeer.cn:14446/mirror/Dominion/releases)

View File

@ -4,7 +4,7 @@ plugins {
}
group = "cn.lunadeer"
version = "2.5.8-beta"
version = "2.6.2-beta"
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
@ -41,10 +41,6 @@ allprojects {
tasks.processResources {
outputs.upToDateWhen { false }
// copy languages folder from PROJECT_DIR/languages to core/src/main/resources
from(file("${projectDir}/languages")) {
into("languages")
}
// replace @version@ in plugin.yml with project version
filesMatching("**/plugin.yml") {
filter {

View File

@ -1,280 +0,0 @@
package cn.lunadeer.dominion.commands;
import cn.lunadeer.dominion.Dominion;
import cn.lunadeer.dominion.managers.Translation;
import cn.lunadeer.minecraftpluginutils.Notification;
import org.bukkit.command.CommandSender;
import static cn.lunadeer.dominion.utils.CommandUtils.hasPermission;
public class SetConfig {
@Deprecated
public static void handler(CommandSender sender, String[] args) {
if (!hasPermission(sender, "dominion.admin")) {
return;
}
if (args.length < 2) {
Notification.error(sender, Translation.Commands_ArgumentsNotEnough);
return;
}
switch (args[1]) {
case "auto_create_radius":
setAutoCreateRadius(sender, args);
break;
case "limit_max_y":
setLimitMaxY(sender, args);
break;
case "limit_min_y":
setLimitMinY(sender, args);
break;
case "limit_size_x":
setLimitSizeX(sender, args);
break;
case "limit_size_z":
setLimitSizeZ(sender, args);
break;
case "limit_size_y":
setLimitSizeY(sender, args);
break;
case "limit_amount":
setLimitAmount(sender, args);
break;
case "limit_depth":
setLimitDepth(sender, args);
break;
case "limit_vert":
setLimitVert(sender, args);
break;
case "limit_op_bypass":
setLimitOpBypass(sender, args);
break;
case "tp_enable":
setTpEnable(sender, args);
break;
case "tp_delay":
setTpDelay(sender, args);
break;
case "tp_cool_down":
setTpCoolDown(sender, args);
break;
case "economy_enable":
setEconomyEnable(sender, args);
break;
case "economy_price":
setEconomyPrice(sender, args);
break;
case "economy_only_xz":
setEconomyOnlyXZ(sender, args);
break;
case "economy_refund":
setEconomyRefund(sender, args);
break;
case "residence_migration":
setResidenceMigration(sender, args);
break;
case "spawn_protection":
setSpawnProtection(sender, args);
break;
default:
Notification.error(sender, Translation.Commands_UnknownArgument);
}
}
public static void refreshPageOrNot(CommandSender sender, String[] args) {
if (args.length == 4) {
int page = Integer.parseInt(args[3]);
String[] newArgs = new String[2];
newArgs[0] = "config";
newArgs[1] = String.valueOf(page);
// SysConfig.show(sender, newArgs);
}
}
private static void setAutoCreateRadius(CommandSender sender, String[] args) {
int size = Integer.parseInt(args[2]);
if (size <= 0) {
Dominion.config.setAutoCreateRadius(1);
Notification.error(sender, Translation.Config_Check_AutoCreateRadiusError);
} else {
Dominion.config.setAutoCreateRadius(size);
}
refreshPageOrNot(sender, args);
}
private static void adjustSizeY() {
if (Dominion.config.getLimitVert(null)) {
Dominion.config.setLimitSizeY(Dominion.config.getLimitMaxY(null) - Dominion.config.getLimitMinY(null) + 1);
}
}
private static void setLimitMaxY(CommandSender sender, String[] args) {
int maxY = Integer.parseInt(args[2]);
if (maxY <= Dominion.config.getLimitMinY(null)) {
Notification.error(sender, Translation.Commands_SetConfig_MinYShouldBeLessThanMaxY);
return;
}
Dominion.config.setLimitMaxY(maxY);
adjustSizeY();
refreshPageOrNot(sender, args);
}
private static void setLimitMinY(CommandSender sender, String[] args) {
int minY = Integer.parseInt(args[2]);
if (minY >= Dominion.config.getLimitMaxY(null)) {
Notification.error(sender, Translation.Commands_SetConfig_MaxYShouldBeGreaterThanMinY);
return;
}
Dominion.config.setLimitMinY(minY);
adjustSizeY();
refreshPageOrNot(sender, args);
}
private static void setLimitSizeX(CommandSender sender, String[] args) {
int sizeX = Integer.parseInt(args[2]);
if (sizeX != -1 && sizeX < 4) {
Dominion.config.setLimitSizeX(4);
Notification.error(sender, Translation.Commands_SetConfig_SizeXShouldBeGreaterThan4);
} else {
Dominion.config.setLimitSizeX(sizeX);
}
refreshPageOrNot(sender, args);
}
private static void setLimitSizeZ(CommandSender sender, String[] args) {
int sizeZ = Integer.parseInt(args[2]);
if (sizeZ != -1 && sizeZ < 4) {
Dominion.config.setLimitSizeZ(4);
Notification.error(sender, Translation.Commands_SetConfig_SizeZShouldBeGreaterThan4);
return;
} else {
Dominion.config.setLimitSizeZ(sizeZ);
}
refreshPageOrNot(sender, args);
}
private static void setLimitSizeY(CommandSender sender, String[] args) {
int sizeY = Integer.parseInt(args[2]);
if (sizeY != -1 && sizeY < 4) {
Dominion.config.setLimitSizeY(4);
Notification.error(sender, Translation.Commands_SetConfig_SizeYShouldBeGreaterThan4);
} else {
Dominion.config.setLimitSizeY(sizeY);
}
refreshPageOrNot(sender, args);
}
private static void setLimitAmount(CommandSender sender, String[] args) {
int amount = Integer.parseInt(args[2]);
if (amount != -1 && amount < 0) {
Dominion.config.setLimitAmount(0);
Notification.error(sender, Translation.Commands_SetConfig_AmountShouldBeGreaterThan0);
} else {
Dominion.config.setLimitAmount(amount);
}
refreshPageOrNot(sender, args);
}
private static void setLimitDepth(CommandSender sender, String[] args) {
int depth = Integer.parseInt(args[2]);
if (depth != -1 && depth < 0) {
Dominion.config.setLimitDepth(0);
Notification.error(sender, Translation.Commands_SetConfig_DepthShouldBeGreaterThan0);
} else {
Dominion.config.setLimitDepth(depth);
}
refreshPageOrNot(sender, args);
}
private static void setLimitVert(CommandSender sender, String[] args) {
boolean limitVert = Boolean.parseBoolean(args[2]);
Dominion.config.setLimitVert(limitVert);
adjustSizeY();
refreshPageOrNot(sender, args);
}
private static void setLimitOpBypass(CommandSender sender, String[] args) {
boolean limitOpBypass = Boolean.parseBoolean(args[2]);
Dominion.config.setLimitOpBypass(limitOpBypass);
refreshPageOrNot(sender, args);
}
private static void setTpEnable(CommandSender sender, String[] args) {
boolean tpEnable = Boolean.parseBoolean(args[2]);
Dominion.config.setTpEnable(tpEnable);
refreshPageOrNot(sender, args);
}
private static void setTpDelay(CommandSender sender, String[] args) {
int tpDelay = Integer.parseInt(args[2]);
if (tpDelay < 0) {
Dominion.config.setTpDelay(0);
Notification.error(sender, Translation.Commands_SetConfig_TpDelayShouldBeGreaterThan0);
} else {
Dominion.config.setTpDelay(tpDelay);
}
refreshPageOrNot(sender, args);
}
private static void setTpCoolDown(CommandSender sender, String[] args) {
int tpCoolDown = Integer.parseInt(args[2]);
if (tpCoolDown < 0) {
Dominion.config.setTpCoolDown(0);
Notification.error(sender, Translation.Commands_SetConfig_TpCoolDownShouldBeGreaterThan0);
} else {
Dominion.config.setTpCoolDown(tpCoolDown);
}
refreshPageOrNot(sender, args);
}
private static void setEconomyEnable(CommandSender sender, String[] args) {
boolean economyEnable = Boolean.parseBoolean(args[2]);
Dominion.config.setEconomyEnable(economyEnable);
refreshPageOrNot(sender, args);
}
private static void setEconomyPrice(CommandSender sender, String[] args) {
float economyPrice = Float.parseFloat(args[2]);
if (economyPrice < 0) {
Dominion.config.setEconomyPrice(0.0f);
Notification.error(sender, Translation.Commands_SetConfig_PriceShouldBeGreaterThan0);
} else {
Dominion.config.setEconomyPrice(economyPrice);
}
refreshPageOrNot(sender, args);
}
private static void setEconomyOnlyXZ(CommandSender sender, String[] args) {
boolean economyOnlyXZ = Boolean.parseBoolean(args[2]);
Dominion.config.setEconomyOnlyXZ(economyOnlyXZ);
refreshPageOrNot(sender, args);
}
private static void setEconomyRefund(CommandSender sender, String[] args) {
float economyRefund = Float.parseFloat(args[2]);
if (economyRefund < 0) {
Dominion.config.setEconomyRefund(0.0f);
Notification.error(sender, Translation.Commands_SetConfig_RefundShouldBeGreaterThan0);
} else {
Dominion.config.setEconomyRefund(economyRefund);
}
refreshPageOrNot(sender, args);
}
private static void setResidenceMigration(CommandSender sender, String[] args) {
boolean residenceMigration = Boolean.parseBoolean(args[2]);
Dominion.config.setResidenceMigration(residenceMigration);
refreshPageOrNot(sender, args);
}
private static void setSpawnProtection(CommandSender sender, String[] args) {
int spawnProtection = Integer.parseInt(args[2]);
if (spawnProtection != -1 && spawnProtection <= 0) {
Dominion.config.setSpawnProtection(1);
Notification.error(sender, Translation.Commands_SetConfig_SpawnProtectRadiusShouldBeGreaterThan0);
} else {
Dominion.config.setSpawnProtection(spawnProtection);
}
refreshPageOrNot(sender, args);
}
}

View File

@ -103,6 +103,14 @@ public class DominionController {
operator.setResponse(FAIL.addMessage(Translation.Messages_SelectPointsWorldNotSame));
return;
}
if (operator.getLocation() == null) {
operator.setResponse(FAIL.addMessage(Translation.Messages_CommandPlayerOnly));
return;
}
if (!loc1.getWorld().getUID().equals(operator.getLocation().getWorld().getUID())) {
operator.setResponse(FAIL.addMessage(Translation.Messages_CrossWorldOperationDisallowed));
return;
}
// 检查世界是否可以创建
if (worldNotValid(operator, loc1.getWorld().getName())) {
operator.setResponse(FAIL.addMessage(Translation.Messages_CreateDominionDisabledWorld, loc1.getWorld().getName()));

View File

@ -5,6 +5,7 @@ import cn.lunadeer.dominion.dtos.Flag;
import cn.lunadeer.minecraftpluginutils.VaultConnect.VaultConnect;
import cn.lunadeer.minecraftpluginutils.XLogger;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@ -16,7 +17,10 @@ import java.util.List;
import java.util.Map;
public class ConfigManager {
public static ConfigManager instance;
public ConfigManager(Dominion plugin) {
instance = this;
new Translation(plugin);
_plugin = plugin;
_plugin.saveDefaultConfig();
@ -38,36 +42,17 @@ public class ConfigManager {
_db_user = _file.getString("Database.User", "postgres");
_db_pass = _file.getString("Database.Pass", "postgres");
_auto_create_radius = _file.getInt("AutoCreateRadius", 10);
if (_auto_create_radius == 0) {
XLogger.err(Translation.Config_Check_AutoCreateRadiusError);
setAutoCreateRadius(10);
}
_spawn_protection = _file.getInt("Limit.SpawnProtection", 10);
_blue_map = _file.getBoolean("BlueMap", false);
_dynmap = _file.getBoolean("Dynmap", false);
_auto_clean_after_days = _file.getInt("AutoCleanAfterDays", 180);
if (_auto_clean_after_days == 0) {
XLogger.err(Translation.Config_Check_AutoCleanAfterDaysError);
setAutoCleanAfterDays(180);
}
_limit_op_bypass = _file.getBoolean("Limit.OpByPass", true);
_check_update = _file.getBoolean("CheckUpdate", true);
_tp_enable = _file.getBoolean("Teleport.Enable", false);
_tp_delay = _file.getInt("Teleport.Delay", 0);
if (_tp_delay < 0) {
XLogger.err(Translation.Config_Check_TpDelayError);
setTpDelay(0);
}
_tp_cool_down = _file.getInt("Teleport.CoolDown", 0);
if (_tp_cool_down < 0) {
XLogger.err(Translation.Config_Check_TpCoolDownError);
setTpCoolDown(0);
}
_tool = _file.getString("Tool", "ARROW");
if (Material.getMaterial(_tool) == null) {
XLogger.err(Translation.Config_Check_ToolNameError);
setTool("ARROW");
}
_economy_enable = _file.getBoolean("Economy.Enable", false);
if (getEconomyEnable()) {
new VaultConnect(this._plugin);
@ -79,60 +64,26 @@ public class ConfigManager {
_group_title_suffix = _file.getString("GroupTitle.Suffix", "&#ffffff]");
GroupLimit defaultGroup = new GroupLimit();
defaultGroup.setLimitSizeX(_file.getInt("Limit.SizeX", 128));
defaultGroup.setLimitSizeY(_file.getInt("Limit.SizeY", 64));
defaultGroup.setLimitSizeZ(_file.getInt("Limit.SizeZ", 128));
defaultGroup.setLimitMinY(_file.getInt("Limit.MinY", -64));
defaultGroup.setLimitMaxY(_file.getInt("Limit.MaxY", 320));
defaultGroup.setLimitAmount(_file.getInt("Limit.Amount", 10));
defaultGroup.setLimitDepth(_file.getInt("Limit.Depth", 3));
defaultGroup.setLimitVert(_file.getBoolean("Limit.Vert", false));
defaultGroup.setWorldBlackList(_file.getStringList("Limit.WorldBlackList"));
defaultGroup.setLimitSizeX(_file.getInt("Limit.SizeX", 128), null);
defaultGroup.setLimitSizeY(_file.getInt("Limit.SizeY", 64), null);
defaultGroup.setLimitSizeZ(_file.getInt("Limit.SizeZ", 128), null);
defaultGroup.setLimitMinY(_file.getInt("Limit.MinY", -64), null);
defaultGroup.setLimitMaxY(_file.getInt("Limit.MaxY", 320), null);
defaultGroup.setLimitAmount(_file.getInt("Limit.Amount", 10), null);
defaultGroup.setLimitDepth(_file.getInt("Limit.Depth", 3), null);
defaultGroup.setLimitVert(_file.getBoolean("Limit.Vert", false), null);
defaultGroup.setPrice(_file.getDouble("Economy.Price", 10.0));
defaultGroup.setPriceOnlyXZ(_file.getBoolean("Economy.OnlyXZ", false));
defaultGroup.setRefundRatio(_file.getDouble("Economy.Refund", 0.85));
limits.put("default", defaultGroup);
ConfigurationSection worldSettings = _file.getConfigurationSection("Limit.WorldSettings");
if (worldSettings != null) {
defaultGroup.addWorldLimits(WorldSetting.load("config.yml", worldSettings));
}
groupLimits.put("default", defaultGroup);
if (defaultGroup.getLimitSizeX() <= 4 && defaultGroup.getLimitSizeX() != -1) {
XLogger.err(Translation.Config_Check_LimitSizeXError);
setLimitSizeX(128);
}
if (defaultGroup.getLimitSizeY() <= 4 && defaultGroup.getLimitSizeY() != -1) {
XLogger.err(Translation.Config_Check_LimitSizeYError);
setLimitSizeY(64);
}
if (defaultGroup.getLimitSizeZ() <= 4 && defaultGroup.getLimitSizeZ() != -1) {
XLogger.err(Translation.Config_Check_LimitSizeZError);
setLimitSizeZ(128);
}
if (defaultGroup.getLimitMinY() >= defaultGroup.getLimitMaxY()) {
XLogger.err(Translation.Config_Check_LimitMinYError);
setLimitMinY(-64);
setLimitMaxY(320);
}
if (defaultGroup.getRefundRatio() < 0.0 || defaultGroup.getRefundRatio() > 1.0) {
XLogger.err(Translation.Config_Check_RefundError);
setEconomyRefund(0.85f);
}
if (defaultGroup.getPrice() < 0.0) {
XLogger.err(Translation.Config_Check_PriceError);
setEconomyPrice(10.0f);
}
if (defaultGroup.getLimitVert() && defaultGroup.getLimitSizeY() <= defaultGroup.getLimitMaxY() - defaultGroup.getLimitMinY()) {
XLogger.warn(Translation.Config_Check_LimitSizeYAutoAdjust, (defaultGroup.getLimitMaxY() - defaultGroup.getLimitMinY() + 1));
setLimitSizeY(defaultGroup.getLimitMaxY() - defaultGroup.getLimitMinY() + 1);
}
if (defaultGroup.getLimitAmount() < 0 && defaultGroup.getLimitAmount() != -1) {
XLogger.err(Translation.Config_Check_AmountError);
setLimitAmount(10);
}
if (defaultGroup.getLimitDepth() < 0 && defaultGroup.getLimitDepth() != -1) {
XLogger.err(Translation.Config_Check_DepthError);
setLimitDepth(3);
}
limits.putAll(GroupLimit.loadGroups(_plugin));
groupLimits.putAll(GroupLimit.loadGroups(_plugin));
checkRules();
saveAll(); // 回写文件 防止文件中的数据不完整
Flag.loadFromFile(); // 加载 Flag 配置
}
@ -163,26 +114,26 @@ public class ConfigManager {
_file.setComments("Limit", List.of(Translation.Config_Comment_DefaultLimit.trans()));
_file.set("Limit.SpawnProtection", _spawn_protection);
_file.setInlineComments("Limit.SpawnProtection", List.of(Translation.Config_Comment_SpawnProtectRadius.trans() + Translation.Config_Comment_NegativeOneDisabled.trans()));
_file.set("Limit.MinY", limits.get("default").getLimitMinY());
_file.set("Limit.MinY", groupLimits.get("default").getLimitMinY(null));
_file.setInlineComments("Limit.MinY", List.of(Translation.Config_Comment_MinY.trans()));
_file.set("Limit.MaxY", limits.get("default").getLimitMaxY());
_file.set("Limit.MaxY", groupLimits.get("default").getLimitMaxY(null));
_file.setInlineComments("Limit.MaxY", List.of(Translation.Config_Comment_MaxY.trans()));
_file.set("Limit.SizeX", limits.get("default").getLimitSizeX());
_file.set("Limit.SizeX", groupLimits.get("default").getLimitSizeX(null));
_file.setInlineComments("Limit.SizeX", List.of(Translation.Config_Comment_SizeX.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
_file.set("Limit.SizeY", limits.get("default").getLimitSizeY());
_file.set("Limit.SizeY", groupLimits.get("default").getLimitSizeY(null));
_file.setInlineComments("Limit.SizeY", List.of(Translation.Config_Comment_SizeY.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
_file.set("Limit.SizeZ", limits.get("default").getLimitSizeZ());
_file.set("Limit.SizeZ", groupLimits.get("default").getLimitSizeZ(null));
_file.setInlineComments("Limit.SizeZ", List.of(Translation.Config_Comment_SizeZ.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
_file.set("Limit.Amount", limits.get("default").getLimitAmount());
_file.set("Limit.Amount", groupLimits.get("default").getLimitAmount(null));
_file.setInlineComments("Limit.Amount", List.of(Translation.Config_Comment_Amount.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
_file.set("Limit.Depth", limits.get("default").getLimitDepth());
_file.set("Limit.Depth", groupLimits.get("default").getLimitDepth(null));
_file.setInlineComments("Limit.Depth", List.of(Translation.Config_Comment_Depth.trans() + Translation.Config_Comment_ZeroDisabled.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
_file.set("Limit.Vert", limits.get("default").getLimitVert());
_file.set("Limit.Vert", groupLimits.get("default").getLimitVert(null));
_file.setInlineComments("Limit.Vert", List.of(Translation.Config_Comment_Vert.trans()));
_file.set("Limit.WorldBlackList", limits.get("default").getWorldBlackList());
_file.setInlineComments("Limit.WorldBlackList", List.of(Translation.Config_Comment_DisabledWorlds.trans()));
_file.set("Limit.OpByPass", _limit_op_bypass);
_file.setInlineComments("Limit.OpByPass", List.of(Translation.Config_Comment_OpBypass.trans()));
_file.set("Limit.WorldSettings", groupLimits.get("default").getWorldSettings());
_file.setInlineComments("Limit.WorldSettings", List.of(Translation.Config_Comment_WorldSettings.trans()));
_file.set("Teleport.Enable", _tp_enable);
_file.set("Teleport.Delay", _tp_delay);
@ -198,11 +149,11 @@ public class ConfigManager {
_file.setComments("Economy", Arrays.asList(Translation.Config_Comment_Economy.trans(), Translation.Config_Comment_VaultRequired.trans()));
_file.set("Economy.Enable", _economy_enable);
_file.set("Economy.Price", limits.get("default").getPrice());
_file.set("Economy.Price", groupLimits.get("default").getPrice());
_file.setInlineComments("Economy.Price", List.of(Translation.Config_Comment_Price.trans()));
_file.set("Economy.OnlyXZ", limits.get("default").getPriceOnlyXZ());
_file.set("Economy.OnlyXZ", groupLimits.get("default").getPriceOnlyXZ());
_file.setInlineComments("Economy.OnlyXZ", List.of(Translation.Config_Comment_OnlyXZ.trans()));
_file.set("Economy.Refund", limits.get("default").getRefundRatio());
_file.set("Economy.Refund", groupLimits.get("default").getRefundRatio());
_file.setInlineComments("Economy.Refund", List.of(Translation.Config_Comment_Refund.trans()));
_file.set("FlyPermissionNodes", _fly_permission_nodes);
@ -250,12 +201,6 @@ public class ConfigManager {
return _db_type;
}
public void setDbType(String db_type) {
_db_type = db_type;
_file.set("Database.Type", db_type);
_plugin.saveConfig();
}
public String getDbHost() {
return _db_host;
}
@ -271,7 +216,6 @@ public class ConfigManager {
public void setDbUser(String db_user) {
_db_user = db_user;
_file.set("Database.User", db_user);
_plugin.saveConfig();
}
public String getDbUser() {
@ -284,7 +228,6 @@ public class ConfigManager {
public void setDbPass(String db_pass) {
_db_pass = db_pass;
_file.set("Database.Pass", db_pass);
_plugin.saveConfig();
}
public String getDbPass() {
@ -292,33 +235,15 @@ public class ConfigManager {
}
public Integer getLimitSizeX(Player player) {
return limits.get(getPlayerGroup(player)).getLimitSizeX();
}
public void setLimitSizeX(Integer max_x) {
limits.get("default").setLimitSizeX(max_x);
_file.set("Limit.SizeX", max_x);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getLimitSizeX(player.getWorld());
}
public Integer getLimitSizeY(Player player) {
return limits.get(getPlayerGroup(player)).getLimitSizeY();
}
public void setLimitSizeY(Integer max_y) {
limits.get("default").setLimitSizeY(max_y);
_file.set("Limit.SizeY", max_y);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getLimitSizeY(player.getWorld());
}
public Integer getLimitSizeZ(Player player) {
return limits.get(getPlayerGroup(player)).getLimitSizeZ();
}
public void setLimitSizeZ(Integer max_z) {
limits.get("default").setLimitSizeZ(max_z);
_file.set("Limit.SizeZ", max_z);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getLimitSizeZ(player.getWorld());
}
public Integer getAutoCreateRadius() {
@ -328,7 +253,6 @@ public class ConfigManager {
public void setAutoCreateRadius(Integer radius) {
_auto_create_radius = radius;
_file.set("AutoCreateRadius", radius);
_plugin.saveConfig();
}
public Boolean getBlueMap() {
@ -346,73 +270,36 @@ public class ConfigManager {
public void setAutoCleanAfterDays(Integer auto_clean_after_days) {
_auto_clean_after_days = auto_clean_after_days;
_file.set("AutoCleanAfterDays", auto_clean_after_days);
_plugin.saveConfig();
}
public Integer getLimitMinY(Player player) {
return limits.get(getPlayerGroup(player)).getLimitMinY();
}
public void setLimitMinY(Integer limit_bottom) {
limits.get("default").setLimitMinY(limit_bottom);
_file.set("Limit.MinY", limit_bottom);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getLimitMinY(player.getWorld());
}
public Integer getLimitMaxY(Player player) {
return limits.get(getPlayerGroup(player)).getLimitMaxY();
}
public void setLimitMaxY(Integer limit_top) {
limits.get("default").setLimitMaxY(limit_top);
_file.set("Limit.MaxY", limit_top);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getLimitMaxY(player.getWorld());
}
public Integer getLimitAmount(Player player) {
return limits.get(getPlayerGroup(player)).getLimitAmount();
}
public void setLimitAmount(Integer limit_amount) {
limits.get("default").setLimitAmount(limit_amount);
_file.set("Limit.Amount", limit_amount);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getLimitAmount(player.getWorld());
}
public Integer getLimitDepth(Player player) {
return limits.get(getPlayerGroup(player)).getLimitDepth();
}
public void setLimitDepth(Integer limit_depth) {
limits.get("default").setLimitDepth(limit_depth);
_file.set("Limit.Depth", limit_depth);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getLimitDepth(player.getWorld());
}
public Boolean getLimitVert(Player player) {
return limits.get(getPlayerGroup(player)).getLimitVert();
}
public void setLimitVert(Boolean limit_vert) {
limits.get("default").setLimitVert(limit_vert);
_file.set("Limit.Vert", limit_vert);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getLimitVert(player.getWorld());
}
public List<String> getWorldBlackList(Player player) {
return limits.get(getPlayerGroup(player)).getWorldBlackList();
return groupLimits.get(getPlayerGroup(player)).getWorldBlackList();
}
public Boolean getLimitOpBypass() {
return _limit_op_bypass;
}
public void setLimitOpBypass(Boolean limit_op_bypass) {
_limit_op_bypass = limit_op_bypass;
_file.set("Limit.OpByPass", limit_op_bypass);
_plugin.saveConfig();
}
public Boolean getCheckUpdate() {
return _check_update;
}
@ -421,12 +308,6 @@ public class ConfigManager {
return _tp_enable;
}
public void setTpEnable(Boolean tp_enable) {
_tp_enable = tp_enable;
_file.set("Teleport.Enable", tp_enable);
_plugin.saveConfig();
}
public Integer getTpDelay() {
return _tp_delay;
}
@ -434,7 +315,6 @@ public class ConfigManager {
public void setTpDelay(Integer tp_delay) {
_tp_delay = tp_delay;
_file.set("Teleport.Delay", tp_delay);
_plugin.saveConfig();
}
public Integer getTpCoolDown() {
@ -444,7 +324,6 @@ public class ConfigManager {
public void setTpCoolDown(Integer tp_cool_down) {
_tp_cool_down = tp_cool_down;
_file.set("Teleport.CoolDown", tp_cool_down);
_plugin.saveConfig();
}
public Material getTool() {
@ -454,79 +333,36 @@ public class ConfigManager {
public void setTool(String tool) {
_tool = tool;
_file.set("Tool", tool);
_plugin.saveConfig();
}
public Boolean getEconomyEnable() {
return _economy_enable;
}
public void setEconomyEnable(Boolean economy_enable) {
_economy_enable = economy_enable;
_file.set("Economy.Enable", economy_enable);
_plugin.saveConfig();
}
public Float getEconomyPrice(Player player) {
return limits.get(getPlayerGroup(player)).getPrice().floatValue();
}
public void setEconomyPrice(Float economy_price) {
limits.get("default").setPrice((double) economy_price);
_file.set("Economy.Price", economy_price);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getPrice().floatValue();
}
public Boolean getEconomyOnlyXZ(Player player) {
return limits.get(getPlayerGroup(player)).getPriceOnlyXZ();
}
public void setEconomyOnlyXZ(Boolean economy_only_xz) {
limits.get("default").setPriceOnlyXZ(economy_only_xz);
_file.set("Economy.OnlyXZ", economy_only_xz);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getPriceOnlyXZ();
}
public Float getEconomyRefund(Player player) {
return limits.get(getPlayerGroup(player)).getRefundRatio().floatValue();
}
public void setEconomyRefund(Float economy_refund) {
limits.get("default").setRefundRatio((double) economy_refund);
_file.set("Economy.Refund", economy_refund);
_plugin.saveConfig();
return groupLimits.get(getPlayerGroup(player)).getRefundRatio().floatValue();
}
public List<String> getFlyPermissionNodes() {
return _fly_permission_nodes;
}
public void setFlyPermissionNodes(List<String> fly_permission_nodes) {
_fly_permission_nodes = fly_permission_nodes;
_file.set("FlyPermissionNodes", fly_permission_nodes);
_plugin.saveConfig();
}
public Boolean getResidenceMigration() {
return _residence_migration;
}
public void setResidenceMigration(Boolean residence_migration) {
_residence_migration = residence_migration;
_file.set("ResidenceMigration", residence_migration);
_plugin.saveConfig();
}
public Integer getSpawnProtection() {
return _spawn_protection;
}
public void setSpawnProtection(Integer spawn_protection) {
_spawn_protection = spawn_protection;
_file.set("Limit.SpawnProtection", spawn_protection);
_plugin.saveConfig();
}
public Boolean getGroupTitleEnable() {
return _group_title_enable;
}
@ -534,38 +370,45 @@ public class ConfigManager {
public void setGroupTitleEnable(Boolean group_title_enable) {
_group_title_enable = group_title_enable;
_file.set("GroupTitle.Enable", group_title_enable);
_plugin.saveConfig();
}
public String getGroupTitlePrefix() {
return _group_title_prefix;
}
public void setGroupTitlePrefix(String group_title_prefix) {
_group_title_prefix = group_title_prefix;
_file.set("GroupTitle.Prefix", group_title_prefix);
_plugin.saveConfig();
}
public String getGroupTitleSuffix() {
return _group_title_suffix;
}
public void setGroupTitleSuffix(String group_title_suffix) {
_group_title_suffix = group_title_suffix;
_file.set("GroupTitle.Suffix", group_title_suffix);
_plugin.saveConfig();
}
public String getLanguage() {
return _language;
}
public void setLanguage(String language) {
_language = language;
_file.set("Language", language);
_plugin.saveConfig();
Translation.instance.loadLocale(language);
public void checkRules() {
if (Material.getMaterial(_tool) == null) {
XLogger.err(Translation.Config_Check_ToolNameError);
setTool("ARROW");
}
if (getAutoCreateRadius() == 0) {
XLogger.err(Translation.Config_Check_AutoCreateRadiusError);
setAutoCreateRadius(10);
}
if (getAutoCleanAfterDays() == 0) {
XLogger.err(Translation.Config_Check_AutoCleanAfterDaysError);
setAutoCleanAfterDays(180);
}
if (getTpDelay() < 0) {
XLogger.err(Translation.Config_Check_TpDelayError);
setTpDelay(0);
}
if (getTpCoolDown() < 0) {
XLogger.err(Translation.Config_Check_TpCoolDownError);
setTpCoolDown(0);
}
for (GroupLimit limit : groupLimits.values()) {
limit.checkRules();
}
}
private final Dominion _plugin;
@ -607,13 +450,13 @@ public class ConfigManager {
private String _group_title_prefix;
private String _group_title_suffix;
private final Map<String, GroupLimit> limits = new HashMap<>();
private final Map<String, GroupLimit> groupLimits = new HashMap<>();
private String getPlayerGroup(@Nullable Player player) {
if (player == null) {
return "default";
}
for (String group : limits.keySet()) {
for (String group : groupLimits.keySet()) {
if (group.equals("default")) {
continue;
}

View File

@ -1,26 +1,21 @@
package cn.lunadeer.dominion.managers;
import cn.lunadeer.minecraftpluginutils.XLogger;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class GroupLimit {
private final YamlConfiguration config;
private YamlConfiguration config;
private final File file_path;
private Integer min_y;
private Integer max_y;
private Integer size_x;
private Integer size_y;
private Integer size_z;
private Integer amount;
private Integer depth;
private Boolean vert;
private List<String> world_black_list;
private final Map<String, WorldSetting> world_limits = new HashMap<>();
private Double price;
private Boolean only_xz;
private Double refund;
@ -28,93 +23,96 @@ public class GroupLimit {
public GroupLimit() {
this.file_path = null;
this.config = new YamlConfiguration();
WorldSetting defaultSetting = new WorldSetting("config.yml");
world_limits.put("default", defaultSetting);
}
public GroupLimit(File filePath) {
private GroupLimit(File filePath) {
this.file_path = filePath;
config = YamlConfiguration.loadConfiguration(this.file_path);
setLimitMinY(config.getInt("MinY", -64));
setLimitMaxY(config.getInt("MaxY", 320));
if (getLimitMinY() >= getLimitMaxY()) {
XLogger.err(Translation.Config_Check_GroupMinYError, this.file_path.getName());
setLimitMinY(-64);
setLimitMaxY(320);
WorldSetting defaultSetting = new WorldSetting(filePath.getName());
defaultSetting.min_y = config.getInt("MinY", -64);
defaultSetting.max_y = config.getInt("MaxY", 320);
defaultSetting.size_x = config.getInt("SizeX", 128);
defaultSetting.size_y = config.getInt("SizeY", 64);
defaultSetting.size_z = config.getInt("SizeZ", 128);
defaultSetting.amount = config.getInt("Amount", 10);
defaultSetting.depth = config.getInt("Depth", 3);
defaultSetting.vert = config.getBoolean("Vert", false);
world_limits.put("default", defaultSetting);
ConfigurationSection worldSettings = config.getConfigurationSection("WorldSettings");
if (worldSettings != null) {
addWorldLimits(WorldSetting.load(filePath.getName() + ":WorldSettings", worldSettings));
}
setLimitSizeX(config.getInt("SizeX", 128));
if (getLimitSizeX() <= 4 && getLimitSizeX() != -1) {
XLogger.err(Translation.Config_Check_GroupSizeXError, this.file_path.getName());
setLimitSizeX(128);
price = config.getDouble("Price", 10.0);
only_xz = config.getBoolean("OnlyXZ", false);
refund = config.getDouble("Refund", 0.85);
checkRules();
saveAll();
}
public Integer getLimitMinY(@Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
return world_limits.get("default").min_y;
} else {
return world_limits.get(world.getName()).min_y;
}
setLimitSizeY(config.getInt("SizeY", 64));
if (getLimitSizeY() <= 4 && getLimitSizeY() != -1) {
XLogger.err(Translation.Config_Check_GroupSizeYError, this.file_path.getName());
setLimitSizeY(64);
}
public Integer getLimitMaxY(@Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
return world_limits.get("default").max_y;
} else {
return world_limits.get(world.getName()).max_y;
}
setLimitSizeZ(config.getInt("SizeZ", 128));
if (getLimitSizeZ() <= 4 && getLimitSizeZ() != -1) {
XLogger.err(Translation.Config_Check_GroupSizeZError, this.file_path.getName());
setLimitSizeZ(128);
}
public Integer getLimitSizeX(@Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
return world_limits.get("default").size_x;
} else {
return world_limits.get(world.getName()).size_x;
}
setLimitAmount(config.getInt("Amount", 10));
if (getLimitAmount() <= 0 && getLimitAmount() != -1) {
XLogger.err(Translation.Config_Check_GroupAmountError, this.file_path.getName());
setLimitAmount(10);
}
public Integer getLimitSizeY(@Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
return world_limits.get("default").size_y;
} else {
return world_limits.get(world.getName()).size_y;
}
setLimitDepth(config.getInt("Depth", 3));
if (getLimitDepth() <= 0 && getLimitDepth() != -1) {
XLogger.err(Translation.Config_Check_GroupDepthError, this.file_path.getName());
setLimitDepth(3);
}
public Integer getLimitSizeZ(@Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
return world_limits.get("default").size_z;
} else {
return world_limits.get(world.getName()).size_z;
}
setLimitVert(config.getBoolean("Vert", false));
setWorldBlackList(config.getStringList("WorldBlackList"));
setPrice(config.getDouble("Price", 10.0));
if (getPrice() < 0.0) {
XLogger.err(Translation.Config_Check_GroupPriceError, this.file_path.getName());
setPrice(10.0);
}
public Integer getLimitAmount(@Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
return world_limits.get("default").amount;
} else {
return world_limits.get(world.getName()).amount;
}
setPriceOnlyXZ(config.getBoolean("OnlyXZ", false));
setRefundRatio(config.getDouble("Refund", 0.85));
if (getRefundRatio() < 0.0 || getRefundRatio() > 1.0) {
XLogger.err(Translation.Config_Check_GroupRefundError, this.file_path.getName());
setRefundRatio(0.85);
}
public Integer getLimitDepth(@Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
return world_limits.get("default").depth;
} else {
return world_limits.get(world.getName()).depth;
}
save(); // 保存一次确保文件中的数据是合法的
}
public Integer getLimitMinY() {
return min_y;
}
public Integer getLimitMaxY() {
return max_y;
}
public Integer getLimitSizeX() {
return size_x;
}
public Integer getLimitSizeY() {
return size_y;
}
public Integer getLimitSizeZ() {
return size_z;
}
public Integer getLimitAmount() {
return amount;
}
public Integer getLimitDepth() {
return depth;
}
public Boolean getLimitVert() {
return vert;
}
public List<String> getWorldBlackList() {
return world_black_list;
public Boolean getLimitVert(@Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
return world_limits.get("default").vert;
} else {
return world_limits.get(world.getName()).vert;
}
}
public Double getPrice() {
@ -130,90 +128,86 @@ public class GroupLimit {
}
public void setLimitMinY(Integer min_y) {
this.min_y = min_y;
this.config.set("MinY", min_y);
this.save();
public void setLimitMinY(Integer min_y, @Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
world_limits.get("default").min_y = min_y;
} else {
world_limits.get(world.getName()).min_y = min_y;
}
}
public void setLimitMaxY(Integer max_y) {
this.max_y = max_y;
this.config.set("MaxY", max_y);
this.save();
public void setLimitMaxY(Integer max_y, @Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
world_limits.get("default").max_y = max_y;
} else {
world_limits.get(world.getName()).max_y = max_y;
}
}
public void setLimitSizeX(Integer size_x) {
this.size_x = size_x;
this.config.set("SizeX", size_x);
this.save();
public void setLimitSizeX(Integer size_x, @Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
world_limits.get("default").size_x = size_x;
} else {
world_limits.get(world.getName()).size_x = size_x;
}
}
public void setLimitSizeY(Integer size_y) {
this.size_y = size_y;
this.config.set("SizeY", size_y);
this.save();
public void setLimitSizeY(Integer size_y, @Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
world_limits.get("default").size_y = size_y;
} else {
world_limits.get(world.getName()).size_y = size_y;
}
}
public void setLimitSizeZ(Integer size_z) {
this.size_z = size_z;
this.config.set("SizeZ", size_z);
this.save();
public void setLimitSizeZ(Integer size_z, @Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
world_limits.get("default").size_z = size_z;
} else {
world_limits.get(world.getName()).size_z = size_z;
}
}
public void setLimitAmount(Integer amount) {
this.amount = amount;
this.config.set("Amount", amount);
this.save();
public void setLimitAmount(Integer amount, @Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
world_limits.get("default").amount = amount;
} else {
world_limits.get(world.getName()).amount = amount;
}
}
public void setLimitDepth(Integer depth) {
this.depth = depth;
this.config.set("Depth", depth);
this.save();
public void setLimitDepth(Integer depth, @Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
world_limits.get("default").depth = depth;
} else {
world_limits.get(world.getName()).depth = depth;
}
}
public void setLimitVert(Boolean vert) {
this.vert = vert;
this.config.set("Vert", vert);
this.save();
}
public void setWorldBlackList(List<String> world_black_list) {
this.world_black_list = world_black_list;
this.config.set("WorldBlackList", world_black_list);
this.save();
public void setLimitVert(Boolean vert, @Nullable World world) {
if (world == null || !world_limits.containsKey(world.getName())) {
world_limits.get("default").vert = vert;
} else {
world_limits.get(world.getName()).vert = vert;
}
}
public void setPrice(Double price) {
this.price = price;
this.config.set("Price", price);
this.save();
}
public void setPriceOnlyXZ(Boolean only_xz) {
this.only_xz = only_xz;
this.config.set("OnlyXZ", only_xz);
this.save();
}
public void setRefundRatio(Double refund) {
this.refund = refund;
this.config.set("Refund", refund);
this.save();
}
private void save() {
if (file_path == null) {
return;
}
try {
config.save(file_path);
} catch (Exception e) {
XLogger.err("Failed to save group limit file: " + file_path.getName());
}
public void addWorldLimits(Map<String, WorldSetting> limits) {
world_limits.putAll(limits);
}
public static Map<String, GroupLimit> loadGroups(JavaPlugin plugin) {
Map<String, GroupLimit> groups = new HashMap<>();
File root = plugin.getDataFolder();
@ -238,4 +232,88 @@ public class GroupLimit {
XLogger.info(Translation.Messages_LoadedGroupAmount, groups.size());
return groups;
}
private void saveAll() {
this.file_path.delete();
this.config = new YamlConfiguration();
this.config.set("MinY", world_limits.get("default").min_y);
this.config.setComments("MinY", Arrays.asList(
Translation.Config_Comment_GroupLine1.trans(),
Translation.Config_Comment_GroupLine2.trans(),
Translation.Config_Comment_GroupLine3.trans(),
Translation.Config_Comment_GroupLine4.trans(),
Translation.Config_Comment_GroupLine5.trans(),
Translation.Config_Comment_GroupLine6.trans(),
Translation.Config_Comment_GroupLine7.trans(),
String.format(Translation.Config_Comment_GroupLine8DocumentAddress.trans(), ConfigManager.instance.getLanguage())
));
this.config.setInlineComments("MinY", List.of(Translation.Config_Comment_MinY.trans()));
this.config.set("MaxY", world_limits.get("default").max_y);
this.config.setInlineComments("MaxY", List.of(Translation.Config_Comment_MaxY.trans()));
this.config.set("SizeX", world_limits.get("default").size_x);
this.config.setInlineComments("SizeX", List.of(Translation.Config_Comment_SizeX.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
this.config.set("SizeY", world_limits.get("default").size_y);
this.config.setInlineComments("SizeY", List.of(Translation.Config_Comment_SizeY.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
this.config.set("SizeZ", world_limits.get("default").size_z);
this.config.setInlineComments("SizeZ", List.of(Translation.Config_Comment_SizeZ.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
this.config.set("Amount", world_limits.get("default").amount);
this.config.setInlineComments("Amount", List.of(Translation.Config_Comment_Amount.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
this.config.set("Depth", world_limits.get("default").depth);
this.config.setInlineComments("Depth", List.of(Translation.Config_Comment_Depth.trans() + Translation.Config_Comment_ZeroDisabled.trans() + Translation.Config_Comment_NegativeOneUnlimited.trans()));
this.config.set("Vert", world_limits.get("default").vert);
this.config.setInlineComments("Vert", List.of(Translation.Config_Comment_Vert.trans()));
this.config.set("Price", price);
this.config.setInlineComments("Price", List.of(Translation.Config_Comment_Price.trans()));
this.config.set("OnlyXZ", only_xz);
this.config.setInlineComments("OnlyXZ", List.of(Translation.Config_Comment_OnlyXZ.trans()));
this.config.set("Refund", refund);
this.config.setInlineComments("Refund", List.of(Translation.Config_Comment_Refund.trans()));
this.config.set("WorldSettings", getWorldSettings());
this.config.setInlineComments("WorldSettings", List.of(Translation.Config_Comment_WorldSettings.trans()));
try {
this.config.save(this.file_path);
} catch (Exception e) {
XLogger.err("Failed to save group limit file: " + this.file_path.getName());
}
}
public YamlConfiguration getWorldSettings() {
YamlConfiguration section = new YamlConfiguration();
if (world_limits.size() <= 1) {
return WorldSetting.getDefaultList();
}
for (Map.Entry<String, WorldSetting> entry : world_limits.entrySet()) {
if (entry.getKey().equals("default")) {
continue;
}
section.set(entry.getKey(), entry.getValue().getYaml());
}
return section;
}
public void checkRules() {
if (getPrice() < 0.0) {
XLogger.err(Translation.Config_Check_GroupPriceError, this.file_path.getName());
setPrice(10.0);
}
if (getRefundRatio() < 0.0 || getRefundRatio() > 1.0) {
XLogger.err(Translation.Config_Check_GroupRefundError, this.file_path.getName());
setRefundRatio(0.85);
}
for (WorldSetting w : world_limits.values()) {
w.checkRules();
}
}
public List<String> getWorldBlackList() {
List<String> list = new ArrayList<>();
for (Map.Entry<String, WorldSetting> entry : world_limits.entrySet()) {
if (!entry.getValue().allow) {
list.add(entry.getKey());
}
}
return list;
}
}

View File

@ -504,6 +504,8 @@ public class Translation extends Localization {
public static i18n Messages_PlaceholderAPIRegisterSuccess;
@i18nField(defaultValue = "共加载了 %d 个领地组")
public static i18n Messages_LoadedGroupAmount;
@i18nField(defaultValue = "<div>%s</div><div>所有人:%s</div>")
public static i18n Messages_MapInfoDetail;
@i18nField(defaultValue = "开始自动清理长时间未登录玩家领地数据")
public static i18n Messages_AutoCleanStart;
@ -808,9 +810,6 @@ public class Translation extends Localization {
@i18nField(defaultValue = "来自领地:")
public static i18n TUI_TitleList_FromDominion;
@i18nField(defaultValue = "Dominion 系统配置")
public static i18n TUI_Config_Title;
@i18nField(defaultValue = "输入要创建的领地名称")
public static i18n CUI_Input_CreateDominion;
@i18nField(defaultValue = "输入要创建的权限组名称")
@ -836,39 +835,21 @@ public class Translation extends Localization {
public static i18n Config_Check_AutoCleanAfterDaysError;
@i18nField(defaultValue = "工具名称设置错误,已重置为 ARROW")
public static i18n Config_Check_ToolNameError;
@i18nField(defaultValue = "Limit.SizeX 尺寸不能小于 4已重置为 128")
public static i18n Config_Check_LimitSizeXError;
@i18nField(defaultValue = "Limit.SizeY 尺寸不能小于 4已重置为 64")
public static i18n Config_Check_LimitSizeYError;
@i18nField(defaultValue = "Limit.SizeZ 尺寸不能小于 4已重置为 128")
public static i18n Config_Check_LimitSizeZError;
@i18nField(defaultValue = "Limit.MinY 不能大于或等于 Limit.MaxY已重置为 -64 320")
public static i18n Config_Check_LimitMinYError;
@i18nField(defaultValue = "Economy.Refund 设置不合法,已重置为 0.85")
public static i18n Config_Check_RefundError;
@i18nField(defaultValue = "Economy.Price 设置不合法,已重置为 10.0")
public static i18n Config_Check_PriceError;
@i18nField(defaultValue = "启用 Limit.Vert 时 Limit.SizeY 不能小于 Limit.MaxY - Limit.MinY已自动调整为 %d")
public static i18n Config_Check_LimitSizeYAutoAdjust;
@i18nField(defaultValue = "Limit.Amount 设置不合法,已重置为 10")
public static i18n Config_Check_AmountError;
@i18nField(defaultValue = "Limit.Depth 设置不合法,已重置为 3")
public static i18n Config_Check_DepthError;
@i18nField(defaultValue = "权限组 %s 的 MinY 不能大于等于 MaxY已重置为 -64 和 320")
@i18nField(defaultValue = "%s 的 MinY 不能大于等于 MaxY已重置为 -64 和 320")
public static i18n Config_Check_GroupMinYError;
@i18nField(defaultValue = "权限组 %s 的 SizeX 设置过小,已重置为 128")
@i18nField(defaultValue = "%s 的 SizeX 设置过小,已重置为 128")
public static i18n Config_Check_GroupSizeXError;
@i18nField(defaultValue = "权限组 %s 的 SizeY 设置过小,已重置为 64")
@i18nField(defaultValue = "%s 的 SizeY 设置过小,已重置为 64")
public static i18n Config_Check_GroupSizeYError;
@i18nField(defaultValue = "权限组 %s 的 SizeZ 设置过小,已重置为 128")
@i18nField(defaultValue = "%s 的 SizeZ 设置过小,已重置为 128")
public static i18n Config_Check_GroupSizeZError;
@i18nField(defaultValue = "权限组 %s 的 Amount 设置不合法,已重置为 10")
@i18nField(defaultValue = "%s 的 Amount 设置不合法,已重置为 10")
public static i18n Config_Check_GroupAmountError;
@i18nField(defaultValue = "权限组 %s 的 Depth 设置不合法,已重置为 3")
@i18nField(defaultValue = "%s 的 Depth 设置不合法,已重置为 3")
public static i18n Config_Check_GroupDepthError;
@i18nField(defaultValue = "权限组 %s 的 Price 设置不合法,已重置为 10.0")
@i18nField(defaultValue = "%s 的 Price 设置不合法,已重置为 10.0")
public static i18n Config_Check_GroupPriceError;
@i18nField(defaultValue = "权限组 %s 的 Refund 设置不合法,已重置为 0.85")
@i18nField(defaultValue = "%s 的 Refund 设置不合法,已重置为 0.85")
public static i18n Config_Check_GroupRefundError;
@i18nField(defaultValue = "读取权限配置失败:%s")
public static i18n Config_Check_LoadFlagError;
@ -907,10 +888,10 @@ public class Translation extends Localization {
public static i18n Config_Comment_ZeroDisabled;
@i18nField(defaultValue = "是否自动延伸到 MaxY 和 MinY")
public static i18n Config_Comment_Vert;
@i18nField(defaultValue = "不允许圈地的世界列表")
public static i18n Config_Comment_DisabledWorlds;
@i18nField(defaultValue = "是否允许OP无视领地限制")
public static i18n Config_Comment_OpBypass;
@i18nField(defaultValue = "单独设置某个世界的圈地规则(如不设置则使用以上规则)")
public static i18n Config_Comment_WorldSettings;
@i18nField(defaultValue = "传送延迟 秒")
public static i18n Config_Comment_TpDelay;
@i18nField(defaultValue = "传送冷却 秒")
@ -941,6 +922,22 @@ public class Translation extends Localization {
public static i18n Config_Comment_GroupTitleColor;
@i18nField(defaultValue = "性能测试计时器")
public static i18n Config_Comment_PerformanceTimer;
@i18nField(defaultValue = ">---------------------------------<")
public static i18n Config_Comment_GroupLine1;
@i18nField(defaultValue = "| 圈地限制特殊权限组配置 |")
public static i18n Config_Comment_GroupLine2;
@i18nField(defaultValue = ">---------------------------------<")
public static i18n Config_Comment_GroupLine3;
@i18nField(defaultValue = "此文件可以作为模板,你可以将此文件复制后重命名为你想要的")
public static i18n Config_Comment_GroupLine4;
@i18nField(defaultValue = "权限组名然后修改里面的配置如果你想给赞助玩家或者VIP")
public static i18n Config_Comment_GroupLine5;
@i18nField(defaultValue = "一些特殊优惠,例如更少的圈地价格、更大的领地等,你可以在")
public static i18n Config_Comment_GroupLine6;
@i18nField(defaultValue = "这里配置。详细说明参阅以下链接:")
public static i18n Config_Comment_GroupLine7;
@i18nField(defaultValue = "> https://dominion.lunadeer.cn/%s/operator/privilege.html")
public static i18n Config_Comment_GroupLine8DocumentAddress;
@i18nField(defaultValue = "管理员")
public static i18n Flags_admin_DisplayName;

View File

@ -0,0 +1,103 @@
package cn.lunadeer.dominion.managers;
import cn.lunadeer.minecraftpluginutils.XLogger;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import java.util.Map;
public class WorldSetting {
public Integer min_y;
public Integer max_y;
public Integer size_x;
public Integer size_y;
public Integer size_z;
public Integer amount;
public Integer depth;
public Boolean vert;
public Boolean allow = true;
private final String sourceName;
/**
* 生成默认设置
*
* @return 设置内容
*/
public static YamlConfiguration getDefaultList() {
YamlConfiguration section = new YamlConfiguration();
section.set("some_world_name.MinY", -64);
section.set("some_world_name.MaxY", 320);
section.set("some_world_name.SizeX", 128);
section.set("some_world_name.SizeY", 64);
section.set("some_world_name.SizeZ", 128);
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;
}
public WorldSetting(String sourceName) {
this.sourceName = sourceName;
}
public static Map<String, WorldSetting> load(String sourceName, ConfigurationSection worldSettings) {
Map<String, WorldSetting> world_limits = new java.util.HashMap<>();
for (String worldName : worldSettings.getKeys(false)) {
WorldSetting setting = new WorldSetting(sourceName);
setting.min_y = worldSettings.getInt(worldName + ".MinY", -64);
setting.max_y = worldSettings.getInt(worldName + ".MaxY", 320);
setting.size_x = worldSettings.getInt(worldName + ".SizeX", 128);
setting.size_y = worldSettings.getInt(worldName + ".SizeY", 64);
setting.size_z = worldSettings.getInt(worldName + ".SizeZ", 128);
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);
world_limits.put(worldName, setting);
}
return world_limits;
}
public YamlConfiguration getYaml() {
YamlConfiguration section = new YamlConfiguration();
section.set("MinY", min_y);
section.set("MaxY", max_y);
section.set("SizeX", size_x);
section.set("SizeY", size_y);
section.set("SizeZ", size_z);
section.set("Amount", amount);
section.set("Depth", depth);
section.set("Vert", vert);
section.set("Allow", allow);
return section;
}
public void checkRules() {
if (min_y > max_y) {
XLogger.err(Translation.Config_Check_GroupMinYError, sourceName);
min_y = -64;
max_y = 320;
}
if (size_x <= 4 && size_x != -1) {
XLogger.err(Translation.Config_Check_GroupSizeXError, sourceName);
size_x = 128;
}
if (size_y <= 4 && size_y != -1) {
XLogger.err(Translation.Config_Check_GroupSizeYError, sourceName);
size_y = 64;
}
if (size_z <= 4 && size_z != -1) {
XLogger.err(Translation.Config_Check_GroupSizeZError, sourceName);
size_z = 128;
}
if (amount <= 0 && amount != -1) {
XLogger.err(Translation.Config_Check_GroupAmountError, sourceName);
amount = 10;
}
if (depth < 0 && depth != -1) {
XLogger.err(Translation.Config_Check_GroupDepthError, sourceName);
depth = 3;
}
}
}

View File

@ -2,6 +2,7 @@ package cn.lunadeer.dominion.utils.map;
import cn.lunadeer.dominion.Cache;
import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.dtos.PlayerDTO;
import cn.lunadeer.dominion.managers.Translation;
import cn.lunadeer.minecraftpluginutils.Scheduler;
import cn.lunadeer.minecraftpluginutils.XLogger;
@ -37,6 +38,11 @@ public class BlueMapConnect {
.build();
for (DominionDTO dominion : d.getValue()) {
PlayerDTO p = PlayerDTO.select(dominion.getOwner());
if (p == null) {
continue;
}
Collection<Vector2d> vectors = new ArrayList<>();
vectors.add(new Vector2d(dominion.getX1() + 0.001, dominion.getZ1() + 0.001));
vectors.add(new Vector2d(dominion.getX2() - 0.001, dominion.getZ1() + 0.001));
@ -55,6 +61,7 @@ public class BlueMapConnect {
Color fill = new Color(r, g, b, 0.2F);
ExtrudeMarker marker = ExtrudeMarker.builder()
.label(dominion.getName())
.detail(String.format(Translation.Messages_MapInfoDetail.trans(), dominion.getName(), p.getLastKnownName()))
.position(x, y, z)
.shape(shape, dominion.getY1() + 0.001f, dominion.getY2() - 0.001f)
.lineColor(line)

View File

@ -1,6 +1,7 @@
package cn.lunadeer.dominion.utils.map;
import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.dtos.PlayerDTO;
import cn.lunadeer.dominion.managers.Translation;
import cn.lunadeer.minecraftpluginutils.Scheduler;
import cn.lunadeer.minecraftpluginutils.XLogger;
@ -40,7 +41,11 @@ public class DynmapConnect extends DynmapCommonAPIListener {
}
private void setDominionMarker(DominionDTO dominion) {
String nameLabel = "<div>" + dominion.getName() + "</div>";
PlayerDTO p = PlayerDTO.select(dominion.getOwner());
if (p == null) {
return;
}
String nameLabel = String.format(Translation.Messages_MapInfoDetail.trans(), dominion.getName(), p.getLastKnownName());
double[] xx = {dominion.getX1(), dominion.getX2()};
double[] zz = {dominion.getZ1(), dominion.getZ2()};
if (dominion.getWorld() == null) {

View File

@ -20,8 +20,18 @@ Limit:
Amount: 10
Depth: 3
Vert: false
WorldBlackList: ['some_world']
OpByPass: true
WorldSettings:
some_world_name:
MinY: -64
MaxY: 320
SizeX: 128
SizeY: 64
SizeZ: 128
Amount: 10
Depth: 3
Vert: false
Allow: false
Teleport:
Enable: true

View File

@ -1,20 +1,22 @@
# >---------------------------------<
# | 圈地限制特殊权限组配置 |
# >---------------------------------<
# 此文件可以作为模板,你可以将此文件复制后重命名为你想要的权限组名,然后修改里面的配置
# 如果你想给赞助玩家或者VIP一些特殊优惠例如更少的圈地价格、更大的领地等你可以在这里配置
# 详细说明参阅 > https://ssl.lunadeer.cn:14448/doc/82/
MinY: -64 # 最小Y坐标
MaxY: 320 # 最大Y坐标
SizeX: 128 # X方向最大长度 -1表示不限制
SizeY: 64 # Y方向最大长度 -1表示不限制
SizeZ: 128 # Z方向最大长度 -1表示不限制
Amount: 10 # 最大领地数量 -1表示不限制
Depth: 3 # 子领地深度 0不允许子领地 -1不限制
Vert: false # 是否自动延伸到 MaxY 和 MinY
WorldBlackList: [ ] # 不允许领地的世界
Price: 10.0 # 方块单价
OnlyXZ: false # 是否只计算xz平面积
Refund: 0.85 # 删除领地退还比例
MinY: -64
MaxY: 320
SizeX: 128
SizeY: 64
SizeZ: 128
Amount: 10
Depth: 3
Vert: false
Price: 10.0
OnlyXZ: false
Refund: 0.85
WorldSettings:
some_world_name:
MinY: -64
MaxY: 320
SizeX: 128
SizeY: 64
SizeZ: 128
Amount: 10
Depth: 3
Vert: false
Allow: false

View File

@ -0,0 +1,20 @@
# 将领地从 Residence 迁移到 Dominion
## 注意事项
1. 迁移采取的“玩家自助”方案,即由玩家自行决定要迁移自己的哪些领地;
2. 目前支持迁移领地、tp点、欢迎/离开提示消息、子领地;
3. 由于对权限的存储、索引方式不同,目前**不支持**对权限进行迁移;
4. 迁移领地**不会产生二次消费**
## 服主要做的事
1. 删除 Residence 插件,保留其数据文件 `plugins/Residence`;
2. 在 Dominion 配置中将 `ResidenceMigration` 打开设置为true
## 玩家要做的事
1. 上线,打开 Dominion 菜单 `/dom`,点击`【迁移数据】`
2. 选择要迁移的 Residence 领地,点击前面的`【迁移】`
3. 完成后即可前往领地列表进一步配置领地的权限等信息:

View File

@ -27,9 +27,18 @@ Limit:
Amount: 10 # 最大领地数量-1表示不限制
Depth: 3 # 子领地深度0表示不开启-1表示不限制
Vert: false # 是否自动延伸到 MaxY 和 MinY
WorldBlackList: # 不允许圈地的世界列表
- some_world
OpByPass: true # 是否允许OP无视领地限制
WorldSettings:
some_world_name:
MinY: -64
MaxY: 320
SizeX: 128
SizeY: 64
SizeZ: 128
Amount: 10
Depth: 3
Vert: false
Allow: false
Teleport:
Enable: true
@ -102,13 +111,16 @@ Timer: false # 性能测试计时器
- SpawnProtection出生点半径保护此半径范围内普通玩家无法创建领地
- MinY领地的最小Y坐标
- MaxY领地的最大Y坐标
- SizeXX方向最大长度
- SizeYY方向最大长度
- SizeZZ方向最大长度
- Amount每个玩家拥有的最大领地数量
- SizeXX方向最大长度 1表示不限制
- SizeYY方向最大长度 1表示不限制
- SizeZZ方向最大长度 1表示不限制
- Amount每个玩家拥有的最大领地数量 1表示不限制
- Depth子领地深度、0表示不允许子领地、 -1表示不限制
- WorldBlackList不允许创建领地的世界
- Vert当设置为 `true`玩家选择区域创建或者自动创建领地会自动将Y向下向上延伸到MinY和MaxY。**同时也会根据 MinY 和 MaxY 的设置自动调整 SizeY 的配置保证数值逻辑一致。**
- WorldSettings单独设置某个世界的圈地规则如不设置则使用上述默认规则
- Allow是否允许在此世界圈地
> 您服务器世界的名称应该避免使用 `default` 这样的特殊单词,否则会导致不可预料的意外错误。
### Teleport

View File

@ -11,7 +11,8 @@
假设你现在想为赞助玩家提供优惠,打开 `plugins/Dominion/groups/sponsor.yml` 文件。修改里面的设置为你期望的数值,保存文件。
假如你想再为 VIP 玩家提供更丰厚的优惠,你可以复制一份 `sponsor.yml` 重命名为 `vip.yml` ,然后编辑里面的数值。(这个文件的名称你可以自定义,但是请不要使用中文、特殊字符、空格等)
假如你想再为 VIP 玩家提供更丰厚的优惠,你可以复制一份 `sponsor.yml` 重命名为 `vip.yml`
,然后编辑里面的数值。(这个文件的名称你可以自定义,但是请不要使用中文、特殊字符、空格等)
## 加载配置
@ -27,3 +28,9 @@
最后保存 LuckPerms 配置,即可生效。
## 注意事项
`groups` 中的 `WorldSettings``config.yml` 中的是独立的。
例如:你不希望任何玩家在下届顶层圈地(包括 `sponsor`),你已经在 `config.yml` 中设置了下届的 `MinY``MaxY`
如果你不在 `sponsor.yml` 中进行同样的设置的话,那么 `sponsor` 玩家就不会收到这个限制。

View File

@ -4,8 +4,7 @@ Commands:
CreateDominionUsage: '用法: /dominion create <领地名称>'
CreateSelectPointsFirst: 请先使用工具选择领地的对角线两点,或使用 /dominion auto_create <领地名称> 创建自动领地
CreateSubDominionUsage: '用法: /dominion create_sub <子领地名称> [父领地名称]'
CreateSubSelectPointsFirst: 请先使用工具选择子领地的对角线两点,或使用 /dominion auto_create_sub <子领地名称>
[父领地名称] 创建自动子领地
CreateSubSelectPointsFirst: 请先使用工具选择子领地的对角线两点,或使用 /dominion auto_create_sub <子领地名称> [父领地名称] 创建自动子领地
AutoCreateDominionUsage: '用法: /dominion auto_create <领地名称>'
AutoCreateSubDominionUsage: '用法: /dominion auto_create_sub <子领地名称> [父领地名称]'
AutoCreateDominionDisabled: 自动创建领地功能已关闭
@ -35,8 +34,7 @@ Commands:
DominionAddMemberUsage: '用法: /dominion member add <领地名称> <玩家名称>'
DominionSetFlagUsage: '用法: /dominion member set_flag <领地名称> <玩家名称> <权限名称> <true/false>'
DominionRemoveMemberUsage: '用法: /dominion member remove <领地名称> <玩家名称>'
DominionApplyTemplateUsage: '用法: /dominion member apply_template <领地名称> <玩家名称>
<模板名称>'
DominionApplyTemplateUsage: '用法: /dominion member apply_template <领地名称> <玩家名称> <模板名称>'
MemberUsage: '用法: /dominion member <add/set_flag/remove/apply_template/list/setting/select_player/select_template>'
PageOptional: 页码(可选)
ArgumentsNotEnough: 参数不足
@ -252,6 +250,7 @@ Messages:
AutoCleanStart: 开始自动清理长时间未登录玩家领地数据
AutoCleanPlayer: 已清理玩家 %s 的领地数据
AutoCleanEnd: 自动清理完成
MapInfoDetail: <div>%s</div><div>所有人:%s</div>
TUI:
NotDominionOwnerOrAdminForPage: 你不是领地 %s 的拥有者或管理员,无权访问此页面
CommandHelp:
@ -410,8 +409,6 @@ TUI:
RemoveButton: 卸下
ApplyButton: 使用
FromDominion: 来自领地:
Config:
Title: Dominion 系统配置
CUI:
Input:
CreateDominion: 输入要创建的领地名称
@ -434,8 +431,7 @@ Config:
LimitMinYError: Limit.MinY 不能大于或等于 Limit.MaxY已重置为 -64 320
RefundError: Economy.Refund 设置不合法,已重置为 0.85
PriceError: Economy.Price 设置不合法,已重置为 10.0
LimitSizeYAutoAdjust: 启用 Limit.Vert 时 Limit.SizeY 不能小于 Limit.MaxY - Limit.MinY已自动调整为
%d
LimitSizeYAutoAdjust: 启用 Limit.Vert 时 Limit.SizeY 不能小于 Limit.MaxY - Limit.MinY已自动调整为 %d
AmountError: Limit.Amount 设置不合法,已重置为 10
DepthError: Limit.Depth 设置不合法,已重置为 3
GroupMinYError: 权限组 %s 的 MinY 不能大于等于 MaxY已重置为 -64 和 320
@ -465,7 +461,6 @@ Config:
Depth: 子领地深度
ZeroDisabled: 0表示不开启
Vert: 是否自动延伸到 MaxY 和 MinY
DisabledWorlds: 不允许圈地的世界列表
OpBypass: 是否允许OP无视领地限制
TpDelay: 传送延迟 秒
TpCoolDown: 传送冷却 秒
@ -482,6 +477,15 @@ Config:
GroupTitleVariable: '变量: %dominion_group_title%'
GroupTitleColor: 前后缀如需要加颜色请使用这种格式 &#ffffff
PerformanceTimer: 性能测试计时器
GroupLine1: '>---------------------------------<'
GroupLine2: '| 圈地限制特殊权限组配置 |'
GroupLine3: '>---------------------------------<'
GroupLine4: 此文件可以作为模板,你可以将此文件复制后重命名为你想要的
GroupLine5: 权限组名然后修改里面的配置如果你想给赞助玩家或者VIP
GroupLine6: 一些特殊优惠,例如更少的圈地价格、更大的领地等,你可以在
GroupLine7: 这里配置。详细说明参阅以下链接:
GroupLine8DocumentAddress: '> https://dominion.lunadeer.cn/%s/operator/privilege.html'
WorldSettings: 单独设置某个世界的圈地规则(如不设置则使用以上规则)
Flags:
admin:
DisplayName: 管理员