abubakarmughal9155
📎 1 file 2,101 chars
📄
pasted-code-1777213770340.txt
txt 72 lines
▶
Create a complete Minecraft Paper plugin (Java 17, API 1.20+) named "ZGPlayzBridge".

Purpose:
This plugin connects a Minecraft server with a web store and automatically delivers purchases (ranks, crate keys, coins) to players when they are online.

Requirements:

1. Core Functionality:
- Every 30 seconds (async task), send a POST request to:
  https://your-site/api/public/pending-deliveries
- Include header: X-ZG-Secret (from config)
- Send JSON body: { "players": ["onlinePlayer1", "onlinePlayer2"] }

- Receive JSON response like:
{
  "deliveries": [
    { "id": "uuid", "ign": "Steve", "type": "rank", "item": "king" },
    { "id": "uuid2", "ign": "Alex", "type": "coin", "amount": 1000 }
  ]
}

- For each delivery:
  - Run a command from config.yml (replace {player} and {amount})
  - Execute command from console (on main thread)
  - After success, send POST to:
    /api/public/confirm-delivery with delivery id

2. Supported Types:
- rank → uses config command: ranks.
- key → uses config command: keys.
- coin → uses config command: coins.command

3. Config.yml:
Include:
- api base-url
- secret-key
- poll interval
- commands for ranks, keys, and coins (with placeholders)

4. Commands:
/zg reload → reload config
/zg check  → manually check deliveries for player
/zg deliver    → test delivery

5. Events:
- On PlayerJoinEvent → instantly check deliveries for that player

6. Structure:
- Main class
- ApiClient (handles HTTP + JSON using Gson)
- DeliveryTask (polling system)
- Handlers: RankHandler, KeyHandler, CoinHandler
- Command class

7. Dependencies:
- Paper API
- Gson
- (Optional soft-depend): LuckPerms, Vault

8. Best Practices:
- Run HTTP async (never block main thread)
- Run commands on main thread
- Handle API errors safely
- Log all deliveries (success/failure)

9. Output:
- Full working code for all classes
- plugin.yml
- config.yml
- Clear instructions to build with Gradle

Do NOT skip any part. Generate complete, clean, production-ready code.
Kodari AI
KodariApr 26 at 2:31 pm 11,151 (v2)

I’ll create a complete web store bridge plugin that polls an API for pending deliveries and executes them automatically.

ZGPlayzBridge
A Paper plugin that seamlessly connects your Minecraft server with a web store backend. Automatically polls for pending purchases and delivers ranks, crate keys, and coins to online players. Features async API communication, configurable commands, manual delivery testing, and instant delivery checks when players join. Includes comprehensive error handling and delivery confirmation system.
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
Code
12 976
src/main/java/com/zgplayz/bridge/ZGPlayzBridge.java
package com.zgplayz.bridge;

import com.zgplayz.bridge.api.ApiClient;
import com.zgplayz.bridge.command.ZGCommand;
import com.zgplayz.bridge.delivery.DeliveryHandler;
import com.zgplayz.bridge.delivery.DeliveryTask;
import com.zgplayz.bridge.listener.JoinListener;
import org.bukkit.plugin.java.JavaPlugin;

public class ZGPlayzBridge extends JavaPlugin {
    
    private ApiClient apiClient;
    private DeliveryHandler deliveryHandler;
    private DeliveryTask deliveryTask;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.apiClient = new ApiClient(this);
        this.deliveryHandler = new DeliveryHandler(this);
        
        this.deliveryTask = new DeliveryTask(this, apiClient, deliveryHandler);
        this.deliveryTask.start();
        
        getCommand("zg").setExecutor(new ZGCommand(this));
        
        getServer().getPluginManager().registerEvents(new JoinListener(this), this);
        
        getLogger().info("ZGPlayz Bridge enabled successfully!");
    }
    
    @Override
    public void onDisable() {
        if (deliveryTask != null) {
            deliveryTask.stop();
        }
        getLogger().info("ZGPlayz Bridge disabled!");
    }
    
    public void reload() {
        reloadConfig();
        
        if (deliveryTask != null) {
            deliveryTask.stop();
        }
        
        this.apiClient = new ApiClient(this);
        this.deliveryHandler = new DeliveryHandler(this);
        
        this.deliveryTask = new DeliveryTask(this, apiClient, deliveryHandler);
        this.deliveryTask.start();
    }
    
    public ApiClient getApiClient() {
        return apiClient;
    }
    
    public DeliveryHandler getDeliveryHandler() {
        return deliveryHandler;
    }
}