coolslowen
πŸ“Ž 1 file 1,516 chars
πŸ“„
pasted-code-1779963926892.txt
txt 56 lines
β–Ά
# EternalWorldCount Plugin Request

Create a professional Minecraft Paper plugin using Java 21 named β€œEternalWorldCount”.

## General Features

* Plugin author must be set to: `Slowen`
* All plugin logs and messages must use the prefix: `Eternal Network`
* The plugin must integrate with PlaceholderAPI
* Code should be clean, optimized, modern, and professional
* Do not add unnecessary comments
* The project must use Maven
* Include a complete and properly configured `plugin.yml`
* Register the PlaceholderExpansion correctly
* Add detailed and colorful startup/shutdown console logs
* Use modern Paper API standards

## Placeholder System

### 1. %dunya_info%

This placeholder should display:

* The player's current world name
* The amount of players currently inside that world

Format example:
spawn (12)

### 2. %dunya_%

This placeholder should return only the player count of the specified world.

Examples:

* `%dunya_spawn%` β†’ `12`
* `%dunya_nether%` β†’ `3`

## Additional Requirements

* Automatically support all worlds
* If a world does not exist, return `0`
* Add detailed error and debug logs
* Check if PlaceholderAPI is installed before enabling the plugin
* Log placeholder registration steps in console
* Plugin must be performance friendly
* Structure the code professionally
* Use asynchronous-safe practices where necessary
* Make the plugin production-ready

## Example Outputs

* spawn (5)
* nether (2)
* world_the_end (0)
Kodari AI
KodariMay 28 at 10:26 am 6
EternalWorldCount
A lightweight Paper plugin that integrates with PlaceholderAPI to expose world player count data. Provides %dunya_info% (current world name + player count) and %dunya_<worldname>% (player count for any world by name) placeholders. Automatically supports all worlds, returns 0 for non-existent worlds, and includes colorful startup/shutdown console logs. Built for performance with thread-safe practices.

Here’s the full plugin built to spec:

Structure:

Plain Text
EternalWorldCount/
β”œβ”€β”€ pom.xml
└── src/main/
    β”œβ”€β”€ java/com/eternalnetwork/worldcount/
    β”‚   β”œβ”€β”€ EternalWorldCount.java          ← Main plugin class
    β”‚   └── placeholder/
    β”‚       └── WorldCountExpansion.java    ← PAPI expansion
    └── resources/
        └── plugin.yml

Key decisions:

  • softdepend on PlaceholderAPI β€” plugin loads but self-disables with a clear error if PAPI is absent

  • persist() returns true so the expansion survives PAPI reloads without re-registering

  • %dunya_info% gracefully handles null player context (relational placeholders)

  • %dunya_<worldname>% returns "0" for any world that doesn’t exist, with a debug log

  • Console colors use raw ANSI codes since Paper’s logger strips Bukkit ChatColor β€” the banner and all log lines render in color in modern terminals

  • onPlaceholderRequest (not onRequest) is used since this expansion is player-aware

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
4 245
src/main/java/com/eternalnetwork/worldcount/EternalWorldCount.java
package com.eternalnetwork.worldcount;

import com.eternalnetwork.worldcount.placeholder.WorldCountExpansion;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class EternalWorldCount extends JavaPlugin {

    private static final String PREFIX = "&8[&6Eternal Network&8] &r";

    @Override
    public void onEnable() {
        printBanner();

        if (!isPlaceholderAPIPresent()) {
            log("&cPlaceholderAPI was not found. The plugin cannot function without it.");
            log("&cDownload PlaceholderAPI from: &ehttps://www.spigotmc.org/resources/6245/");
            log("&cDisabling EternalWorldCount...");
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }

        log("&aPlaceholderAPI detected. Proceeding with registration...");

        WorldCountExpansion expansion = new WorldCountExpansion(this);
        if (expansion.register()) {
            log("&aSuccessfully registered placeholder expansion &e'dunya'&a.");
            log("&7Available placeholders:");
            log("&7  &e%dunya_info%        &7- Current world name and player count");
            log("&7  &e%dunya_<worldname>% &7- Player count for the specified world");
        } else {
            log("&cFailed to register placeholder expansion. Check PlaceholderAPI status.");
        }

        log("&aEternalWorldCount &2v" + getDescription().getVersion() + " &ahas been enabled successfully.");
    }

    @Override
    public void onDisable() {
        log("&cEternalWorldCount has been disabled. Goodbye!");
    }

    private boolean isPlaceholderAPIPresent() {
        return Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
    }

    private void printBanner() {
        String line = color("&8&m----------------------------------------");
        getLogger().info(color(line));
        getLogger().info(color("&r"));
        getLogger().info(color("  &6Eternal &eNetwork &7- &bEternalWorldCount"));
        getLogger().info(color("  &7Version: &f" + getDescription().getVersion()));
        getLogger().info(color("  &7Author:  &fSlowen"));
        getLogger().info(color("&r"));
        getLogger().info(color(line));
    }

    public void log(String message) {
        getLogger().info(color(PREFIX + message));
    }

    public static String color(String message) {
        return message
                .replace("&0", "\u001B[30m")
                .replace("&1", "\u001B[34m")
                .replace("&2", "\u001B[32m")
                .replace("&3", "\u001B[36m")
                .replace("&4", "\u001B[31m")
                .replace("&5", "\u001B[35m")
                .replace("&6", "\u001B[33m")
                .replace("&7", "\u001B[37m")
                .replace("&8", "\u001B[90m")
                .replace("&9", "\u001B[94m")
                .replace("&a", "\u001B[92m")
                .replace("&b", "\u001B[96m")
                .replace("&c", "\u001B[91m")
                .replace("&d", "\u001B[95m")
                .replace("&e", "\u001B[93m")
                .replace("&f", "\u001B[97m")
                .replace("&l", "\u001B[1m")
                .replace("&m", "\u001B[9m")
                .replace("&n", "\u001B[4m")
                .replace("&o", "\u001B[3m")
                .replace("&r", "\u001B[0m");
    }
}