feat: 实现 ProtocolLib 自定义标题

This commit is contained in:
Coldsmile_7
2026-04-15 03:07:25 +08:00
parent cc07647551
commit 6452226151
5 changed files with 73 additions and 14 deletions

View File

@@ -1,8 +1,12 @@
package cn.infstar.essentialsC.commands;
import cn.infstar.essentialsC.EssentialsC;
import cn.infstar.essentialsC.listeners.InventoryTitleListener;
import org.bukkit.entity.Player;
/**
* 末影箱命令 - 使用 ProtocolLib 实现自定义标题
*/
public class EnderChestCommand extends BaseCommand {
public EnderChestCommand() {
@@ -11,18 +15,15 @@ public class EnderChestCommand extends BaseCommand {
@Override
protected boolean execute(Player player, String[] args) {
EssentialsC plugin = EssentialsC.getInstance();
InventoryTitleListener titleListener = EssentialsC.getInventoryTitleListener();
// 如果启用了 ProtocolLib,使用自定义标题
if (plugin.isProtocolLibEnabled()) {
// 从配置读取标题
String title = plugin.getConfig().getString("enderchest.title", "&5随身末影箱");
// 标记下一个打开的 inventory 需要修改标题
plugin.getInventoryTitleListener().markForTitleChange(player, title);
// 如果 ProtocolLib 可用,设置自定义标题
if (titleListener != null) {
String title = "&5随身末影箱";
titleListener.markForTitleChange(player, title);
}
// 直接打开玩家的末影箱(参考 EssentialsX 实现)
// 打开末影箱
player.openInventory(player.getEnderChest());
return true;
}