priyanshu_2010
📎 1 file 2,420 chars
📄
pasted-code-1790242017049.txt
txt 69 lines
▶
### Geyser & Floodgate Compatibility

The plugin MUST be fully compatible with **GeyserMC and Floodgate**, allowing both Java Edition and Bedrock Edition players to use the `/sell` system.

Requirements:

* `/sell` must work for both Java and Bedrock players.
* The 54-slot chest GUI must be usable through Geyser.
* The Green Stained Glass Pane in slot 53 must work as the Sell button for Bedrock players.
* Bedrock players must be able to:

  * Open the `/sell` GUI
  * Place items into the selling inventory
  * Remove items from the inventory
  * Click the Sell button
  * Receive their money correctly
  * Close the GUI without losing items
* Do NOT use Java-only client features that could break the GUI on Bedrock through Geyser.
* Use standard Minecraft inventory GUI components supported by Geyser.
* Do not require Bedrock players to install any client-side mod, resource pack, or addon.
* The plugin must work whether the player is:

  * Java Edition
  * Bedrock Edition through Geyser + Floodgate

### Floodgate Detection

If Floodgate is installed, detect Floodgate players safely using the Floodgate API.

Do not assume every player is a Java player.

The plugin should gracefully continue working if Floodgate is not installed, as long as Geyser is not required for basic Java functionality.

### Bedrock Safety

Pay special attention to inventory events because Bedrock players interact with inventories through Geyser differently from Java players.

The plugin must correctly handle:

* InventoryClickEvent
* InventoryDragEvent
* Shift-clicking
* Hotbar/number-key interactions
* Double-clicking
* Item dragging
* Closing the inventory
* Disconnecting while the sell GUI is open

Never duplicate or delete items because of Geyser/Floodgate inventory synchronization.

### Economy

The economy system must be identical for Java and Bedrock players.

For example:

10 Diamonds × $1,000 × 1.5 multiplier = $15,000

The same calculation must apply regardless of whether the player is using Java Edition or Bedrock Edition.

### Testing Requirement

Before considering the plugin complete, verify that the GUI works for:

1. Java player on Paper 1.21.11
2. Bedrock player connected through Geyser + Floodgate

The plugin should not require separate commands or separate GUI implementations for Bedrock players unless technically necessary.
Kodari AI
KodariSep 24 at 9:29 am 2
SellGUI
A cross-platform selling plugin for Paper 1.21.11 with full Geyser and Floodgate compatibility. Players use /sell to open a 54-slot chest GUI where they place items and click a Green Stained Glass Pane in slot 53 to sell. The plugin calculates item values with configurable multipliers, supports both Java and Bedrock players through standard inventory components, and safely handles all inventory events including clicks, drags, shift-clicks, and hotbar interactions without item duplication or loss. Economy integration works identically across both platforms.
  1. Create the Paper plugin setup, /sell command, and configurable Vault prices.

  2. Build the 54-slot GUI with protected sell button and safe item recovery for Java and Bedrock players.

  3. Detect Floodgate players optionally without making Floodgate a requirement.

Created KodariSell with /sell, a standard 54-slot inventory, a protected green stained glass sell button, configurable prices and multiplier, and Vault payouts shared by Java and Bedrock players. Items that aren’t sold are returned when the GUI closes or the player disconnects; Floodgate detection is optional and won’t prevent Java players from using the plugin.

The code is ready for server testing, but I haven’t verified it on live Paper 1.21.11 or Geyser/Floodgate servers.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 387
src/main/java/com/kodari/sell/SellPlugin.java
package com.kodari.sell;

import com.cryptomorin.xseries.XMaterial;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
import java.util.Map;

public final class SellPlugin extends JavaPlugin {
    private SellManager sellManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        RegisteredServiceProvider<Economy> registration = getServer().getServicesManager().getRegistration(Economy.class);
        if (registration == null || registration.getProvider() == null) {
            getLogger().severe("No Vault economy provider is available. Disabling KodariSell.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        Map<Material, Double> prices = loadPrices();
        double multiplier = getConfig().getDouble("multiplier", 1.5);
        if (!Double.isFinite(multiplier) || multiplier < 0) {
            getLogger().warning("Invalid multiplier; using 1.5.");
            multiplier = 1.5;
        }

        sellManager = new SellManager(this, registration.getProvider(), prices, multiplier);
        getServer().getPluginManager().registerEvents(sellManager, this);
        getCommand("sell").setExecutor(new SellCommand(this, sellManager, new FloodgateHook(this)));
    }

    @Override
    public void onDisable() {
        if (sellManager != null) {
            sellManager.shutdown();
        }
    }

    private Map<Material, Double> loadPrices() {
        Map<Material, Double> prices = new HashMap<>();
        ConfigurationSection section = getConfig().getConfigurationSection("prices");
        if (section == null) {
            getLogger().warning("No prices section is configured; items cannot be sold.");
            return prices;
        }

        for (String key : section.getKeys(false)) {
            XMaterial xMaterial = XMaterial.matchXMaterial(key).orElse(null);
            Material material = xMaterial == null ? null : xMaterial.parseMaterial();
            double price = section.getDouble(key, -1);
            if (material == null || !Double.isFinite(price) || price <= 0) {
                getLogger().warning("Ignoring invalid sell price entry: " + key);
                continue;
            }
            prices.put(material, price);
        }
        return prices;
    }
}