rkboss95yt
๐Ÿ“Ž 1 file 17,758 chars
๐Ÿ“„
pasted-code-1788062347882.txt
txt 1160 lines
โ–ถ
# BOSS SHOP โ€” FINAL COMPLETE UPDATE REQUIREMENTS + CRITICAL FIXES

Modify the EXISTING BossShop plugin according to ALL requirements below.

Do NOT create a completely unrelated plugin.

Keep the existing plugin name:

BossShop

The plugin must remain lightweight, safe, optimized and production-ready.

---

# IMPORTANT COMMAND REQUIREMENT

Player commands must be exactly:

/shop
/sell

Admin command:

/bshop

There must be NO:

/sellgui

The /sell command itself must directly open the Sell GUI.

Do not register /sellgui as a command or alias.

---

# ADMIN PERMISSIONS

The /bshop command and all subcommands are ADMIN ONLY.

Main permission:

bossshop.admin

Normal players must not be able to use /bshop.

Support individual permissions:

bossshop.admin.help
bossshop.admin.reload
bossshop.admin.addsection
bossshop.admin.deletesection
bossshop.admin.additem
bossshop.admin.addsellitem
bossshop.admin.deleteitem

Players without permission must receive:

&cYou do not have permission to use this command.

---

# MAIN /shop GUI โ€” VERY IMPORTANT

The main /shop GUI must contain exactly:

3 rows
27 slots

The inventory size must always be:

27

Bukkit slot layout:

Row 1: 0 1 2 3 4 5 6 7 8
Row 2: 9 10 11 12 13 14 15 16 17
Row 3: 18 19 20 21 22 23 24 25 26

The exact center slot is:

Slot 13

---

# MAIN SHOP GUI BACKGROUND

Every unused slot must contain:

BLACK_STAINED_GLASS_PANE

The black glass pane must:

- Have no visible name or use " ".
- Not be movable.
- Not be removable.
- Not support shift-click.
- Not support drag.
- Not support number-key movement.
- Only act as a background.

---

# CENTERED SECTION PLACEMENT โ€” VERY IMPORTANT

Currently section icons are being placed starting from the top-left corner.

THIS MUST BE FIXED.

When there is only ONE section, the section icon must always be placed at:

Slot 13

Example:

/bshop addsection gear DIAMOND_CHESTPLATE &a 8

The Gear icon must appear in the exact center of the 3-row /shop GUI.

It must NOT appear in slot 0.

---

# MULTIPLE SECTION CENTERED PLACEMENT

When multiple sections exist, automatically place them around the center.

Use this placement priority:

13
12
14
11
15
10
16
9
17

Then continue with:

4
22
3
5
21
23
2
6
20
24
1
7
19
25
0
8
18
26

This ensures sections remain visually centered.

Do not always start section placement from slot 0.

---

# SECTION CREATION COMMAND

The exact command must be:

