ignix.mc

Make this plugin a reality.

📎 1 file 4,225 chars
📄
pasted-code-1776505602205.txt
txt 39 lines
▶
**Project Overview: GrantX Replica**
Hey Dev, we need to build an exact, 1:1 replica of the **GrantX** plugin. This is an absolutely amazing, revolutionary permission management tool. It takes the tedious, error-prone process of assigning ranks and turns it into a flawless, stunning INVENTORY GUI experience. 

It needs to be heavily optimized, insanely configurable, and extremely user-friendly. Below is the highly detailed yet simplified specification sheet you need to recreate it perfectly.

---

### 1. The Core Mechanism: The Grant Procedure (`/grant`)
The bread and butter of this plugin is the `/grant` command. When a staff member runs `/grant `, it must trigger a beautifully designed, multi-step INVENTORY GUI sequence:
* **Select a Rank:** A menu opens displaying available ranks or permission nodes (represented by custom blocks/items).
* **Select a Duration:** The user picks a pre-configured time limit (e.g., 30 Days, 1 Hour, Lifetime). 
* **Select a Reason:** The user picks from pre-set reasons (e.g., "Store Purchase", "Staff Promotion", "Giveaway Winner").
* **Confirmation:** A final INVENTORY GUI appears displaying all the selected parameters, asking the user to confirm to prevent accidental grants.

### 2. The Log System: Grant History & Revocation
Every single action must be recorded.
* **Database & Storage:** The plugin must support local data file storage (YAML/JSON) AND remote database storage (MySQL) for the server.
* **Logs Menu (`/grants` or `/grantx logs`):** A INVENTORY GUI where staff can view a specific player's active, expired, and revoked grants, or view the most recent grants server-wide.
* **In-INVENTORY GUI Revocation:** Active grants can be clicked and revoked right from the menu (with a confirmation screen).
* **Hierarchical Security:** You must implement a weight/permission system for revoking. A Moderator should never be able to revoke an Admin's grant.

### 3. The In-Game Editor (The Game Changer)
Server owners shouldn't have to touch a single configuration file if they don't want to. 
* **Full INVENTORY GUI Editor:** Admins can type an editor command to create, delete, and modify everything.
* **Editable Elements:** They must be able to edit ranks, servers, durations, and reasons purely through in-game clicks.
* **Deep Tweaking:** Inside the editor, they should be able to change an item's display name, the lore, the INVENTORY GUI material (e.g., Diamond Block vs. Wool), the priority/weight of the rank, and the exact permission required to grant it.

### 4. Insane Customizability (The "Amazing" Factor)
GrantX is famous for being adaptable to any server theme. Your replica must be just as amazing:
* **Complete Menu Control:** Every single INVENTORY GUI menu must have a clean, heavily documented configuration file (`menus.yml`, `settings.yml`, `messages.yml`, `ranks.yml`). Server owners must be able to change slot placements, glass pane colors, and titles.
* **Plug-and-Play Defaults:** Even though it’s 100% customizable, the plugin MUST ship "99% pre-configured" with a stunning, optimal default layout so novice owners don't have to build menus from scratch.
* **Custom Messages:** Every chat message, error, and broadcast needs to be editable. 

### 5. Backend Requirements & Integrations
* **Permission Hooks:** It must integrate flawlessly with any Vault-supported permissions plugin (LuckPerms, PermissionsEx, GroupManager). Create permissions for every command and hierarchial permissions.
* **Command Executions:** When a grant is finalized, the plugin needs to run console commands to actually give the rank, and allow for custom actions like broadcasting a global message.
* **Version Compatibility:** Code it to support a wide range of Minecraft versions, ideally 1.8 through the latest 1.21+.

