Fix HEX color parsing - normalize to lowercase - Added normalizeMiniMessageHex to convert existing <#RRGGBB> tags to lowercase - convertHexColors now outputs lowercase hex codes - Added send/getComponent methods to MessageConfig
This commit is contained in:
parent
d2c45b3f0c
commit
f4752000c8
2 changed files with 51 additions and 4 deletions
|
|
@ -2,6 +2,8 @@ package com.loki.lochat.config;
|
|||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.utils.ChatFormatter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
|
|
@ -43,6 +45,34 @@ public class MessageConfig {
|
|||
return ChatFormatter.convertAllColors(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает сообщение как Component
|
||||
*/
|
||||
public Component getComponent(String path) {
|
||||
return ChatFormatter.parse(get(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает сообщение как Component с заменами
|
||||
*/
|
||||
public Component getComponent(String path, String... replacements) {
|
||||
return ChatFormatter.parse(get(path, replacements));
|
||||
}
|
||||
|
||||
/**
|
||||
* Отправляет сообщение игроку
|
||||
*/
|
||||
public void send(CommandSender sender, String path) {
|
||||
sender.sendMessage(getComponent(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Отправляет сообщение игроку с заменами
|
||||
*/
|
||||
public void send(CommandSender sender, String path, String... replacements) {
|
||||
sender.sendMessage(getComponent(path, replacements));
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
public String getPrefix() {
|
||||
return get("prefix");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue