rufaidabeautiful
📎 1 file 3,839 chars
📄
pasted-code-1781797114485.txt
txt 199 lines
▶
‎# Frenzy Points (Paper Plugin)
‎
‎Create a professional Minecraft Paper plugin named **Frenzy Points**.
‎
‎## Compatibility
‎
‎* Platform: PaperMC
‎* Java Version: Java 21
‎* Minecraft Version: 1.21+
‎* Plugin Name: Frenzy Points
‎
‎## Main Features
‎
‎### 1. Frenzy Points System
‎
‎* Every player has a virtual currency called **Frenzy Points**.
‎* When a player joins the server for the first time, they automatically receive **20 Frenzy Points**.
‎* Points must be saved permanently in a database (SQLite by default).
‎* Points should persist after server restarts.
‎
‎### 2. Player Kill Rewards
‎
‎* When Player A kills Player B:
‎
‎  * 5 Frenzy Points are automatically removed from Player B.
‎  * 5 Frenzy Points are automatically added to Player A.
‎* If Player B has less than 5 points:
‎
‎  * Transfer only the amount they currently have.
‎* Show actionbar and chat messages:
‎
‎  * Killer: "+5 Frenzy Points"
‎  * Victim: "-5 Frenzy Points"
‎
‎### 3. Task System
‎
‎Operators can create and assign custom tasks.
‎
‎Example:
‎
‎* /frenzytask give   
‎
‎Example:
‎
‎* /frenzytask give Steve 50 Mine 100 Diamonds
‎
‎This assigns a task:
‎"Mine 100 Diamonds"
‎Reward:
‎50 Frenzy Points
‎
‎### 4. Task Completion
‎
‎Operators can manually complete tasks.
‎
‎Command:
‎
‎* /frenzytask complete 
‎
‎When completed:
‎
‎* Task reward points are automatically added.
‎* Player receives a title and chat notification.
‎* Task is removed from active tasks.
‎
‎### 5. Points Management Commands
‎
‎Admin Commands:
‎
‎* /frenzypoints add  
‎* /frenzypoints remove  
‎* /frenzypoints set  
‎* /frenzypoints reset 
‎* /frenzypoints check 
‎
‎Player Commands:
‎
‎* /points
‎* /frenzypoints balance
‎* /frenzypoints top
‎
‎### 6. Task Commands
‎
‎Admin:
‎
‎* /frenzytask give   
‎* /frenzytask complete 
‎* /frenzytask remove 
‎* /frenzytask list
‎* /frenzytask reload
‎
‎Player:
‎
‎* /task
‎* /tasks
‎
‎### 7. INVENTORY GUI System
‎
‎Create a clean INVENTORY GUI.
‎
‎Main Menu:
‎
‎* My Points
‎* Active Task
‎* Top Players
‎* Statistics
‎
‎Commands:
‎
‎* /points INVENTORY GUI
‎* /frenzypoints INVENTORY GUI
‎
‎### 8. Leaderboard
‎
‎Command:
‎
‎* /frenzypoints top
‎
‎Shows:
‎#1 Player - 5000 FP
‎#2 Player - 4200 FP
‎#3 Player - 3900 FP
‎
‎### 9. Permissions
‎
‎Admin Permissions:
‎
‎* frenzy.admin
‎* frenzy.points.admin
‎* frenzy.task.admin
‎
‎Default Player Permissions:
‎
‎* frenzy.points.use
‎
‎Only OPs or players with admin permissions can modify points or tasks.
‎
‎### 10. Configuration
‎
‎config.yml options:
‎
‎* Join bonus amount
‎* Kill reward amount
‎* Messages
‎* Sounds
‎* Titles
‎* Database settings
‎
‎Example:
‎
‎join-bonus: 20
‎kill-transfer: 5
‎
‎### 11. PlaceholderAPI Support
‎
‎Placeholders:
‎
‎* %frenzy_points%
‎* %frenzy_rank%
‎* %frenzy_task%
‎* %frenzy_task_reward%
‎
‎### 12. Performance Requirements
‎
‎* Optimized for large servers.
‎* Async database operations.
‎* Clean OOP structure.
‎* No memory leaks.
‎* Proper error handling.
‎* Tab Completion support.
‎* Hex color support.
‎* Reload-safe.
‎
‎### 13. Plugin Messages
‎
‎Examples:
‎
‎"&aYou received &e20 Frenzy Points!"
‎"&cYou lost &e5 Frenzy Points!"
‎"&6Task Completed!"
‎"&aYou earned &e50 Frenzy Points!"
‎
‎### 14. Files
‎
‎Generate:
‎
‎* plugin.yml
‎* config.yml
‎* messages.yml
‎* SQLite database handler
‎* Commands
‎* Events
‎* INVENTORY GUI classes
‎* Task Manager
‎* Points Manager
‎* PlaceholderAPI expansion
‎
‎Provide complete source code with proper package structure and comments.
‎
Kodari AI
KodariJun 18 at 3:50 pm 65
FrenzyPoints
A feature-rich Paper plugin providing a virtual currency system called Frenzy Points. Players earn points on first join, gain/lose points through PvP kills, and complete admin-assigned tasks for rewards. Includes an inventory GUI with leaderboard, async SQLite storage, full admin commands for points and task management, PlaceholderAPI support, and configurable sounds, messages, and titles.

Here’s a summary of what was built:

25 files, fully wired together:

Layer
Files
Core
FrenzyPoints.java
— bootstraps everything, reload-safe
Database
DatabaseManager
— async SQLite with sync fallback for shutdown
Managers
PointsManager
(in-memory cache + async DB),
TaskManager
(task lifecycle + title/sound on complete)
Models
FrenzyTask
,
PlayerData
— Lombok
@Getter @AllArgsConstructor
Listeners
PlayerListener
— first-join bonus, PvP kill transfer with actionbar + chat
Commands
PointsCommand
(
/frenzypoints
+
/points
),
TaskCommand
(
/frenzytask
+
/task
) — both implement
TabCompleter
GUI
Full framework (
InventoryHandler
,
InventoryButton
,
InventoryGUI
,
GUIManager
,
GUIListener
) +
MainMenuGUI
(27-slot, 4 buttons) +
TopPlayersGUI
(54-slot, skull heads, back button)
Placeholders
FrenzyExpansion
—
%frenzy_points%
,
%frenzy_rank%
,
%frenzy_task%
,
%frenzy_task_reward%
Util
ColorUtil
— hex
&#RRGGBB
+
&
code → Adventure
Component
Config
ConfigManager
,
MessageManager
— hot-reload via
/frenzytask reload
rufaidabeautiful

Display every player's points above their nametag in the format: FP (Points)

When a player receives a task, play a satisfying notification sound and automatically give them a book. The book title should be the task name, and the book content should contain a short description of the assigned task.

Kodari AI
KodariJun 18 at 4:11 pm 43

Now I have full context. Here’s the plan:

  1. Create NameTagManager — spawns a transparent TextDisplay as a passenger on each player, showing FP (N) above their head; updates whenever points change

  2. Wire it into FrenzyPoints, PointsManager, and PlayerListener (join/quit/world change)

  3. Play task-assigned sound + give a written book in TaskCommand.give

  4. Add task-assigned sound key to ConfigManager and config.yml


Now I need to fix the catch block that was consumed by the previous patch:

Now create the NameTagManager:

Here’s a summary of every change made:

New file — NameTagManager

  • On player join, spawns a TextDisplay entity as a passenger of the player. Being a passenger, it renders ~0.35 blocks above the head collision box — sitting visibly above the normal nametag.

  • Billboard CENTER: always faces the viewer regardless of angle.

  • Transparent background, no shadow, scale 0.65 to match nametag proportions.

  • updateIfOnline(uuid, points) schedules to the main thread (called from setPoints which can be async).

  • clearAll() called on plugin disable to ensure no orphan entities persist.

PointsManager.setPoints — calls nameTagManager.updateIfOnline() after every point change (covers addPoints, removePoints, and setPoints).

PlayerListener

  • After player data loads on join, calls setupPlayer with their current point total.

  • onQuit removes the display entity before unloading cache.

  • New PlayerChangedWorldEvent handler re-spawns the display in the new world (passengers don’t survive world transfers).