**Developer Mission:** Make the menus feel snappy and intuitive. The ultimate goal is to make a permission management system so visual, safe, and visually appealing that a server owner will never want to type an ugly `/lp user parent set` command ever again. Replicate this exactly! Make sure to keep everything to the messages in files just liked mentioned so that anything can be configured.
Kodari AI
KodariApr 18 at 9:57 am 64,961 (v2)
GrantX
A feature-complete GrantX replica — a revolutionary GUI-driven permission management plugin. Staff complete a multi-step inventory GUI flow (select rank → duration → reason → confirm) to issue timed or permanent grants. Includes a full grant history viewer with in-GUI revocation, hierarchical weight-based security, a complete in-game editor for ranks/durations/reasons, YAML and MySQL storage, Vault integration, and 100% configurable menus, messages, and layouts.
  • Full 4-step grant GUI flow → logs viewer with revocation → complete in-game editor

  • Hierarchical weight security, Vault hooks, MySQL/YAML dual storage, expiry task

  • Every message, title, material, slot, and layout driven from config files with beautiful defaults

All 44 files have been created. Here’s a summary of what was built:

Grant Flow (4-step GUI): /grant <player> → SelectRankGUI → SelectDurationGUI → SelectReasonGUI → ConfirmGrantGUI — each step passes a GrantContext object carrying selections forward, with back buttons and a cancel option throughout.

Grant Logs & Revocation: /grants <player|recent> opens a paginated 28-grants-per-page GrantLogsGUI with color-coded active/expired/revoked entries. Clicking an active grant opens RevokeConfirmGUI — guarded by hierarchical weight checking so lower-weight staff can never revoke higher-weight grants.

In-Game Editor: /grantx editor opens EditorMainGUI → rank/duration/reason list GUIs → per-entry edit screens. All fields (name, lore, material, weight, permissions, commands) are editable purely through chat-input prompts captured by ChatInputListener, with changes persisting immediately to ranks.yml / config.yml.

Storage & Backend: DatabaseManager auto-selects YAML (data/grants.yml) or MySQL (HikariCP pool) from config. GrantExpiryTask runs every configurable interval to automatically expire and run revoke-commands for time-limited grants. VaultManager hooks into any Vault-compatible permissions plugin for .hasPermission() calls.

Configuration: Every GUI title, size, material, slot, lore line, and message is backed by menus.yml, messages.yml, config.yml, and ranks.yml — shipped with a complete, beautiful default layout requiring zero setup.

ignix.mc
  • I have noticed that it doesnt follow the correct timings at all. so make sure the timing problem is fixed
  • Make a message for the target player when he recieves a rank
  • And make sure no other message are shown publicly except for notifying ops that a player has given a rank.
ignix.mc

-I have noticed that it doesnt follow the correct timings at all. so make sure the timing problem is fixed. you can also go ahead add more timings like 30s, 1m and so on (make theme however still aesthetically pleasing) -Make a message for the target player when he recieves a rank. Make a message for notifying ops that a player has given a rank. -And make sure no other messages are shown publicly. -Add a discord webhook feature with its own yml file. I can connect a discord webhook and it will send a log whenever the plugin does any action, for example: if i grant a player a rank, or revoke a rank, etc..... but make sure this message states in points the target player, the player giving the rank, rank of player that is giving rank, and rank that is being given, time of said process, and more you think is stuitable.

Kodari AI
KodariApr 19 at 12:25 pm 24,766 (v2)

Now I have a full picture. Here’s my plan:

  • Fix timings: Expand durations in config.yml with proper millis (30s, 1m, 5m, 10m, 15m, 2h, 6h, 12h, 3d, 14d, 60d) and reduce expiry-check-interval; add getHighestRank() to RankManager for webhook/notify context

  • Player/Op notifications: Add grant-received-player, grant-notify-ops, revoke-received-player, revoke-notify-ops to messages.yml; wire them up in GrantManager; remove public broadcast

  • Discord Webhook: Create webhook.yml, WebhookManager, register it in GrantX, and call it from GrantManager on every action

