mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2024-12-26 07:18:52 +00:00
feat: 添加配置初始化 根据Tellraw数据发送不同消息
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
b4d7f14d49
commit
fffe3156a2
@ -1,9 +1,9 @@
|
||||
package pw.yumc.YumCore.config.inject;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import pw.yumc.YumCore.config.FileConfig;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 配置自动载入类
|
||||
*
|
||||
@ -24,6 +24,7 @@ public abstract class InjectConfig extends AbstractInjectConfig {
|
||||
public InjectConfig(FileConfig config) {
|
||||
this.config = config;
|
||||
inject(config);
|
||||
init();
|
||||
}
|
||||
|
||||
public InjectConfig(String name) {
|
||||
@ -39,12 +40,19 @@ public abstract class InjectConfig extends AbstractInjectConfig {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化配置(对象初始化也要在此处)
|
||||
*/
|
||||
public void init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载配置文件
|
||||
*/
|
||||
public void reload() {
|
||||
config.reload();
|
||||
inject(config);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,19 +1,18 @@
|
||||
package pw.yumc.YumCore.tellraw;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import pw.yumc.YumCore.bukkit.Log;
|
||||
import pw.yumc.YumCore.bukkit.P;
|
||||
import pw.yumc.YumCore.bukkit.compatible.C;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TellRaw简易处理类
|
||||
*
|
||||
@ -22,7 +21,9 @@ import pw.yumc.YumCore.bukkit.compatible.C;
|
||||
*/
|
||||
public class Tellraw {
|
||||
static boolean isPaper = Bukkit.getVersion().contains("Paper");
|
||||
List<MessagePart> messageParts = new ArrayList<>();
|
||||
private List<MessagePart> messageParts = new ArrayList<>();
|
||||
private String json = null;
|
||||
private String oldjson = null;
|
||||
|
||||
public Tellraw(String text) {
|
||||
messageParts.add(new MessagePart(text));
|
||||
@ -161,16 +162,17 @@ public class Tellraw {
|
||||
* 命令发送者
|
||||
*/
|
||||
public void send(final CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
final String json = toJsonString();
|
||||
if (sender instanceof Player && json.getBytes().length < 32000) {
|
||||
if (isPaper && !Bukkit.isPrimaryThread()) {
|
||||
Bukkit.getScheduler().runTask(P.instance, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + toJsonString());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + json);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + toJsonString());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + sender.getName() + " " + json);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(toOldMessageFormat());
|
||||
@ -258,9 +260,7 @@ public class Tellraw {
|
||||
* @return {@link Tellraw}
|
||||
*/
|
||||
public Tellraw tip(List<String> texts) {
|
||||
if (texts.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
if (texts.isEmpty()) { return this; }
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (String t : texts) {
|
||||
text.append(t).append("\n");
|
||||
|
Loading…
Reference in New Issue
Block a user