/bshop addsection 
Example: /bshop addsection gear DIAMOND_CHESTPLATE &a 8 Another example: /bshop addsection blocks GRASS_BLOCK &e 9 --- # SECTION ARGUMENTS
The internal section ID. Examples: gear blocks food ores tools The internal ID should be unique. The material used as the section icon inside the main /shop GUI. Examples: DIAMOND_CHESTPLATE GRASS_BLOCK DIAMOND_PICKAXE GOLDEN_APPLE IRON_INGOT Validate that the Minecraft material exists. Minecraft color codes. Examples: &a &e &b &c &6 Example: /bshop addsection gear DIAMOND_CHESTPLATE &a 8 The displayed name should automatically become: &aGear The plugin should combine: +
--- # SECTION SLOT SYSTEM โ€” IMPORTANT The value determines the EXACT number of usable shop item positions PER PAGE. Valid values: 1 2 3 4 5 6 7 8 9 Examples: slots = 8 Means: Each page has exactly 8 usable item positions. slots = 9 Means: Each page has exactly 9 usable item positions. DO NOT automatically convert: 8 โ†’ 9 The configured slot amount must always remain exact. --- # CRITICAL GUI LAYOUT FIX โ€” SECTION ITEMS The current plugin has a visual problem where items overflow into the bottom row. For example, when a section has configured shop slots, the plugin must NEVER place overflow items into another row. THIS IS NOT ACCEPTABLE. Items must NEVER automatically overflow into the bottom row. The section GUI inventory size must remain fixed. --- # FIXED SECTION GUI SIZE Every shop section GUI must use exactly: 3 rows 27 total slots The inventory size must always be: 27 The section GUI must NEVER dynamically expand. --- # EXACT SHOP ITEM SLOT POSITIONS Use these exact slots as the shop item positions: 9 10 11 12 13 14 15 16 17 This is the complete middle row. Therefore: slots = 1 uses Slot 9 slots = 2 uses Slots 9โ€“10 slots = 7 uses Slots 9โ€“15 slots = 8 uses Slots 9โ€“16 slots = 9 uses Slots 9โ€“17 IMPORTANT: All shop items must stay in these middle-row positions. Do NOT place the 8th or 9th item into the bottom row. Do NOT use dynamic slot positions. Do NOT create additional item slots. --- # SECTION GUI VISUAL LAYOUT The section GUI must use this fixed layout: Top Row: Slots 0โ€“8 = BLACK_STAINED_GLASS_PANE Middle Row: Slots 9โ€“17 = Shop Item Positions Bottom Row: Slot 18 = Previous Page Button Slots 19โ€“25 = BLACK_STAINED_GLASS_PANE Slot 26 = Next Page Button The exact layout concept: [ BLACK ][ BLACK ][ BLACK ][ BLACK ][ BLACK ][ BLACK ][ BLACK ][ BLACK ][ BLACK ] [ ITEM ][ ITEM ][ ITEM ][ ITEM ][ ITEM ][ ITEM ][ ITEM ][ ITEM ][ ITEM ] [ PREVIOUS ][ BLACK ][ BLACK ][ BLACK ][ BLACK ][ BLACK ][ BLACK ][ BLACK ][ NEXT ] --- # CONFIGURED SLOT LIMIT The argument controls how many positions from the middle row are usable. Example: /bshop addsection gear DIAMOND_CHESTPLATE &a 7 Only these positions are usable: 9 10 11 12 13 14 15 Slots: 16 17 must remain: BLACK_STAINED_GLASS_PANE They must NOT become usable. --- # IMPORTANT: DO NOT CREATE EXTRA SHOP SLOTS This is a critical fix. Currently, when an item is added, the plugin is incorrectly creating or expanding extra inventory slots. THIS MUST NOT HAPPEN. If a section has: slots = 9 then exactly: 9 shop item positions per page must exist. Adding the first item must NOT create a new slot. Adding the second item must NOT create a new slot. The GUI layout must remain fixed. The number of shop item positions must always be determined ONLY by: /bshop addsection
NOT by the number of items added. --- # SECTION PAGE SYSTEM โ€” VERY IMPORTANT Sections must support automatic pagination. Example: /bshop addsection gear DIAMOND_CHESTPLATE &a 9 This means: 9 usable shop item positions PER PAGE. When items 1 through 9 are added: Page 1 is full. When the administrator adds item number 10: DO NOT: Increase inventory size Create extra item slots Expand the first page Place item 10 in the bottom row Instead: Automatically create Page 2. Item number 10 must be placed on: Page 2 --- # PAGE NAVIGATION When more than one page exists, display navigation buttons. Use fixed positions: Slot 18 = Previous Page button Slot 26 = Next Page button Navigation buttons must NOT count as shop item slots. Example: slots = 9 The section still has exactly 9 usable item positions per page. Page 1: Items 1โ€“9 Next Page button visible in Slot 26 Page 2: Items 10โ€“18 Previous Page button visible in Slot 18 If there are more pages: Previous Page button = Slot 18 Next Page button = Slot 26 When a navigation button is not required, that slot must contain: BLACK_STAINED_GLASS_PANE --- # CRITICAL NO-OVERFLOW RULE The following must NEVER happen: Configured Slots: 7 Middle Row: 7 items Bottom Row: Extra items Instead: Configured Slots: 7 Page 1: Maximum 7 items Item 8: Automatically goes to Page 2 This rule is mandatory. --- # DELETE SECTION COMMAND The exact command: /bshop deletesection
Example: /bshop deletesection gear This must: - Delete the section. - Delete its section icon. - Delete all pages. - Delete all buy items inside the section. - Save changes immediately. Do not affect unrelated sell items unless they are explicitly linked to that section. --- # BUY ITEM COMMAND โ€” UPDATED The old command with sell price must be removed. DO NOT use: /bshop addhanditem
The new exact command must be: /bshop addhanditem
Example: /bshop addhanditem gear 100 The administrator must hold the item in their MAIN HAND. The plugin must save the complete ItemStack. The item must automatically be added to the next available page and position. Example: If Page 1 contains 8 items and slots = 9: The next item goes to Page 1, position 9. If Page 1 already contains 9 items: The next item goes to Page 2, position 1. Do not create extra slots. Do not expand Page 1. --- # BUY PRICE FORMAT The buy price should support: 100 1000 50.5 1000000 Also support: -1 The value: -1 means: Buying Disabled Example: /bshop addhanditem gear -1 The item can be displayed but cannot be bought. Reject invalid negative values such as: -2 -100 --- # SELL ITEM SYSTEM โ€” COMPLETELY SEPARATE Sell items must be configured separately. Add this exact admin command: /bshop addhandsellitem Example: /bshop addhandsellitem 300 The administrator must hold an item in their MAIN HAND. The plugin must save that exact item as a sellable item. IMPORTANT SELL MATCHING FIX: If an administrator holds an OAK_LOG and runs: /bshop addhandsellitem 300 Then that exact OAK_LOG must successfully sell through /sell. The plugin must correctly save and later compare the ItemStack. Do not accidentally fail matching because the item is vanilla and has no custom metadata. For normal vanilla items, matching the saved ItemStack must work correctly. The price is the amount the player receives when selling the item through: /sell --- # LARGE SELL PRICES The argument for: /bshop addhandsellitem must support normal and very large finite economy values. Examples: 100 1000 1000000 999999999 1000000000000 Do not impose an unnecessarily small hard-coded maximum. Use a numeric type compatible with the Vault economy provider. The price must be: - A valid finite number. - Greater than or equal to zero. Reject: NaN Infinity -Infinity negative numbers invalid text If the economy provider itself has limits, handle those limits safely and show a clear error. --- # SELL ITEMS ARE NOT LINKED TO BUY ITEMS The Buy Shop and Sell Shop must be independent. Example: /bshop addhanditem gear 100 This adds an item to the Buy Shop only. It does NOT automatically make the item sellable. To make an item sellable, an admin must separately use: /bshop addhandsellitem Example: /bshop addhandsellitem 50 This saves the currently held item as sellable for: /sell --- # /sell GUI โ€” CRITICAL FIX The /sell command must open the BossShop Sell GUI. There must be NO: /sellgui The Sell GUI must contain exactly: 54 total slots The GUI inventory size must be: 54 The sellable input area must be: Slots 0โ€“52 Slot 53 must be reserved for the SELL ITEMS button. This gives the player a large sell area without dynamically changing GUI size. IMPORTANT: Do not dynamically expand the Sell GUI. Do not create additional inventory rows. The /sell GUI must always remain exactly 54 slots. --- # SELL GUI LAYOUT Slots: 0โ€“52 = Player sell input slots 53 = SELL ITEMS button The SELL ITEMS button must have a clear display name such as: &a&lSELL ITEMS When the player clicks Slot 53: 1. Check all items in slots 0โ€“52. 2. Match each item against sell.yml. 3. Sell every matching configured item. 4. Calculate the correct payout. 5. Deposit money through Vault. 6. Remove only items that were successfully sold. 7. Leave non-sellable items untouched. 8. Never delete an item when the economy transaction fails. --- # SELL ITEM MATCHING โ€” CRITICAL FIX The plugin must match configured sell items safely and reliably. Use important ItemStack data where applicable: - Material - Custom name - Lore - Enchantments - Custom Model Data - Important ItemMeta However, the matching system must NOT reject ordinary vanilla items simply because they do not have custom metadata. For example: Admin holds OAK_LOG and runs: /bshop addhandsellitem 300 A player later puts a normal OAK_LOG into /sell. It MUST match and sell correctly. Use a robust comparison strategy. For exact custom items, compare their relevant ItemMeta. For plain vanilla items with no special metadata, material matching must work. --- # SELL TRANSACTION RULES If an item matches a configured sell item: - Remove the correct amount. - Deposit the configured money. - Only finalize item removal after the Vault transaction succeeds. If an item is not configured as sellable: - Do not destroy it. - Do not sell it. - Leave it in the Sell GUI. When the player closes the Sell GUI: - Return all remaining unsold items safely to the player's inventory. - If the inventory is full, safely drop the remaining items at the player's location. - Never lose items. --- # sell.yml The sell.yml file must store items added through: /bshop addhandsellitem Example concept: sell-items: item-id: price: 300 item: ... On a fresh installation, there must be no default sell items. --- # shop.yml The shop.yml file stores: - Sections - Section display name - Prefix - Section showitem - Slots per page - Pages - Buy items - Buy prices - Complete saved ItemStacks Example concept: sections: gear: display-name: "&aGear" showitem: DIAMOND_CHESTPLATE slots-per-page: 9 pages: 1: items: item1: price: 100 item: ... If more than 9 items are added: pages: 1: items: ... 2: items: ... --- # DELETE ITEM COMMAND Keep the exact command: /bshop deleteitem
Example: /bshop deleteitem gear DiamondSword This must: - Remove the item from the specified shop section. - Remove its buy price. - Remove it from its page. - Reorganize pages safely if needed. - Save immediately. Deleting an item must NOT corrupt pagination. If a page becomes empty, optionally remove that page safely. --- # DELETE SELL ITEM SUPPORT Also support deleting configured sell items. Recommended command: /bshop deletesellitem Tab completion should show configured sell item IDs. Do not accidentally delete unrelated items. --- # SHOP ITEM LORE Buy items should display: &7Left Click to Buy &aBuy Price: $100 If buying is disabled: &cBuying Disabled Do NOT automatically display sell prices on buy shop items, because selling is managed separately through /sell. --- # /bshop reload Command: /bshop reload Reload: shop.yml sell.yml Reload all data without restarting the server. --- # /bshop help Show the updated command list: &6&lBossShop Admin Commands &f/bshop addsection
&f/bshop deletesection
&f/bshop addhanditem
&f/bshop addhandsellitem &f/bshop deleteitem
&f/bshop reload &f/bshop help --- # FINAL COMMAND TREE The final command system must be exactly: /shop /sell /bshop help /bshop reload /bshop addsection
/bshop deletesection
/bshop addhanditem
/bshop addhandsellitem /bshop deleteitem
Do NOT use: /sellgui Do NOT use: /bshop addhanditem
The sell price must not be part of addhanditem. --- # TAB COMPLETION /bshop should suggest: help reload addsection deletesection addhanditem addhandsellitem deleteitem deletesellitem Section arguments should suggest existing sections. deleteitem should suggest items from the selected section. Sell item deletion should suggest configured sell item IDs. --- # SECURITY Prevent: - Item duplication. - Money duplication. - Extra slot creation. - Dynamic unwanted GUI expansion. - Shop item overflow into another row. - Shift-click exploits. - Number-key exploits. - Drag exploits. - Double-click exploits. - Taking black glass panes. - Taking section icons. - Invalid page access. - Invalid prices. - NaN prices. - Infinity prices. - Failed Vault transaction exploits. - Item loss. - Inventory desynchronization. All transactions must be validated. --- # FINAL CRITICAL REQUIREMENTS MAIN SHOP: /shop 3 ROWS 27 TOTAL SLOTS ONE SECTION = EXACT CENTER SLOT 13 MULTIPLE SECTIONS = CENTERED PLACEMENT PRIORITY EMPTY POSITIONS = BLACK_STAINED_GLASS_PANE SECTION PAGES: SECTION GUI = ALWAYS 27 SLOTS TOP ROW = BLACK GLASS MIDDLE ROW SLOTS 9โ€“17 = ONLY SHOP ITEM POSITIONS BOTTOM ROW: SLOT 18 = PREVIOUS PAGE SLOTS 19โ€“25 = BLACK GLASS SLOT 26 = NEXT PAGE slots 8 = EXACTLY 8 ITEM POSITIONS PER PAGE slots 9 = EXACTLY 9 ITEM POSITIONS PER PAGE ADDING ITEMS MUST NEVER CREATE EXTRA SLOTS ITEMS MUST NEVER OVERFLOW INTO THE BOTTOM ROW FULL PAGE = AUTOMATICALLY CREATE NEXT PAGE SELL GUI: /sell ALWAYS EXACTLY 54 SLOTS SLOTS 0โ€“52 = SELL INPUT AREA SLOT 53 = SELL ITEMS BUTTON NO DYNAMIC GUI EXPANSION SELL MATCHING MUST WORK FOR NORMAL VANILLA ITEMS SUCH AS OAK_LOG Example: Admin holds OAK_LOG: /bshop addhandsellitem 300 Player puts OAK_LOG into /sell and clicks SELL ITEMS. The item MUST sell successfully and the player MUST receive the configured money. COMMANDS: PLAYER: /shop /sell ADMIN: /bshop addsection
/bshop deletesection
/bshop addhanditem
/bshop addhandsellitem /bshop deleteitem
/bshop reload /bshop help MOST IMPORTANT: NO /sellgui NO SELL PRICE IN /bshop addhanditem BUY ITEMS AND SELL ITEMS MUST BE CONFIGURED SEPARATELY NO EXTRA GUI SLOTS WHEN ADDING ITEMS NO SHOP ITEM OVERFLOW INTO BOTTOM ROW FULL PAGE = NEXT PAGE, NOT INVENTORY EXPANSION /sell MUST USE EXACTLY 54 SLOTS The plugin must compile without errors and all data must persist after server restart.
Kodari AI
KodariAug 30 at 4:02 am 18
BossShop
A GUI-based shop plugin with separate buy and sell systems. Players use /shop to browse centered section icons and purchase items from paginated 27-slot GUIs with fixed middle-row item positions, and /sell to sell items through a fixed 54-slot interface with a dedicated sell button. Admins use /bshop with subcommands to manage sections, buy items, and sell items, with data persisted in shop.yml and sell.yml. Includes Vault economy integration, robust item matching for vanilla and custom items, centered section placement, automatic pagination without overflow, and comprehensive security against exploits.
  1. Create the BossShop plugin foundation, Vault integration, commands, and persistent shop/sell storage.

  2. Implement fixed-size centered shop, section pagination, and exploit-safe click handling.

  3. Implement the 54-slot sell GUI with reliable ItemStack matching and transaction-safe payouts.