Here’s a summary of everything changed:

  • config.yml: Removed the public broadcast settings, lowered expiry check interval to 10s, and expanded durations to 16 entries (30s → Lifetime) with correct millis values and distinct, aesthetically matching materials

  • messages.yml: Added 6 new message keys — target receives a personal message on grant/revoke/expire; staff with grantx.notify permission receive a private notification; no public broadcasts remain

  • GrantManager.java: Replaced Bukkit.broadcastMessage() with targeted messages (online target player + permission-gated staff notify), wired up webhook calls on grant, revoke, and expire; also backfills revoke fields on the Grant object for accurate webhook payloads

  • RankManager.java: Added getHighestRankDisplay(Player) to resolve a player’s highest rank by weight for use in webhook/notify context

  • WebhookManager.java: New class that reads webhook.yml, builds rich Discord embeds with all relevant fields (target, granter, granter’s rank, rank given, duration, reason, timestamps, grant ID), and posts them asynchronously to the configured webhook URL

  • webhook.yml: New config file with enable toggle, URL, and per-action (grant/revoke/expire) color, title, and footer settings

  • ConfigManager.java: Removed now-unused isBroadcastGrants() and getBroadcastFormat() methods

ignix.mc

do this

📎 1 file 545 chars
📄
pasted-code-1777022822087.txt
txt 30 lines
▶


# 🧩 Problem Overview

## ✅ What works

* Grant creation works
* Duration/timer system works
* Expiry detection works (`GrantExpiryTask`)
* Expiry logs correctly show grant ended

## ❌ What fails

* Rank is **NOT reverted after expiry**
* Player keeps the granted rank (or ends up in invalid state)

---

# 🔍 Root Cause

### 1. No state preservation

The system **does not store the player’s previous rank** when a grant is applied.

### 2. Incorrect expiry behavior

On expiry:

```java
rank.getRevokeCommands()
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
46 4,093
src/main/java/com/grantx/GrantX.java
package com.grantx;

import com.grantx.command.GrantCommand;
import com.grantx.command.GrantXCommand;
import com.grantx.command.GrantsCommand;
import com.grantx.inventory.gui.GUIListener;
import com.grantx.inventory.gui.GUIManager;
import com.grantx.listener.ChatInputListener;
import com.grantx.manager.ConfigManager;
import com.grantx.manager.DatabaseManager;
import com.grantx.manager.GrantManager;
import com.grantx.manager.RankManager;
import com.grantx.manager.VaultManager;
import com.grantx.manager.WebhookManager;
import com.grantx.task.GrantExpiryTask;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;

public class GrantX extends JavaPlugin {

    @Getter private static GrantX instance;

    @Getter private ConfigManager configManager;
    @Getter private RankManager rankManager;
    @Getter private DatabaseManager databaseManager;
    @Getter private GrantManager grantManager;
    @Getter private VaultManager vaultManager;
    @Getter private GUIManager guiManager;
    @Getter private WebhookManager webhookManager;

    private final Map<UUID, Consumer<String>> pendingInputs = new HashMap<>();

    @Override
    public void onEnable() {
        instance = this;

        saveDefaultConfig();

        configManager = new ConfigManager(this);
        configManager.load();

        rankManager = new RankManager(this);
        rankManager.load();

        databaseManager = new DatabaseManager(this);
        databaseManager.init();

        vaultManager = new VaultManager(this);
        vaultManager.setup();

        grantManager = new GrantManager(this);

        webhookManager = new WebhookManager(this);
        webhookManager.load();

        guiManager = new GUIManager();

        GUIListener guiListener = new GUIListener(guiManager);
        Bukkit.getPluginManager().registerEvents(guiListener, this);
        Bukkit.getPluginManager().registerEvents(new ChatInputListener(this), this);

        getCommand("grant").setExecutor(new GrantCommand(this));
        getCommand("grants").setExecutor(new GrantsCommand(this));
        getCommand("grantx").setExecutor(new GrantXCommand(this));

        long interval = configManager.getSettings().getLong("settings.expiry-check-interval", 60L) * 20L;
        Bukkit.getScheduler().runTaskTimerAsynchronously(this, new GrantExpiryTask(this), interval, interval);

        getLogger().info("GrantX has been enabled.");
    }

    @Override
    public void onDisable() {
        if (databaseManager != null) {
            databaseManager.close();
        }
        getLogger().info("GrantX has been disabled.");
    }

    public void setPendingInput(UUID uuid, Consumer<String> consumer) {
        pendingInputs.put(uuid, consumer);
    }

    public Consumer<String> getPendingInput(UUID uuid) {
        return pendingInputs.get(uuid);
    }

    public void removePendingInput(UUID uuid) {
        pendingInputs.remove(uuid);
    }
}