babi2503

Create a plugin that creates a counter of players who joined the server, it will be checked for the first time under the command /liczbagraczy

Kodari AI
KodariJan 13 at 8:31 pm 3,723 (v2)

I’ll create a player counter plugin that tracks unique players and displays the count with /liczbagraczy command.

PlayerCounter
A lightweight plugin that tracks the total number of unique players who have joined the server. Features a simple command to display the player count, persistent data storage using YAML files, and automatic tracking of new players through join events. Perfect for server statistics and monitoring player base growth.

Plugin created! Features:

  • Tracks unique players by UUID in data.yml

  • Command /liczbagraczy displays total count

  • Automatically saves when new players join

  • Polish language messages configurable in config.yml

  • Persistent storage across server restarts

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 208
src/main/java/com/playercounter/PlayerCounter.java
package com.playercounter;

import com.playercounter.commands.PlayerCountCommand;
import com.playercounter.listeners.JoinListener;
import com.playercounter.managers.DataManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class PlayerCounter extends JavaPlugin {
    
    private DataManager dataManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.dataManager = new DataManager(this);
        dataManager.load();
        
        getCommand("liczbagraczy").setExecutor(new PlayerCountCommand(this));
        getServer().getPluginManager().registerEvents(new JoinListener(this), this);
        
        getLogger().info("PlayerCounter został włączony!");
    }
    
    @Override
    public void onDisable() {
        if (dataManager != null) {
            dataManager.save();
        }
        getLogger().info("PlayerCounter został wyłączony!");
    }
}