This commit is contained in:
parent
43dc8f0abc
commit
937f9fcd8f
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>EssentialsD</artifactId>
|
||||
<version>2.2.3</version>
|
||||
<version>2.3.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EssentialsD</name>
|
||||
|
@ -22,6 +22,7 @@ import cn.lunadeer.essentialsd.commands.weather.Sun;
|
||||
import cn.lunadeer.essentialsd.events.*;
|
||||
import cn.lunadeer.essentialsd.managers.ConfigManager;
|
||||
import cn.lunadeer.essentialsd.managers.DatabaseTables;
|
||||
import cn.lunadeer.essentialsd.managers.TabListUpdater;
|
||||
import cn.lunadeer.essentialsd.managers.TeleportManager;
|
||||
import cn.lunadeer.essentialsd.recipes.*;
|
||||
import cn.lunadeer.minecraftpluginutils.*;
|
||||
@ -53,6 +54,7 @@ public final class EssentialsD extends JavaPlugin {
|
||||
if (config.getPrefixEnable()) {
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
Bukkit.getPluginManager().registerEvents(new ChatPrefixEvent(), this);
|
||||
new TabListUpdater(); // 更新 TabList
|
||||
} else {
|
||||
XLogger.warn("未找到 PlaceholderAPI 插件, 无法使用聊天前缀功能, 已自动关闭前缀功能");
|
||||
config.setPrefixEnable(false);
|
||||
|
@ -335,6 +335,16 @@ public class ConfigManager {
|
||||
_plugin.saveConfig();
|
||||
}
|
||||
|
||||
public String getPrefixTabFormat() {
|
||||
return _prefix_tab_format;
|
||||
}
|
||||
|
||||
public void setPrefixTabFormat(String format) {
|
||||
_prefix_tab_format = format;
|
||||
_file.set("Prefix.TabFormat", format);
|
||||
_plugin.saveConfig();
|
||||
}
|
||||
|
||||
|
||||
private final EssentialsD _plugin;
|
||||
private FileConfiguration _file;
|
||||
|
@ -0,0 +1,24 @@
|
||||
package cn.lunadeer.essentialsd.managers;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TabListUpdater {
|
||||
|
||||
public static TabListUpdater instance;
|
||||
|
||||
public TabListUpdater() {
|
||||
instance = this;
|
||||
Scheduler.runTaskRepeatAsync(this::update, 0, 40);
|
||||
}
|
||||
|
||||
private void update() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
String formated = PlaceholderAPI.setPlaceholders(player, EssentialsD.config.getPrefixTabFormat());
|
||||
player.setPlayerListName(formated);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user