kitti.g

plugin สร้าง ตัวยึดตำแหน่งผ่าน config เพื่อนำไปใช้กับ plugin ต่างๆที่รองรับ PlaceholderAPI ตัวอย่าง config edition: "PC": "&fPC" "BE": "&fBE" แสดงผลผู้เล่น java จะขึ้น PC ผู้เล่น Bedrock จะขึ้น BE มีคำสั่งรีโหลด config

Kodari AI
KodariJul 9 at 3:56 pm 1

I’ll create a Minecraft plugin that displays player edition (PC/BE) via PlaceholderAPI, configurable through config.yml.

EditionPlaceholders
Config-driven placeholder plugin that shows player edition type (PC/BE) through PlaceholderAPI. Supports Floodgate detection for Bedrock players. Display text is fully customizable via config.yml with color code support. Includes a reload command for hot-reloading configuration without server restart. No hard dependencies — gracefully falls back to PC if Floodgate is absent.
A lightweight PlaceholderAPI expansion plugin that displays the player's game edition (PC or Bedrock Edition) via configurable placeholders. Supports Floodgate/Geyser detection to distinguish Java and Bedrock players. Fully customizable labels through config.yml, reload command included. Ideal for cross-platform servers wanting to show edition-specific prefixes or tags.
A Minecraft plugin that displays player edition labels (PC/Bedrock) via PlaceholderAPI. Detects Bedrock players through Floodgate API and shows customizable labels from config.yml. Includes a reload command and full PlaceholderAPI expansion integration. Supports color codes in labels. Lightweight, no dependencies beyond PlaceholderAPI and optional Floodgate.

Let me create all the project files.

สรุปโปรเจกต์ EditionPlaceholders:

  • PlaceholderAPI: %edition_type% — แสดงป้ายชื่อตามรุ่นของผู้เล่น

  • Config: กำหนดข้อความสำหรับ PC (Java) และ BE (Bedrock) รองรับสี &

  • ตรวจจับ Bedrock: ใช้ Floodgate API — ถ้าไม่มี Floodgate จะแสดง PC เสมอ

  • คำสั่ง: /edition reload (สิทธิ์ editionplaceholders.admin) — โหลด config ใหม่

  • Soft dependencies: PlaceholderAPI (จำเป็น), floodgate (optional)

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
6 181
src/main/java/com/editionplaceholders/EditionPlaceholders.java
package com.editionplaceholders;

import com.editionplaceholders.expansion.EditionExpansion;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
import java.util.Map;

public class EditionPlaceholders extends JavaPlugin {

    private Map<String, String> editionLabels;
    private EditionExpansion expansion;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        loadEditionLabels();

        if (getServer().getPluginManager().getPlugin("PlaceholderAPI") == null) {
            getLogger().severe("PlaceholderAPI not found! Disabling plugin.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        expansion = new EditionExpansion(this);
        if (expansion.register()) {
            getLogger().info("Placeholder expansion registered successfully!");
        } else {
            getLogger().severe("Failed to register PlaceholderAPI expansion!");
        }
    }

    @Override
    public void onDisable() {
        if (expansion != null) {
            expansion.unregister();
        }
    }

    public void loadEditionLabels() {
        editionLabels = new HashMap<>();
        FileConfiguration config = getConfig();
        if (config.isConfigurationSection("edition")) {
            for (String key : config.getConfigurationSection("edition").getKeys(false)) {
                String value = ChatColor.translateAlternateColorCodes('&',
                        config.getString("edition." + key, key));
                editionLabels.put(key, value);
            }
        }
    }

    public String getEditionLabel(String edition) {
        return editionLabels.getOrDefault(edition, edition);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
            if (!sender.hasPermission("editionplaceholders.admin")) {
                sender.sendMessage(ChatColor.RED + "You don't have permission!");
                return true;
            }
            reloadConfig();
            loadEditionLabels();
            sender.sendMessage(ChatColor.GREEN + "Configuration reloaded!");
            return true;
        }
        return false;
    }
}