TaskCommand.give

  • Plays sounds.task-assigned (BLOCK_NOTE_BLOCK_CHIME by default) to the target player immediately after task assignment.

  • Crafts a WRITTEN_BOOK with the task description as the title, a structured Adventure component page containing task details, reward amount, and assigner name, then gives it to the player (drops at feet if inventory is full).

ConfigManager — new getTaskAssignedSound() method.
config.yml — new sounds.task-assigned: BLOCK_NOTE_BLOCK_CHIME entry.

rufaidabeautiful

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

rufaidabeautiful

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

rufaidabeautiful

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

Task Reward

For the visible text:

Task text should be black. Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

rufaidabeautiful

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

rufaidabeautiful

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Make the points text larger, bold, and clearly visible from a distance. The points should update automatically whenever the player's points change. Keep the player's name in white and the points in red.

itsfrenzyplayz

Why is the book text appearing like this? Please make all book text normal black color.

Remove the "Assigned By" section completely. The book should only contain:

* Task * Reward

For the visible text:

* Task text should be black. * Reward text should be yellow.

Also, change the book name to "Task Book" for every book. Do not use a normal book. Make it a special custom book named Task Book.

Do not show "Signed By" anywhere. The book should only display the title Task Book with a special custom style and text. No other changes are needed.

PLAYER_NAME (Points) POINTS

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
26 1,812
src/main/java/com/frenzy/points/FrenzyPoints.java
package com.frenzy.points;

import com.frenzy.points.command.PointsCommand;
import com.frenzy.points.command.TaskCommand;
import com.frenzy.points.config.ConfigManager;
import com.frenzy.points.config.MessageManager;
import com.frenzy.points.database.DatabaseManager;
import com.frenzy.points.inventory.gui.GUIListener;
import com.frenzy.points.inventory.gui.GUIManager;
import com.frenzy.points.listener.PlayerListener;
import com.frenzy.points.manager.NameTagManager;
import com.frenzy.points.manager.PointsManager;
import com.frenzy.points.manager.TaskManager;
import com.frenzy.points.placeholder.FrenzyExpansion;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.sql.SQLException;

@Getter
public class FrenzyPoints extends JavaPlugin {

    private DatabaseManager databaseManager;
    private PointsManager pointsManager;
    private TaskManager taskManager;
    private GUIManager guiManager;
    private ConfigManager configManager;
    private MessageManager messageManager;
    private NameTagManager nameTagManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResource("messages.yml", false);

        configManager = new ConfigManager(this);
        messageManager = new MessageManager(this);

        databaseManager = new DatabaseManager(this);
        try {
            databaseManager.init();
        } catch (SQLException e) {
            getLogger().severe("Failed to initialize database: " + e.getMessage());
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }

        pointsManager = new PointsManager(this);
        taskManager = new TaskManager(this);
        guiManager = new GUIManager();
        nameTagManager = new NameTagManager(this);

        // Load any players already online (reload scenario)
        Bukkit.getOnlinePlayers().forEach(player -> {
            pointsManager.loadPlayer(player.getUniqueId(), player.getName());
            taskManager.loadTask(player.getUniqueId());
        });

        Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
        Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);

        PointsCommand pointsCommand = new PointsCommand(this);
        TaskCommand taskCommand = new TaskCommand(this);

        getCommand("frenzypoints").setExecutor(pointsCommand);
        getCommand("frenzypoints").setTabCompleter(pointsCommand);
        getCommand("frenzytask").setExecutor(taskCommand);
        getCommand("frenzytask").setTabCompleter(taskCommand);

        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new FrenzyExpansion(this).register();
            getLogger().info("Hooked into PlaceholderAPI.");
        }

        getLogger().info("FrenzyPoints v" + getDescription().getVersion() + " enabled!");
    }

    @Override
    public void onDisable() {
        if (pointsManager != null) pointsManager.saveAll();
        if (taskManager != null) taskManager.saveAll();
        if (nameTagManager != null) nameTagManager.clearAll();
        if (databaseManager != null) databaseManager.close();
        getLogger().info("FrenzyPoints disabled.");
    }
}