Sharpness Og

Here is the full technical setup for your custom Minecraft scoreboard plugin, written completely in standalone Java so it requires zero external plugins or dependencies

Kodari AI
KodariOct 5 at 10:21 am 1
StandaloneScoreboard
StandaloneScoreboard is a self-contained Minecraft plugin that provides a comprehensive custom scoreboard system without requiring any external dependencies. It features a fully integrated GUI framework for interactive scoreboard management, allowing players to view and modify scores through an intuitive inventory-based interface. The plugin includes a robust event-driven architecture with a centralized GUIManager, button-based interaction system, and lazy initialization for optimal performance. Players can open the scoreboard GUI via command, navigate through clickable items, and manage scores seamlessly. The plugin handles all inventory events automatically, ensuring smooth operation across Bukkit, Spigot, and Paper servers. It offers a complete, standalone solution for server administrators seeking a feature-rich scoreboard experience with zero plugin dependencies.

I’ll create a standalone Bukkit sidebar scoreboard plugin with configurable title and lines, player/world/online placeholders, and automatic refresh.

Created a standalone scoreboard plugin with a configurable sidebar, automatic refresh, and {player}, {world}, {online}, and {max_players} placeholders. Adjust the title, refresh interval, and lines in config.yml.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
4 203
src/main/java/com/kodari/scoreboard/SimpleScoreboardPlugin.java
package com.kodari.scoreboard;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class SimpleScoreboardPlugin extends JavaPlugin implements Listener {
    private final Map<UUID, PlayerBoard> playerBoards = new HashMap<>();
    private BukkitTask refreshTask;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        Bukkit.getPluginManager().registerEvents(this, this);

        for (Player player : Bukkit.getOnlinePlayers()) {
            updateScoreboard(player);
        }

        long refreshTicks = Math.max(1L, getConfig().getLong("refresh-ticks", 20L));
        refreshTask = Bukkit.getScheduler().runTaskTimer(this, this::updateAllPlayers, refreshTicks, refreshTicks);
    }

    @Override
    public void onDisable() {
        if (refreshTask != null) {
            refreshTask.cancel();
        }

        for (Player player : Bukkit.getOnlinePlayers()) {
            player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
        }
        playerBoards.clear();
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        Bukkit.getScheduler().runTask(this, () -> updateScoreboard(event.getPlayer()));
    }

    @EventHandler
    public void onPlayerQuit(PlayerQuitEvent event) {
        playerBoards.remove(event.getPlayer().getUniqueId());
    }

    @EventHandler
    public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
        updateScoreboard(event.getPlayer());
    }

    private void updateAllPlayers() {
        for (Player player : Bukkit.getOnlinePlayers()) {
            updateScoreboard(player);
        }
    }

    private void updateScoreboard(Player player) {
        PlayerBoard playerBoard = playerBoards.get(player.getUniqueId());
        if (playerBoard == null) {
            playerBoard = createPlayerBoard();
            playerBoards.put(player.getUniqueId(), playerBoard);
            player.setScoreboard(playerBoard.scoreboard);
        }

        playerBoard.objective.setDisplayName(limitText(colorize(getConfig().getString("title", "&6&lMy Server")), 32));

        List<String> lines = getConfig().getStringList("lines");
        int lineCount = Math.min(lines.size(), playerBoard.teams.size());
        for (int i = 0; i < lineCount; i++) {
            String line = formatLine(player, lines.get(i));
            String[] parts = splitLine(line);
            Team team = playerBoard.teams.get(i);
            team.setPrefix(parts[0]);
            team.setSuffix(parts[1]);
        }
    }

    private PlayerBoard createPlayerBoard() {
        Scoreboard scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
        Objective objective = scoreboard.registerNewObjective("sidebar", "dummy");
        objective.setDisplaySlot(DisplaySlot.SIDEBAR);

        List<String> lines = getConfig().getStringList("lines");
        int lineCount = Math.min(lines.size(), 15);
        List<Team> teams = new ArrayList<>();
        ChatColor[] colors = ChatColor.values();

        for (int i = 0; i < lineCount; i++) {
            String teamName = "line" + i;
            String entry = colors[i].toString();
            Team team = scoreboard.registerNewTeam(teamName);
            team.addEntry(entry);
            objective.getScore(entry).setScore(lineCount - i);
            teams.add(team);
        }

        return new PlayerBoard(scoreboard, objective, teams);
    }

    private String formatLine(Player player, String line) {
        String formatted = line
                .replace("{player}", player.getName())
                .replace("{world}", player.getWorld().getName())
                .replace("{online}", String.valueOf(Bukkit.getOnlinePlayers().size()))
                .replace("{max_players}", String.valueOf(Bukkit.getMaxPlayers()));
        return colorize(formatted);
    }

    private String colorize(String text) {
        return ChatColor.translateAlternateColorCodes('&', text);
    }

    private String[] splitLine(String line) {
        int prefixLength = Math.min(16, line.length());
        if (prefixLength < line.length() && prefixLength > 0 && line.charAt(prefixLength - 1) == ChatColor.COLOR_CHAR) {
            prefixLength--;
        }

        String prefix = line.substring(0, prefixLength);
        String suffix = ChatColor.getLastColors(prefix) + line.substring(prefixLength);
        if (suffix.length() > 16) {
            suffix = suffix.substring(0, 16);
            if (suffix.charAt(suffix.length() - 1) == ChatColor.COLOR_CHAR) {
                suffix = suffix.substring(0, suffix.length() - 1);
            }
        }
        return new String[]{prefix, suffix};
    }

    private String limitText(String text, int maxLength) {
        if (text.length() <= maxLength) {
            return text;
        }
        String limited = text.substring(0, maxLength);
        if (limited.charAt(limited.length() - 1) == ChatColor.COLOR_CHAR) {
            limited = limited.substring(0, limited.length() - 1);
        }
        return limited;
    }

    private static class PlayerBoard {
        private final Scoreboard scoreboard;
        private final Objective objective;
        private final List<Team> teams;

        private PlayerBoard(Scoreboard scoreboard, Objective objective, List<Team> teams) {
            this.scoreboard = scoreboard;
            this.objective = objective;
            this.teams = teams;
        }
    }
}