sanixcraft.

Create a high-performance Minecraft plugin named SanixLB (Sanix Leaderboards).

---

NEW REQUIREMENT: FORMAT CONTROL + INTERACTIVE LEADERBOARDS

  1. Custom Line Formatting (FULLY CONFIGURABLE)

Leaderboard lines must NOT be hardcoded.

Admins can define format in config like:

format: line: "&e{position}. {name} &7»"

Examples output:

  • "1. Ssjius »"
  • "2. Ahausi »"

Support placeholders:

  • "{position}"
  • "{name}"
  • "{value}" (optional)

---

  1. Interactive Scope Switching (CRITICAL FEATURE)

Under the leaderboard (like in holograms or chat), allow this:

footer: - "&7[ &aDaily &7] [ &bWeekly &7] [ &6Alltime &7]"

Behavior:

  • These MUST be clickable (using text components / packets)
  • Clicking changes the leaderboard scope dynamically:

- Daily → shows daily leaderboard - Weekly → shows weekly leaderboard - Alltime → shows alltime leaderboard

---

  1. Implementation (DO IT PROPERLY)

DO NOT fake this with placeholders only. That’s weak.

Use:

  • Adventure API (Component + ClickEvent)
  • OR Spigot TextComponent

Click actions:

  • Run internal command:

- "/slb view <stat> daily" - "/slb view <stat> weekly" - "/slb view <stat> alltime"

---

  1. Hologram Interaction (IMPORTANT LIMITATION)

Holograms are NOT naturally clickable.

So:

Option A (Recommended):

  • Use interaction entities (1.19+)
  • Invisible hitbox near hologram lines
  • Clicking triggers scope switch

Option B (Fallback):

  • Use chat-based interaction only
  • OR command suggestion on click

---

  1. Placeholder-Based Fallback (REQUIRED)

Also support static placeholders like:

  • "%slb_current_scope%"
  • "%slb_switch_daily%"
  • "%slb_switch_weekly%"
  • "%slb_switch_alltime%"

These return formatted clickable text (for chat use).

---

  1. Smart Rendering
  • When player clicks:

- DO NOT recalc leaderboard - Pull from cached data

  • Store per-player selected scope (Map<UUID, Scope>)
  • Update only that player’s view

---

  1. Performance Rules (STRICT)
  • No recalculation on click
  • No DB query on click
  • Use precomputed cache only
  • Minimal packet updates

---

  1. Example Hologram Config

lines: - "&6Top Playtime" - "&e{1}. %slb_name_1% &7»" - "&e{2}. %slb_name_2% &7»" - "&e{3}. %slb_name_3% &7»" - "" - "&7[ &aDaily &7] [ &bWeekly &7] [ &6Alltime &7]"

---

  1. Commands to Support Interaction
  • "/slb view <stat> <scope>"
  • "/slb setscope <scope>" (optional)

---

OUTPUT REQUIREMENTS

Generate:

  • Formatting system
  • Clickable component builder
  • Player scope manager
  • Cached leaderboard renderer
  • Hologram interaction system (entity-based if possible)

---

Make this system scalable, clean, and designed like a premium plugin, not a basic one.

Kodari AI
KodariApr 14 at 9:02 am 21,078 (v2)

I’ll create a premium leaderboard plugin with fully configurable formatting, interactive scope switching, and high-performance caching.

SanixLB
A high-performance, fully customizable leaderboard system with interactive scope switching (daily/weekly/alltime). Features beautifully formatted leaderboards with dynamic placeholders, clickable components for instant scope changes, hologram integration with interaction entities, MySQL/SQLite support with connection pooling, automatic time-based resets, player-specific views, and comprehensive PlaceholderAPI support. Designed for premium servers requiring scalable stat tracking without performance overhead.

All files created successfully. SanixLB is now a premium-quality leaderboard plugin with interactive scope switching, configurable formatting, PlaceholderAPI integration, cached performance, and hologram compatibility.

sanixcraft.

Create a production-grade Minecraft plugin named SanixLB (Sanix Leaderboards).

The plugin must be fully optimized, modular, and scalable for large servers.

---

CORE SYSTEM

  • Java (Paper/Spigot API)
  • Async database (MySQL + SQLite fallback)
  • Cached leaderboards (NO recalculation on request)
  • Internal placeholder system + PlaceholderAPI hook support

---

PLACEHOLDER SYSTEM (STRICT REQUIREMENT)

  1. Auto Registration
  • The plugin MUST automatically register its placeholders on startup
  • If PlaceholderAPI is installed:

- Auto-register expansion (NO manual "/papi ecloud download")

  • If PlaceholderAPI is NOT installed:

- Internal placeholders must STILL work inside the plugin (holograms, INVENTORY GUI, etc.)

---

  1. Placeholder Format

Support BOTH:

Internal usage:

%slb_<scope>_<stat>_<position>_name% %slb_<scope>_<stat>_<position>_value%

PlaceholderAPI usage:

Same format must work globally (chat, other plugins, holograms)

---

  1. Scopes
  • "daily"
  • "weekly"
  • "alltime"

