在 Bukkit 1.20 中,使用 PlaceholderAPI 2.11.3 版本,可以通过以下方式获取所有可用的占位符:

import me.clip.placeholderapi.PlaceholderAPI;

public class YourClass {
    public void yourMethod() {
        // 获取所有可用的占位符
        Map<String, PlaceholderAPI.PlaceholderRequest> placeholders = PlaceholderAPI.getPlaceholders();

        // 遍历所有占位符
        for (Map.Entry<String, PlaceholderAPI.PlaceholderRequest> entry : placeholders.entrySet()) {
            String placeholder = entry.getKey();
            PlaceholderAPI.PlaceholderRequest request = entry.getValue();

            // 打印占位符和请求信息
            System.out.println('占位符: ' + placeholder);
            System.out.println('请求信息: ' + request.toString());
        }
    }
}

在上面的示例中,我们通过 PlaceholderAPI.getPlaceholders() 方法获取了所有可用的占位符,并将其存储在一个 Map<String, PlaceholderAPI.PlaceholderRequest> 对象中。然后,我们遍历该 Map 对象,获取每个占位符的名称和请求信息,并进行相应的操作。

请注意,您需要确保已正确安装并加载了 PlaceholderAPI 插件,并在代码中导入正确的 PlaceholderAPI 类。

Bukkit 1.20 PlaceholderAPI 2.11.3: 获取所有可用占位符 - PlaceholderAPI.getPlaceholders() 方法

原文地址: https://www.cveoy.top/t/topic/fTrT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录