Skip to content

Commit

Permalink
新增允许配置领地默认提示消息 #26
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdeZhang committed Sep 24, 2024
1 parent ca2b42a commit 458fc53
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<Flag, Boolean> flags = new HashMap<>();
private final Field tp_location = new Field("tp_location", "default");
private final Field color = new Field("color", "#00BFFF");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "玩家没有权限时的提示消息位置")
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 458fc53

Please sign in to comment.