---

  1. Stats
  • "kills"
  • "deaths"
  • "playtime"
  • "money" (Vault)

---

  1. Placeholder Behavior (MANDATORY)
  • Every placeholder MUST always return a valid value:

- If no player exists → return ""None"" - If no data → return ""0""

  • MUST NOT return null
  • MUST NOT break parsing

---

  1. Performance Rules
  • NO database queries when parsing placeholders
  • ONLY use cached leaderboard data
  • Fast string parsing (no heavy regex per call)

---

MAIN COMMANDS

"/slb reload"

  • Reload configs
  • Reload holograms
  • Reload leaderboard cache safely (async)

---

HOLOGRAM SYSTEM (CRITICAL FEATURE)

DO NOT depend on external plugins.

Use TextDisplay (1.19+).

---

"/slbholo" INVENTORY GUI COMMAND

"/slbholo"

Opens a INVENTORY GUI with 4 options:

  • Kills
  • Deaths
  • Playtime
  • Money

---

INVENTORY GUI BEHAVIOR

When player clicks one option:

  • Automatically create a hologram at player location
  • Use that stat type
  • Save config file

---

HOLOGRAM STORAGE

Create folder:

/plugins/SanixLB/leaderboards/

Each hologram:

<id>.yml

---

FILE STRUCTURE EXAMPLE

location: world: world x: 100.5 y: 64.0 z: 200.5

stat: money default-scope: alltime update-interval: 5

lines: - "&6Top Money" - "&7Leaderboard" - "" - "&e1. %slb_{scope}_money_1_name% &7» &e$%slb_{scope}_money_1_value%" - "&e2. %slb_{scope}_money_2_name% &7» &e$%slb_{scope}_money_2_value%" - "&e3. %slb_{scope}_money_3_name% &7» &e$%slb_{scope}_money_3_value%" - ... - "" - "&7[ &aDaily &7] [ &bWeekly &7] [ &6Alltime &7]"

---

AUTO GENERATION RULES

When created via INVENTORY GUI:

  • Auto-generate ID (lb_1, lb_2, etc.)
  • Save file instantly
  • Spawn hologram instantly

---

INTERACTION SYSTEM (IMPORTANT)

Clicking hologram must:

  • Switch between:

- daily - weekly - alltime

Implementation:

  • Use Interaction Entities OR hitbox system
  • Each player has their own selected scope
  • DO NOT globally change hologram

---

RENDERING ENGINE

  • Replace "{scope}" dynamically per player
  • Use cached leaderboard data
  • NO DB calls during render

---

UPDATE SYSTEM

  • Batch update all holograms async
  • Only update text if changed
  • Avoid flickering

---

INVENTORY GUI SYSTEM

  • Use Inventory INVENTORY GUI
  • Clean icons:

- Diamond Sword → kills - Totem → deaths -HOLOGRAM CONTENT FORMAT (STRICT – DO NOT MODIFY STRUCTURE)

ALL generated leaderboards MUST use this EXACT content format.

ONLY replace "<stat>" dynamically (money, kills, deaths, playtime).

DO NOT change structure, colors, symbols, spacing, or layout.

---

TEMPLATE (CONTENT ONLY)

pages:

  • lines:

- content: '&#28FF9ETop <stat_display>' height: 0.3 - content: '&7ʟᴇᴀᴅᴇʀʙᴏᴀʀᴅ' height: 0.3 - content: '&r' height: 0.2 - content: '&#28FF9E➊ &7| &f%slb_alltime_<stat>_1_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_1_value%' height: 0.3 - content: '&#28FF9E➋ &7| &f%slb_alltime_<stat>_2_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_2_value%' height: 0.3 - content: '&#28FF9E➌ &7| &f%slb_alltime_<stat>_3_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_3_value%' height: 0.3 - content: '&#28FF9E➍ &7| &f%slb_alltime_<stat>_4_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_4_value%' height: 0.3 - content: '&#28FF9E➎ &7| &f%slb_alltime_<stat>_5_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_5_value%' height: 0.3 - content: '&#28FF9E➏ &7| &f%slb_alltime_<stat>_6_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_6_value%' height: 0.3 - content: '&#28FF9E➐ &7| &f%slb_alltime_<stat>_7_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_7_value%' height: 0.3 - content: '&#28FF9E➑ &7| &f%slb_alltime_<stat>_8_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_8_value%' height: 0.3 - content: '&#28FF9E➒ &7| &f%slb_alltime_<stat>_9_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_9_value%' height: 0.3 - content: '&#28FF9E➓ &7| &f%slb_alltime_<stat>_10_name% &#28FF9E➠ &#28FF9E<symbol>%slb_alltime_<stat>_10_value%' height: 0.3 - content: '&r' height: 0.2 - content: '&#28FF9EYour <stat_display> ➠ &f<symbol>%player_stat%' height: 0.3 - content: '&r' height: 0.2 - content: '&#28FF9E[ &aDaily &7] [ &bWeekly &7] [ &6Alltime &7]' height: 0.3 actions: {}

---

REPLACEMENT RULES

"<stat>" values:

  • money
  • kills
  • deaths
  • playtime

