diff --git a/build.gradle.kts b/build.gradle.kts index fb2a8d7d..8d1ce738 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "cn.lunadeer" -version = "2.9.1-beta" +version = "2.10.0-beta" java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) diff --git a/core/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java b/core/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java index 4a92e2d1..5c32c438 100644 --- a/core/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java +++ b/core/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java @@ -186,6 +186,8 @@ private DominionDTO(Integer id, UUID owner, String name, UUID world_uid, this.y2.value = y2; this.z2.value = z2; this.parentDomId.value = parentDomId; + this.joinMessage.value = Dominion.config.getDefaultJoinMessage(); + this.leaveMessage.value = Dominion.config.getDefaultLeaveMessage(); } public DominionDTO(UUID owner, String name, @NotNull World world, @@ -208,8 +210,8 @@ public static DominionDTO create(UUID owner, String name, @NotNull World world, private final Field y2 = new Field("y2", FieldType.INT); private final Field z2 = new Field("z2", FieldType.INT); private final Field parentDomId = new Field("parent_dom_id", -1); - private final Field joinMessage = new Field("join_message", "欢迎!"); - private final Field leaveMessage = new Field("leave_message", "欢迎下次光临~"); + private final Field joinMessage = new Field("join_message", ""); + private final Field leaveMessage = new Field("leave_message", ""); private final Map flags = new HashMap<>(); private final Field tp_location = new Field("tp_location", "default"); private final Field color = new Field("color", "#00BFFF"); diff --git a/core/src/main/java/cn/lunadeer/dominion/managers/ConfigManager.java b/core/src/main/java/cn/lunadeer/dominion/managers/ConfigManager.java index 485c0512..69451753 100644 --- a/core/src/main/java/cn/lunadeer/dominion/managers/ConfigManager.java +++ b/core/src/main/java/cn/lunadeer/dominion/managers/ConfigManager.java @@ -41,6 +41,8 @@ public void reload() { _db_pass = _file.getString("Database.Pass", "postgres"); _auto_create_radius = _file.getInt("AutoCreateRadius", 10); + _default_join_message = _file.getString("DefaultJoinMessage", "&3Welcome to %dominion_current_dominion%!"); + _default_leave_message = _file.getString("DefaultLeaveMessage", "&3Leaving %dominion_current_dominion%..."); _message_display_no_permission = _file.getString("MessageDisplay.NoPermission", "ACTION_BAR"); _message_display_join_leave = _file.getString("MessageDisplay.JoinLeave", "ACTION_BAR"); @@ -113,6 +115,10 @@ public void saveAll() { _file.set("AutoCreateRadius", _auto_create_radius); _file.setComments("AutoCreateRadius", Arrays.asList(Translation.Config_Comment_AutoCreateRadius.trans(), Translation.Config_Comment_NegativeOneDisabled.trans())); + _file.set("DefaultJoinMessage", _default_join_message); + _file.setComments("DefaultJoinMessage", Collections.singletonList(Translation.Config_Comment_DefaultJoinMessage.trans())); + _file.set("DefaultLeaveMessage", _default_leave_message); + _file.setComments("DefaultLeaveMessage", Collections.singletonList(Translation.Config_Comment_DefaultLeaveMessage.trans())); _file.setComments("MessageDisplay", Collections.singletonList(Translation.Config_Comment_MessageDisplay.trans())); _file.set("MessageDisplay.NoPermission", _message_display_no_permission); @@ -259,6 +265,14 @@ public Integer getAutoCreateRadius() { return _auto_create_radius; } + public String getDefaultJoinMessage() { + return _default_join_message; + } + + public String getDefaultLeaveMessage() { + return _default_leave_message; + } + public void setAutoCreateRadius(Integer radius) { _auto_create_radius = radius; _file.set("AutoCreateRadius", radius); @@ -451,6 +465,8 @@ public void checkRules() { private String _language; private Integer _auto_create_radius; + private String _default_join_message; + private String _default_leave_message; private Boolean _limit_op_bypass; diff --git a/core/src/main/java/cn/lunadeer/dominion/managers/DatabaseTables.java b/core/src/main/java/cn/lunadeer/dominion/managers/DatabaseTables.java index fceb427c..edca7cb8 100644 --- a/core/src/main/java/cn/lunadeer/dominion/managers/DatabaseTables.java +++ b/core/src/main/java/cn/lunadeer/dominion/managers/DatabaseTables.java @@ -114,8 +114,8 @@ public static void migrate() { Field server_dom_y2_field = new Field("y2", 2147483647); Field server_dom_z2_field = new Field("z2", 2147483647); Field server_dom_parent_dom_id_field = new Field("parent_dom_id", -1); - Field server_dom_join_message_field = new Field("join_message", "欢迎"); - Field server_dom_leave_message_field = new Field("leave_message", "再见"); + Field server_dom_join_message_field = new Field("join_message", ""); + Field server_dom_leave_message_field = new Field("leave_message", ""); InsertRow insert_server_dom = new InsertRow().table("dominion").onConflictDoNothing(server_dom_id_field) .field(server_dom_id_field) .field(server_dom_owner_field) diff --git a/core/src/main/java/cn/lunadeer/dominion/managers/Translation.java b/core/src/main/java/cn/lunadeer/dominion/managers/Translation.java index 352dfc94..8b5b85a2 100644 --- a/core/src/main/java/cn/lunadeer/dominion/managers/Translation.java +++ b/core/src/main/java/cn/lunadeer/dominion/managers/Translation.java @@ -864,6 +864,10 @@ public class Translation extends Localization { public static i18n Config_Comment_Language; @i18nField(defaultValue = "自动创建领地的半径,单位为方块") public static i18n Config_Comment_AutoCreateRadius; + @i18nField(defaultValue = "默认进入领地提示消息") + public static i18n Config_Comment_DefaultJoinMessage; + @i18nField(defaultValue = "默认离开领地提示消息") + public static i18n Config_Comment_DefaultLeaveMessage; @i18nField(defaultValue = "提示消息显示位置(BOSS_BAR, ACTION_BAR, TITLE, SUBTITLE, CHAT)") public static i18n Config_Comment_MessageDisplay; @i18nField(defaultValue = "玩家没有权限时的提示消息位置") diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index 55b8f251..cc3d05f2 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -9,6 +9,8 @@ Database: Language: zh-cn AutoCreateRadius: 10 +DefaultJoinMessage: '&3Welcome to %dominion_current_dominion%!' +DefaultLeaveMessage: '&3Leaving %dominion_current_dominion%...' MessageDisplay: NoPermission: ACTION_BAR