feat: 执行指令时检测 PlaceholderAPI 是否存在并替换变量
This commit is contained in:
@@ -13,6 +13,9 @@ dependencies {
|
|||||||
compileOnly("org.black_ixx:playerpoints:3.2.6") {
|
compileOnly("org.black_ixx:playerpoints:3.2.6") {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
}
|
}
|
||||||
|
compileOnly("me.clip:placeholderapi:2.11.5") {
|
||||||
|
isTransitive = false
|
||||||
|
}
|
||||||
|
|
||||||
implementation("net.kyori:adventure-platform-bukkit:4.3.2") {
|
implementation("net.kyori:adventure-platform-bukkit:4.3.2") {
|
||||||
exclude(group = "org.jetbrains")
|
exclude(group = "org.jetbrains")
|
||||||
|
@@ -5,6 +5,7 @@ import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import de.tr7zw.changeme.nbtapi.NBTContainer;
|
import de.tr7zw.changeme.nbtapi.NBTContainer;
|
||||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.kyori.adventure.title.Title;
|
import net.kyori.adventure.title.Title;
|
||||||
@@ -386,6 +387,10 @@ public final class CoreBukkitUtils {
|
|||||||
|
|
||||||
@SuppressWarnings("CallToPrintStackTrace")
|
@SuppressWarnings("CallToPrintStackTrace")
|
||||||
public static void executeCommand(@NotNull Player player, @NotNull String command) {
|
public static void executeCommand(@NotNull Player player, @NotNull String command) {
|
||||||
|
command = command.replace("%player_name%", player.getName());
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||||
|
command = PlaceholderAPI.setPlaceholders(player, command);
|
||||||
|
}
|
||||||
String[] split = command.split(":", 2);
|
String[] split = command.split(":", 2);
|
||||||
try {
|
try {
|
||||||
switch (split[0]) {
|
switch (split[0]) {
|
||||||
|
Reference in New Issue
Block a user