feat(core-bukkit): 当安装 PlaceholderAPI 时自动替换 UI 变量
This commit is contained in:
@@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "cn.hamster3.mc.plugin"
|
||||
version = "1.3.0"
|
||||
version = "1.3.1"
|
||||
|
||||
subprojects {
|
||||
apply {
|
||||
|
@@ -3,6 +3,7 @@ package cn.hamster3.mc.plugin.core.bukkit.page.handler;
|
||||
import cn.hamster3.mc.plugin.core.bukkit.page.ButtonGroup;
|
||||
import cn.hamster3.mc.plugin.core.bukkit.page.PageConfig;
|
||||
import cn.hamster3.mc.plugin.core.bukkit.page.PageManager;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
@@ -118,6 +119,9 @@ public abstract class PageHandler implements InventoryHolder {
|
||||
@NotNull
|
||||
public String getTitle() {
|
||||
String title = pageConfig.getTitle();
|
||||
if (player instanceof Player && Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
title = PlaceholderAPI.setPlaceholders((Player) player, title);
|
||||
}
|
||||
for (Map.Entry<String, String> entry : getPageVariables().entrySet()) {
|
||||
title = title.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
@@ -390,21 +390,25 @@ public final class CoreBukkitUtils {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
command = PlaceholderAPI.setPlaceholders(player, command);
|
||||
}
|
||||
String[] split = command.split(":", 2);
|
||||
switch (split[0]) {
|
||||
String[] args = command.split(":", 2);
|
||||
switch (args[0]) {
|
||||
case "player": {
|
||||
Bukkit.dispatchCommand(player, split[1]);
|
||||
Bukkit.dispatchCommand(player, args[1]);
|
||||
break;
|
||||
}
|
||||
case "console": {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), split[1]);
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), args[1]);
|
||||
break;
|
||||
}
|
||||
case "message": {
|
||||
player.sendMessage(args[1]);
|
||||
break;
|
||||
}
|
||||
case "op": {
|
||||
boolean op = player.isOp();
|
||||
player.setOp(true);
|
||||
try {
|
||||
Bukkit.dispatchCommand(player, split[1]);
|
||||
Bukkit.dispatchCommand(player, args[1]);
|
||||
} finally {
|
||||
player.setOp(op);
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ load: STARTUP
|
||||
softdepend:
|
||||
- Vault
|
||||
- PlayerPoints
|
||||
- PlaceholderAPI
|
||||
|
||||
loadbefore:
|
||||
- HamsterAPI
|
||||
|
Reference in New Issue
Block a user