Created BossShop from scratch with:

  • /shop: fixed 27-slot, centered section GUI with black-pane background.

  • Section menus: fixed 27 slots, exact middle-row capacity (1โ€“9), safe pagination at slots 18/26.

  • /sell: fixed 54-slot GUI, slots 0โ€“52 for input and slot 53 as the sell button.

  • Vault-backed buy/sell transactions that only remove items after successful economy responses.

  • Separate persisted shop.yml and sell.yml storage.

  • /bshop admin commands, permissions, reload support, and contextual tab completion.

  • No /sellgui, no sell price on /bshop addhanditem, and no dynamic inventory expansion.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
15 1,085
src/main/java/com/kodari/bossshop/BossShopPlugin.java
package com.kodari.bossshop;

import com.kodari.bossshop.command.BossShopCommand;
import com.kodari.bossshop.gui.ShopGuiService;
import com.kodari.bossshop.gui.ShopListener;
import com.kodari.bossshop.storage.SellRepository;
import com.kodari.bossshop.storage.ShopRepository;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public final class BossShopPlugin extends JavaPlugin {
    private ShopRepository shopRepository;
    private SellRepository sellRepository;
    private ShopGuiService shopGuiService;
    private Economy economy;

    @Override
    public void onEnable() {
        if (!setupEconomy()) {
            getLogger().severe("Vault with an economy provider is required to use BossShop.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        this.shopRepository = new ShopRepository(this);
        this.sellRepository = new SellRepository(this);
        this.shopGuiService = new ShopGuiService(this);

        ShopListener listener = new ShopListener(this);
        getServer().getPluginManager().registerEvents(listener, this);

        BossShopCommand command = new BossShopCommand(this);
        registerCommand("shop", command);
        registerCommand("sell", command);
        registerCommand("bshop", command);
    }

    private boolean setupEconomy() {
        RegisteredServiceProvider<Economy> registration = getServer().getServicesManager().getRegistration(Economy.class);
        if (registration == null) {
            return false;
        }
        this.economy = registration.getProvider();
        return this.economy != null;
    }

    private void registerCommand(String name, BossShopCommand executor) {
        PluginCommand command = getCommand(name);
        if (command == null) {
            throw new IllegalStateException("Missing command registration for /" + name);
        }
        command.setExecutor(executor);
        command.setTabCompleter(executor);
    }
}