ghansis

I want a sidebar for my paper minecraft server that uses geyser to cross platform bedrock and java

Kodari AI
KodariMay 16 at 12:15 am 11,889 (v2)
CrossPlatformSidebar
A Paper plugin that provides a dynamic sidebar (scoreboard) for both Java and Bedrock (Geyser/Floodgate) players. Integrates with the TAB plugin API to display per-player scoreboards with configurable title, lines, and refresh interval. Detects Bedrock players via Floodgate and applies Bedrock-safe formatting. Fully configurable via config.yml with support for PlaceholderAPI placeholders in all lines.

Here’s my plan:

  • Use the TAB plugin API (ScoreboardManager) to create and show per-player scoreboards — this is the correct approach for a sidebar on Paper with TAB installed

  • Detect Bedrock players via Floodgate API (FloodgateApi.isFloodgatePlayer) and apply a separate configurable set of lines/title stripped of unsupported formatting

  • Register a PlayerLoadEvent (TAB’s own event) so the scoreboard is applied after TAB fully loads the player

  • Config-driven: title, lines, refresh interval, and separate bedrock overrides

The plugin is ready. Here’s a summary of how it works:

  • SidebarManager reads config.yml and creates two TAB Scoreboard objects — one for Java players, one for Bedrock players

  • Bedrock detection uses FloodgateApi.isFloodgatePlayer() wrapped in a try/catch so the plugin degrades gracefully if Floodgate isn’t present at runtime

  • PlayerLoadEvent (TAB’s own event, not Bukkit’s join event) ensures the scoreboard is applied only after TAB has fully loaded the player — this avoids the common race condition

  • TabLoadEvent re-applies scoreboards to all online players after a /tab reload, so API changes survive reloads

  • The bedrock.lines list falls back to java.lines if left empty in config, so you only need to define Bedrock lines if you want different content

ghansis

i need a lifesteal addon too

Kodari AI
KodariMay 16 at 12:20 am 21,648 (v2)

Let me read the existing project files first.

Good. Now let me plan the lifesteal system:

  • On player death by another player: killer gains +1 max heart (up to configurable max), victim loses -1 max heart (down to configurable min)

  • Elimination: when a player hits 0 hearts, they are banned (configurable: temp ban or permanent)

  • Heart items: players can craft/receive a heart item to restore lost hearts, configurable material and recipe

  • Persistence: store each player’s max health in a flat file (hearts.yml) so it survives restarts

  • Sidebar placeholders: expose %cps_hearts% via a custom PlaceholderAPI expansion so the sidebar can show lifesteal hearts

  • Wire everything into the existing main class and add config keys

Now I have everything I need. Here’s the plan:

  • LifestealManager — loads/saves per-player heart counts to hearts.yml, applies max health via Attribute, handles gain/loss/elimination logic

  • LifestealListener — listens to EntityDeathEvent (PvP kill) and PlayerInteractEvent (consuming a heart item)

  • LifestealCommand — /lifesteal give <player> [amount] and /lifesteal set <player> <amount> for admins

  • LifestealPlaceholderExpansion — registers %cps_hearts% with PlaceholderAPI

  • Wire into CrossPlatformSidebar.java and add lifesteal config section to config.yml

Now wire everything into the main class and update config/plugin.yml:

Now create the four lifesteal classes:

Now add PlaceholderAPI to build.gradle:

Now let me write the actual Java source files:

Here’s what was added:

Lifesteal System

Class
Role
LifestealManager
Loads/saves
hearts.yml
, applies
generic.max_health
via XAttribute, handles kill/death heart transfers, elimination banning, and heart item creation + recipe registration
LifestealListener
PlayerDeathEvent
for PvP kills,
PlayerJoinEvent
to restore health on login,
PlayerInteractEvent
to consume heart items
LifestealCommand
/lifesteal give/set/get/item <player> [amount]
— admin only
LifestealPlaceholderExpansion
Registers
%cps_hearts%
and
%cps_max_hearts%
for use in the sidebar lines

Config keys added (config.yml)

  • lifesteal.starting-hearts, max-hearts, min-hearts

  • lifesteal.hearts-per-kill, hearts-per-death

  • lifesteal.elimination-type (temp or permanent), temp-ban-duration

  • lifesteal.heart-item — material, name, lore, craftable, shaped recipe + ingredients

Use %cps_hearts% in your sidebar java.lines / bedrock.lines to display each player’s current heart count.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
9 705
src/main/java/com/crossplatformsidebar/CrossPlatformSidebar.java
package com.crossplatformsidebar;

import com.crossplatformsidebar.lifesteal.LifestealCommand;
import com.crossplatformsidebar.lifesteal.LifestealListener;
import com.crossplatformsidebar.lifesteal.LifestealManager;
import com.crossplatformsidebar.lifesteal.LifestealPlaceholderExpansion;
import com.crossplatformsidebar.sidebar.SidebarManager;
import me.neznamy.tab.api.TabAPI;
import me.neznamy.tab.api.event.player.PlayerLoadEvent;
import me.neznamy.tab.api.event.plugin.TabLoadEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class CrossPlatformSidebar extends JavaPlugin {

    private SidebarManager sidebarManager;
    private LifestealManager lifestealManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        this.sidebarManager = new SidebarManager(this);
        this.lifestealManager = new LifestealManager(this);

        getServer().getPluginManager().registerEvents(new LifestealListener(lifestealManager), this);

        LifestealCommand lifestealCmd = new LifestealCommand(lifestealManager);
        getCommand("lifesteal").setExecutor(lifestealCmd);
        getCommand("lifesteal").setTabCompleter(lifestealCmd);

        if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new LifestealPlaceholderExpansion(lifestealManager).register();
        }

        TabAPI.getInstance().getEventBus().register(PlayerLoadEvent.class, event -> {
            sidebarManager.applyToPlayer(event.getPlayer());
        });

        TabAPI.getInstance().getEventBus().register(TabLoadEvent.class, event -> {
            sidebarManager.reload();
            for (me.neznamy.tab.api.TabPlayer tp : TabAPI.getInstance().getOnlinePlayers()) {
                sidebarManager.applyToPlayer(tp);
            }
        });

        getLogger().info("CrossPlatformSidebar enabled.");
    }

    @Override
    public void onDisable() {
        if (sidebarManager != null) {
            sidebarManager.cleanup();
        }
    }

    public SidebarManager getSidebarManager() {
        return sidebarManager;
    }

    public LifestealManager getLifestealManager() {
        return lifestealManager;
    }
}