mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2025-02-17 21:49:37 +08:00
新增 MessageDisplay 配置,允许服务器管理员配置消息提示位置 #20
This commit is contained in:
parent
b818fc2153
commit
3a08f41906
@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "cn.lunadeer"
|
||||
version = "2.7.2-beta"
|
||||
version = "2.8.0-beta"
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
@ -38,7 +38,7 @@ allprojects {
|
||||
compileOnly("us.dynmap:DynmapCoreAPI:3.4")
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
|
||||
implementation("cn.lunadeer:MinecraftPluginUtils:1.3.8-SNAPSHOT")
|
||||
implementation("cn.lunadeer:MinecraftPluginUtils:1.3.9-SNAPSHOT")
|
||||
implementation("org.yaml:snakeyaml:2.0")
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
package cn.lunadeer.dominion;
|
||||
|
||||
import cn.lunadeer.dominion.dtos.*;
|
||||
import cn.lunadeer.dominion.utils.MessageDisplay;
|
||||
import cn.lunadeer.dominion.utils.Particle;
|
||||
import cn.lunadeer.dominion.utils.ResMigration;
|
||||
import cn.lunadeer.dominion.utils.map.MapRender;
|
||||
import cn.lunadeer.minecraftpluginutils.*;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import cn.lunadeer.minecraftpluginutils.AutoTimer;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -238,20 +239,10 @@ public class Cache {
|
||||
return last_dominion;
|
||||
}
|
||||
if (last_dom_id != -1) {
|
||||
String msg = last_dominion.getLeaveMessage();
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
msg = PlaceholderAPI.setPlaceholders(player, msg);
|
||||
}
|
||||
msg = ColorParser.getBukkitType(msg);
|
||||
Notification.actionBar(player, msg);
|
||||
MessageDisplay.show(player, Dominion.config.getMessageDisplayJoinLeave(), last_dominion.getLeaveMessage());
|
||||
}
|
||||
if (current_dom_id != -1) {
|
||||
String msg = current_dominion.getJoinMessage();
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
msg = PlaceholderAPI.setPlaceholders(player, msg);
|
||||
}
|
||||
msg = ColorParser.getBukkitType(msg);
|
||||
Notification.actionBar(player, msg);
|
||||
MessageDisplay.show(player, Dominion.config.getMessageDisplayJoinLeave(), current_dominion.getJoinMessage());
|
||||
}
|
||||
|
||||
lightOrNot(player, current_dominion); // 发光检查
|
||||
|
@ -2,6 +2,7 @@ package cn.lunadeer.dominion.managers;
|
||||
|
||||
import cn.lunadeer.dominion.Dominion;
|
||||
import cn.lunadeer.dominion.dtos.Flag;
|
||||
import cn.lunadeer.dominion.utils.MessageDisplay;
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import org.bukkit.Material;
|
||||
@ -11,10 +12,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class ConfigManager {
|
||||
public static ConfigManager instance;
|
||||
@ -41,7 +39,12 @@ public class ConfigManager {
|
||||
_db_name = _file.getString("Database.Name", "dominion");
|
||||
_db_user = _file.getString("Database.User", "postgres");
|
||||
_db_pass = _file.getString("Database.Pass", "postgres");
|
||||
|
||||
_auto_create_radius = _file.getInt("AutoCreateRadius", 10);
|
||||
|
||||
_message_display_no_permission = _file.getString("MessageDisplay.NoPermission", "ACTION_BAR");
|
||||
_message_display_join_leave = _file.getString("MessageDisplay.JoinLeave", "ACTION_BAR");
|
||||
|
||||
_spawn_protection = _file.getInt("Limit.SpawnProtection", 10);
|
||||
_blue_map = _file.getBoolean("BlueMap", false);
|
||||
_dynmap = _file.getBoolean("Dynmap", false);
|
||||
@ -111,6 +114,12 @@ public class ConfigManager {
|
||||
_file.set("AutoCreateRadius", _auto_create_radius);
|
||||
_file.setComments("AutoCreateRadius", Arrays.asList(Translation.Config_Comment_AutoCreateRadius.trans(), Translation.Config_Comment_NegativeOneDisabled.trans()));
|
||||
|
||||
_file.setComments("MessageDisplay", Collections.singletonList(Translation.Config_Comment_MessageDisplay.trans()));
|
||||
_file.set("MessageDisplay.NoPermission", _message_display_no_permission);
|
||||
_file.setComments("MessageDisplay.NoPermission", Collections.singletonList(Translation.Config_Comment_MessageDisplayNoPermission.trans()));
|
||||
_file.set("MessageDisplay.JoinLeave", _message_display_join_leave);
|
||||
_file.setComments("MessageDisplay.JoinLeave", Collections.singletonList(Translation.Config_Comment_MessageDisplayJoinLeave.trans()));
|
||||
|
||||
_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()));
|
||||
@ -267,6 +276,14 @@ public class ConfigManager {
|
||||
return _auto_clean_after_days;
|
||||
}
|
||||
|
||||
public MessageDisplay.Place getMessageDisplayNoPermission() {
|
||||
return MessageDisplay.Place.valueOf(_message_display_no_permission);
|
||||
}
|
||||
|
||||
public MessageDisplay.Place getMessageDisplayJoinLeave() {
|
||||
return MessageDisplay.Place.valueOf(_message_display_join_leave);
|
||||
}
|
||||
|
||||
public void setAutoCleanAfterDays(Integer auto_clean_after_days) {
|
||||
_auto_clean_after_days = auto_clean_after_days;
|
||||
_file.set("AutoCleanAfterDays", auto_clean_after_days);
|
||||
@ -397,6 +414,14 @@ public class ConfigManager {
|
||||
XLogger.err(Translation.Config_Check_AutoCleanAfterDaysError);
|
||||
setAutoCleanAfterDays(180);
|
||||
}
|
||||
if (Arrays.stream(MessageDisplay.Place.values()).noneMatch(place -> place.name().equals(getMessageDisplayNoPermission().name()))) {
|
||||
XLogger.err(Translation.Config_Check_MessageDisplayError, getMessageDisplayNoPermission());
|
||||
_message_display_no_permission = "ACTION_BAR";
|
||||
}
|
||||
if (Arrays.stream(MessageDisplay.Place.values()).noneMatch(place -> place.name().equals(getMessageDisplayJoinLeave().name()))) {
|
||||
XLogger.err(Translation.Config_Check_MessageDisplayError, getMessageDisplayJoinLeave());
|
||||
_message_display_join_leave = "ACTION_BAR";
|
||||
}
|
||||
if (getTpDelay() < 0) {
|
||||
XLogger.err(Translation.Config_Check_TpDelayError);
|
||||
setTpDelay(0);
|
||||
@ -450,6 +475,9 @@ public class ConfigManager {
|
||||
private String _group_title_prefix;
|
||||
private String _group_title_suffix;
|
||||
|
||||
private String _message_display_no_permission;
|
||||
private String _message_display_join_leave;
|
||||
|
||||
private final Map<String, GroupLimit> groupLimits = new HashMap<>();
|
||||
|
||||
private String getPlayerGroup(@Nullable Player player) {
|
||||
|
@ -831,6 +831,8 @@ public class Translation extends Localization {
|
||||
|
||||
@i18nField(defaultValue = "AutoCreateRadius 不能等于 0,已重置为 10")
|
||||
public static i18n Config_Check_AutoCreateRadiusError;
|
||||
@i18nField(defaultValue = "MessageDisplay 不能设置为 %s,已重置为 ACTION_BAR")
|
||||
public static i18n Config_Check_MessageDisplayError;
|
||||
@i18nField(defaultValue = "AutoCleanAfterDays 不能等于 0,已重置为 180")
|
||||
public static i18n Config_Check_AutoCleanAfterDaysError;
|
||||
@i18nField(defaultValue = "工具名称设置错误,已重置为 ARROW")
|
||||
@ -862,6 +864,12 @@ public class Translation extends Localization {
|
||||
public static i18n Config_Comment_Language;
|
||||
@i18nField(defaultValue = "自动创建领地的半径,单位为方块")
|
||||
public static i18n Config_Comment_AutoCreateRadius;
|
||||
@i18nField(defaultValue = "提示消息显示位置(BOSS_BAR, ACTION_BAR, TITLE, SUBTITLE, CHAT)")
|
||||
public static i18n Config_Comment_MessageDisplay;
|
||||
@i18nField(defaultValue = "玩家没有权限时的提示消息位置")
|
||||
public static i18n Config_Comment_MessageDisplayNoPermission;
|
||||
@i18nField(defaultValue = "进入/离开领地时的提示消息位置")
|
||||
public static i18n Config_Comment_MessageDisplayJoinLeave;
|
||||
@i18nField(defaultValue = "-1表示不开启")
|
||||
public static i18n Config_Comment_NegativeOneDisabled;
|
||||
@i18nField(defaultValue = "默认玩家圈地限制")
|
||||
|
@ -7,12 +7,6 @@ import cn.lunadeer.dominion.dtos.Flag;
|
||||
import cn.lunadeer.dominion.dtos.GroupDTO;
|
||||
import cn.lunadeer.dominion.dtos.MemberDTO;
|
||||
import cn.lunadeer.dominion.managers.Translation;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@ -77,11 +71,9 @@ public class EventUtils {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
TextComponent msg = Component.text(
|
||||
String.format(Translation.Messages_NoPermissionForFlag.trans(), flag.getDisplayName(), flag.getDescription()),
|
||||
Style.style(TextColor.color(0xFF0000), TextDecoration.BOLD))
|
||||
.hoverEvent(Component.text(flag.getDescription()));
|
||||
Notification.actionBar(player, msg);
|
||||
String msg = String.format(Translation.Messages_NoPermissionForFlag.trans(), flag.getDisplayName(), flag.getDescription());
|
||||
msg = "&#FF0000" + "&l" + msg;
|
||||
MessageDisplay.show(player, Dominion.config.getMessageDisplayNoPermission(), msg);
|
||||
if (event != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package cn.lunadeer.dominion.utils;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.ColorParser;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MessageDisplay {
|
||||
public enum Place {
|
||||
BOSS_BAR,
|
||||
ACTION_BAR,
|
||||
TITLE,
|
||||
SUBTITLE,
|
||||
CHAT
|
||||
}
|
||||
|
||||
public static void show(Player player, Place place, String message) {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
message = PlaceholderAPI.setPlaceholders(player, message);
|
||||
}
|
||||
message = ColorParser.getBukkitType(message);
|
||||
// BOSS_BAR, ACTION_BAR, TITLE, SUBTITLE, CHAT
|
||||
if (place == Place.BOSS_BAR) {
|
||||
Notification.bossBar(player, message);
|
||||
} else if (place == Place.CHAT) {
|
||||
player.sendMessage(message);
|
||||
} else if (place == Place.TITLE) {
|
||||
Notification.title(player, message);
|
||||
} else if (place == Place.SUBTITLE) {
|
||||
Notification.subTitle(player, message);
|
||||
} else {
|
||||
Notification.actionBar(player, message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,10 @@ Language: zh-cn
|
||||
|
||||
AutoCreateRadius: 10
|
||||
|
||||
MessageDisplay:
|
||||
NoPermission: ACTION_BAR
|
||||
JoinLeave: ACTION_BAR
|
||||
|
||||
Limit:
|
||||
SpawnProtection: 10
|
||||
MinY: -64
|
||||
|
@ -16,6 +16,13 @@ Language: zh-cn
|
||||
# -1表示不开启
|
||||
AutoCreateRadius: 10
|
||||
|
||||
# 领地提示消息显示位置(BOSS_BAR, ACTION_BAR, TITLE, SUBTITLE, CHAT)
|
||||
MessageDisplay:
|
||||
# 玩家没有权限时的提示消息位置
|
||||
NoPermission: ACTION_BAR
|
||||
# 进入/离开领地时的提示消息位置
|
||||
JoinLeave: SUBTITLE
|
||||
|
||||
# 默认玩家圈地限制
|
||||
Limit:
|
||||
SpawnProtection: 10 # 出生点保护半径 出生点此范围内不允许圈地-1表示不开启
|
||||
@ -105,6 +112,13 @@ Timer: false # 性能测试计时器
|
||||
|
||||
配置玩家在使用“自动创建”功能时会自动向XYZ三个方向延伸此距离创建领地。
|
||||
|
||||
### MessageDisplay
|
||||
|
||||
配置提示消息显示位置,可选项:`BOSS_BAR`, `ACTION_BAR`, `TITLE`, `SUBTITLE`, `CHAT`。
|
||||
|
||||
- NoPermission:玩家没有权限时的提示消息位置
|
||||
- JoinLeave:进入/离开领地时的提示消息位置
|
||||
|
||||
### Limit
|
||||
|
||||
玩家使用此插件的一些限制:
|
||||
|
@ -445,6 +445,7 @@ Config:
|
||||
LoadFlagError: 读取权限配置失败:%s
|
||||
TpDelayError: 传送延迟不能小于 0,已重置为 0
|
||||
TpCoolDownError: 传送冷却不能小于 0,已重置为 0
|
||||
MessageDisplayError: MessageDisplay 不能设置为 %s,已重置为 ACTION_BAR
|
||||
Comment:
|
||||
Language: 语言设置,参考 languages 文件夹下的文件名
|
||||
AutoCreateRadius: 自动创建领地的半径,单位为方块
|
||||
@ -461,6 +462,7 @@ Config:
|
||||
Depth: 子领地深度
|
||||
ZeroDisabled: 0表示不开启
|
||||
Vert: 是否自动延伸到 MaxY 和 MinY
|
||||
DisabledWorlds: 不允许圈地的世界列表
|
||||
OpBypass: 是否允许OP无视领地限制
|
||||
TpDelay: 传送延迟 秒
|
||||
TpCoolDown: 传送冷却 秒
|
||||
@ -486,6 +488,9 @@ Config:
|
||||
GroupLine7: 这里配置。详细说明参阅以下链接:
|
||||
GroupLine8DocumentAddress: '> https://dominion.lunadeer.cn/%s/operator/privilege.html'
|
||||
WorldSettings: 单独设置某个世界的圈地规则(如不设置则使用以上规则)
|
||||
MessageDisplay: 领地提示消息显示位置(BOSS_BAR, ACTION_BAR, TITLE, SUBTITLE, CHAT)
|
||||
MessageDisplayNoPermission: 玩家没有权限时的提示消息位置
|
||||
MessageDisplayJoinLeave: 进入/离开领地时的提示消息位置
|
||||
Flags:
|
||||
admin:
|
||||
DisplayName: 管理员
|
||||
|
Loading…
Reference in New Issue
Block a user