erik_segway1

create me a lightweight plugin that has only 1 command. that is /vote. when people do this command a [apasa-ma] is sent in the chat, when they click that they open this link https://minecraft-mp.com/server/358855/vote/, can you also create a command only for operators and admins that is /checkvote to see a leaderboard of all the players that clicked the [apasa-ma] with numbers indicating how many times they did it

Kodari AI
KodariJun 3 at 3:57 pm 6
SimpleVote
A lightweight voting plugin with two commands. /vote sends a clickable [apasa-ma] chat component that tracks clicks and redirects players to the server's voting page. /checkvote (operators/admins only) displays a leaderboard showing all players who clicked the vote link along with their click counts, sorted by most votes. Data persists across restarts.

Plan:

  1. VotePlugin — main class, wires everything shows sorted leaderboard

  2. plugin.yml + build.gradle

  3. VoteManager — stores click counts, persists to data.yml

  4. VoteCommand — /vote sends the clickable component

  5. VoteClickCommand — hidden /voteclick triggered by the click, increments count + sends URL

  6. CheckVoteCommand — /checkvote

Done. Here’s what was built:

  • /vote — sends §a§l[apasa-ma] in chat with a hover tooltip; clicking it silently runs /voteclick

  • /voteclick — increments the player’s count in data.yml, then sends them a second clickable link that opens the vote URL in their browser

  • /checkvote — op-only by default (configurable in plugin.yml), shows a top-10 leaderboard sorted by most clicks, with gold/silver/bronze coloring for top 3

  • Votes persist across restarts in plugins/SimpleVote/data.yml

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 265
src/main/java/com/kodari/simplevote/SimpleVote.java
package com.kodari.simplevote;

import com.kodari.simplevote.commands.CheckVoteCommand;
import com.kodari.simplevote.commands.VoteClickCommand;
import com.kodari.simplevote.commands.VoteCommand;
import org.bukkit.plugin.java.JavaPlugin;

public class SimpleVote extends JavaPlugin {

    private VoteManager voteManager;

    @Override
    public void onEnable() {
        voteManager = new VoteManager(this);

        getCommand("vote").setExecutor(new VoteCommand());
        getCommand("voteclick").setExecutor(new VoteClickCommand(voteManager));
        getCommand("checkvote").setExecutor(new CheckVoteCommand(voteManager));
    }

    @Override
    public void onDisable() {
        voteManager.save();
    }

    public VoteManager getVoteManager() {
        return voteManager;
    }
}