rkboss95yt
๐Ÿ“Ž 1 file 12,753 chars
๐Ÿ“„
pasted-code-1788962050235.txt
txt 877 lines
โ–ถ
# IMPORTANT COMMAND REQUIREMENT

Player commands must be exactly:

/shop

Admin command:

/bshop

There must be NO:

---

# 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 Configured Slots: 7 Page 1: Maximum 7 items Item 8: Automatically goes to Page 2 Extra items must NEVER be placed in the bottom row. 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. --- # BUY ITEM COMMAND โ€” UPDATED DO NOT use: /bshop addhanditem
The 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. 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 --- Example concept: sell-items: item-id: price: 300 item: ... The stored ItemStack must contain enough information for robust matching. Plain vanilla items must still match by Material. --- # 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: 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 --- # /bshop reload Command: /bshop reload Reload: shop.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 deleteitem
&f/bshop reload &f/bshop help --- # FINAL COMMAND TREE PLAYER: /shop ADMIN: /bshop help /bshop reload /bshop addsection
/bshop deletesection
/bshop addhanditem
/bshop deleteitem
Do NOT use: Do NOT use: /bshop addhanditem
The sell price must not be part of addhanditem. --- # TAB COMPLETION /bshop should suggest: help reload addsection deletesection addhanditem deleteitem 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. - Taking black glass panes. - Taking section icons. - Invalid page access. - Invalid prices. - NaN prices. - Infinity prices. - Item loss. - Inventory desynchronization. - Double-click collection exploits. - Number-key exploits in protected /shop GUIs. IMPORTANT: 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 Do not unnecessarily change any correctly working /shop behavior. 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 = NEXT PAGE, NOT INVENTORY EXPANSION SELL GUI โ€” FINAL: ALWAYS EXACTLY 54 SLOTS NO RESERVED ACTION SLOT PLAYERS MUST BE ABLE TO USE SHIFT + LEFT CLICK TO QUICKLY MOVE ITEMS INTO THE SELL GUI PLAYERS PUT ITEMS IN THE GUI AND CLOSE IT WITH ESC OR NORMAL INVENTORY CLOSE CLOSING THE GUI AUTOMATICALLY PROCESSES THE SALE SUCCESSFULLY SOLD ITEMS: - Vault deposit succeeds first. - Then the sold item is removed. UNSELLABLE OR FAILED ITEMS: - Must be returned safely. - Must never disappear. SELL MATCHING MUST WORK FOR NORMAL VANILLA ITEMS SUCH AS OAK_LOG Example: Admin holds OAK_LOG: Player opens: Player SHIFT + LEFT CLICKS OAK_LOG stacks into the Sell GUI. Player presses ESC. All matching OAK_LOG items are automatically sold. The player receives: 300 ร— number of OAK_LOG successfully sold. There must be NO: NO SELL PRICE IN /bshop addhanditem NO EXTRA GUI SLOTS WHEN ADDING SHOP ITEMS NO SHOP ITEM OVERFLOW INTO BOTTOM ROW FULL SHOP PAGE = NEXT PAGE, NOT INVENTORY EXPANSION The plugin must compile without errors and all data must persist after server restart.
Kodari AI
KodariSep 9 at 1:56 pm 13
BossShopManager
A Bukkit plugin providing a GUI-based player shop system. Players open a 27-slot main shop GUI via /shop, with section icons centered around slot 13. Each section opens a fixed 27-slot page GUI with shop items in the middle row (slots 9-17), automatic pagination, and navigation buttons. Admins use /bshop to manage sections and items, with commands for adding/deleting sections, adding held items with buy prices, deleting items, and reloading config. Includes a 54-slot sell GUI supporting shift-click selling with vault deposit and safe item return.
  • Build the fixed 27-slot main and paginated section shop interfaces.

  • Persist sections, complete item stacks, pages, buy prices, and sell listings in shop.yml.

  • Add /shop, permission-protected /bshop administration, Vault transactions, and secure sell-on-close handling.

Created the BossShop plugin with:

  • Fixed 27-slot /shop main menu and centered section priority placement.

  • Fixed 27-slot section menus, middle-row-only item slots, and safe page navigation.

  • shop.yml persistence for sections, pages, full ItemStack data, buy prices, and sell listings.

  • Vault-backed buy and sell processing with failed sell items returned safely.

  • /shop plus permission-protected /bshop administration, validation, reload, and tab completion.

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

import com.kodari.bossshop.command.ShopCommand;
import com.kodari.bossshop.command.ShopTabCompleter;
import com.kodari.bossshop.listener.ShopListener;
import com.kodari.bossshop.shop.ShopManager;
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;

public class BossShopPlugin extends JavaPlugin {

    @Getter
    private ShopManager shopManager;

    @Getter
    private Economy economy;

    @Override
    public void onEnable() {
        setupEconomy();
        shopManager = new ShopManager(this, economy);

        ShopCommand command = new ShopCommand(this);
        ShopTabCompleter completer = new ShopTabCompleter(this);
        PluginCommand shopCommand = getCommand("shop");
        PluginCommand adminCommand = getCommand("bshop");
        if (shopCommand != null) {
            shopCommand.setExecutor(command);
        }
        if (adminCommand != null) {
            adminCommand.setExecutor(command);
            adminCommand.setTabCompleter(completer);
        }
        getServer().getPluginManager().registerEvents(new ShopListener(this), this);
    }

    private void setupEconomy() {
        RegisteredServiceProvider<Economy> registration = getServer().getServicesManager().getRegistration(Economy.class);
        if (registration != null) {
            economy = registration.getProvider();
        }
        if (economy == null) {
            getLogger().severe("Vault economy provider was not found. Buying and selling are disabled.");
        }
    }
}