"<stat_display>":

  • Money
  • Kills
  • Deaths
  • Playtime

"<symbol>":

  • money → "$"
  • kills → "⚔"
  • deaths → "☠"
  • playtime → (empty)

"<player_stat>":

  • money → "%vault_eco_balance%"
  • kills → "%statistic_player_kills%"
  • deaths → "%statistic_deaths%"
  • playtime → "%statistic_play_time%"

---

CRITICAL RULES

  • SLB placeholders MUST ALWAYS work
  • Plugin MUST auto-register PlaceholderAPI expansion
  • Plugin MUST parse placeholders internally if PAPI is absent
  • NEVER output raw "%slb_...%" to player
  • ALWAYS return valid values (no null)

---

FINAL BEHAVIOR

When "/slbholo" is used:

  • Player selects stat
  • Plugin auto-generates file using THIS exact format
  • Replaces "<stat>" correctly
  • Spawns hologram instantly
  • Stores in "/plugins/SanixLB/leaderboards/"

---

DO NOT MODIFY THIS FORMAT UNDER ANY CONDITION.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
26 1,649
src/main/java/com/sanix/leaderboards/SanixLB.java
package com.sanix.leaderboards;

import com.sanix.leaderboards.command.SanixCommand;
import com.sanix.leaderboards.config.ConfigManager;
import com.sanix.leaderboards.config.Messages;
import com.sanix.leaderboards.data.TimeScope;
import com.sanix.leaderboards.format.FormatManager;
import com.sanix.leaderboards.format.InteractiveComponentBuilder;
import com.sanix.leaderboards.listener.PlayerJoinListener;
import com.sanix.leaderboards.listener.StatListener;
import com.sanix.leaderboards.manager.HologramManager;
import com.sanix.leaderboards.manager.LeaderboardManager;
import com.sanix.leaderboards.manager.ScopeManager;
import com.sanix.leaderboards.manager.StatManager;
import com.sanix.leaderboards.placeholder.SanixPlaceholders;
import com.sanix.leaderboards.storage.Database;
import com.sanix.leaderboards.storage.MySQLDatabase;
import com.sanix.leaderboards.storage.SQLiteDatabase;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

@Getter
public class SanixLB extends JavaPlugin {
    private Database database;
    private ConfigManager configManager;
    private Messages messages;
    private StatManager statManager;
    private LeaderboardManager leaderboardManager;
    private ScopeManager scopeManager;
    private HologramManager hologramManager;
    private FormatManager formatManager;
    private InteractiveComponentBuilder componentBuilder;
    
    private BukkitTask updateTask;
    private BukkitTask playtimeTask;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        this.messages = new Messages(this);
        
        String dbType = getConfig().getString("database.type", "SQLITE").toUpperCase();
        if (dbType.equals("MYSQL")) {
            this.database = new MySQLDatabase(this);
        } else {
            this.database = new SQLiteDatabase(this);
        }
        
        database.initialize();
        
        TimeScope defaultScope = TimeScope.fromString(getConfig().getString("leaderboard.default-scope", "ALLTIME"));
        if (defaultScope == null) {
            defaultScope = TimeScope.ALLTIME;
        }
        
        this.scopeManager = new ScopeManager(defaultScope);
        this.statManager = new StatManager(this);
        this.leaderboardManager = new LeaderboardManager(this);
        this.hologramManager = new HologramManager(this);
        this.formatManager = new FormatManager(this);
        this.componentBuilder = new InteractiveComponentBuilder(this);
        
        registerCommands();
        registerListeners();
        registerPlaceholders();
        startTasks();
        
        leaderboardManager.updateAll();
        
        getLogger().info("SanixLB has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (updateTask != null) {
            updateTask.cancel();
        }
        
        if (playtimeTask != null) {
            playtimeTask.cancel();
        }
        
        for (Player player : Bukkit.getOnlinePlayers()) {
            statManager.stopPlaytime(player);
        }
        
        if (database != null) {
            database.shutdown();
        }
        
        getLogger().info("SanixLB has been disabled!");
    }
    
    private void registerCommands() {
        SanixCommand commandExecutor = new SanixCommand(this);
        getCommand("slb").setExecutor(commandExecutor);
        getCommand("slb").setTabCompleter(commandExecutor);
    }
    
    private void registerListeners() {
        Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(this), this);
        Bukkit.getPluginManager().registerEvents(new StatListener(this), this);
    }
    
    private void registerPlaceholders() {
        if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
            new SanixPlaceholders(this).register();
            getLogger().info("PlaceholderAPI expansion registered!");
        }
    }
    
    private void startTasks() {
        int updateInterval = configManager.getUpdateInterval() * 20;
        
        this.updateTask = Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
            leaderboardManager.updateDirty();
            hologramManager.updateHolograms();
        }, updateInterval, updateInterval);
        
        int playtimeInterval = getConfig().getInt("stats.playtime.update-interval", 60) * 20;
        
        this.playtimeTask = Bukkit.getScheduler().runTaskTimer(this, () -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                statManager.updatePlaytime(player);
            }
        }, playtimeInterval, playtimeInterval);
    }
}