build: 优化构建脚本
This commit is contained in:
@@ -55,7 +55,7 @@ public class HamsterCorePlugin extends JavaPlugin {
|
||||
.create();
|
||||
CoreBukkitAPI.init();
|
||||
logger.info("已初始化 CoreBukkitAPI.");
|
||||
CoreMessage.init(this);
|
||||
CoreMessage.init(getLogger(), getConfig().getConfigurationSection("messages"));
|
||||
logger.info("已初始化语言文本.");
|
||||
long time = System.currentTimeMillis() - start;
|
||||
logger.info("仓鼠核心初始化完成,总计耗时 " + time + " ms.");
|
||||
|
@@ -7,8 +7,10 @@ import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public enum CoreMessage {
|
||||
COMMAND_NOT_FOUND,
|
||||
@@ -40,10 +42,9 @@ public enum CoreMessage {
|
||||
|
||||
private DisplayMessage message;
|
||||
|
||||
public static void init(@NotNull Plugin plugin) {
|
||||
ConfigurationSection config = plugin.getConfig().getConfigurationSection("messages");
|
||||
public static void init(@NotNull Logger logger, @Nullable ConfigurationSection config) {
|
||||
if (config == null) {
|
||||
plugin.getLogger().warning("加载消息失败: 配置文件中未找到 messages 节点!");
|
||||
logger.warning("加载消息失败: 配置文件中未找到 messages 节点!");
|
||||
return;
|
||||
}
|
||||
for (CoreMessage value : values()) {
|
||||
@@ -54,13 +55,13 @@ public enum CoreMessage {
|
||||
try {
|
||||
value.message = CoreBukkitUtils.getDisplayMessage(section);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("加载消息设置 " + value.name() + " 时遇到了一个异常: ");
|
||||
logger.warning("加载消息设置 " + value.name() + " 时遇到了一个异常: ");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void show(CommandSender sender, TextReplacementConfig... replacement) {
|
||||
public void show(@NotNull CommandSender sender, TextReplacementConfig... replacement) {
|
||||
if (message == null) {
|
||||
sender.sendMessage(name());
|
||||
return;
|
||||
|
Reference in New Issue
Block a user