๐
pasted-code-1788061142078.txt
txt
1120 lines
โถ
# BOSS SHOP โ FINAL COMPLETE UPDATE REQUIREMENTS
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:
```text
/shop
/sell
```
Admin command:
```text
/bshop
```
There must be NO:
```text
/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:
```text
bossshop.admin
```
Normal players must not be able to use `/bshop`.
Support individual permissions:
```text
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:
```text
&cYou do not have permission to use this command.
```
---
# MAIN `/shop` GUI โ VERY IMPORTANT
The main `/shop` GUI must contain exactly:
```text
3 rows
27 slots
```
The inventory size must always be:
```text
27
```
Bukkit slot layout:
```text
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:
```text
13
```
---
# MAIN SHOP GUI BACKGROUND
Every unused slot must contain:
```text
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:
```text
Slot 13
```
Example:
```text
/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:
```text
13
12
14
11
15
10
16
9
17
```
Then continue with:
```text
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:
```text
/bshop addsection
```
Example:
```text
/bshop addsection gear DIAMOND_CHESTPLATE &a 8
```
Another example:
```text
/bshop addsection blocks GRASS_BLOCK &e 9
```
---
# SECTION ARGUMENTS
## ``
The internal section ID.
Examples:
```text
gear
blocks
food
ores
tools
```
The internal ID should be unique.
---
## ``
The material used as the section icon inside the main `/shop` GUI.
Examples:
```text
DIAMOND_CHESTPLATE
GRASS_BLOCK
DIAMOND_PICKAXE
GOLDEN_APPLE
IRON_INGOT
```
Validate that the Minecraft material exists.
---
## ``
Minecraft color codes.
Examples:
```text
&a
&e
&b
&c
&6
```
Example:
```text
/bshop addsection gear DIAMOND_CHESTPLATE &a 8
```
The displayed name should automatically become:
```text
&aGear
```
The plugin should combine:
```text
+
```
---
# SECTION SLOT SYSTEM โ IMPORTANT
The `` value determines the EXACT number of usable shop item positions PER PAGE.
Valid values:
```text
1
2
3
4
5
6
7
8
9
```
Examples:
```text
slots = 8
```
Means:
```text
Each page has exactly 8 usable item positions.
```
Example:
```text
slots = 9
```
Means:
```text
Each page has exactly 9 usable item positions.
```
DO NOT automatically convert:
```text
8 โ 9
```
The configured slot amount must always remain exact.
---
# 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:
```text
slots = 9
```
then exactly:
```text
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:
```text
/bshop addsection
```
NOT by the number of items added.
---
# SECTION PAGE SYSTEM โ VERY IMPORTANT
Sections must support automatic pagination.
Example:
```text
/bshop addsection gear DIAMOND_CHESTPLATE &a 9
```
This means:
```text
9 usable shop item positions PER PAGE.
```
When items 1 through 9 are added:
```text
Page 1 is full.
```
When the administrator adds item number 10:
DO NOT:
```text
Increase inventory size
Create extra item slots
Expand the first page
```
Instead:
```text
Automatically create Page 2.
```
Item number 10 must be placed on:
```text
Page 2
```
---
# PAGE NAVIGATION
When more than one page exists, display navigation buttons.
The section GUI should have fixed navigation positions outside the configured shop item positions.
Use:
```text
Previous Page button = left side
Next Page button = right side
```
The navigation buttons must NOT count as shop item slots.
Example:
```text
slots = 9
```
The section still has exactly 9 usable item positions per page.
The Next Page button is a navigation button, not an item slot.
Example behavior:
```text
Page 1
Items 1โ9
Next Page button visible
```
After clicking Next Page:
```text
Page 2
Items 10โ18
Previous Page button visible
```
If Page 2 also contains more pages:
```text
Previous Page button
Next Page button
```
---
# SECTION GUI LAYOUT
Use a fixed GUI layout.
Do not dynamically change inventory size based on the number of items.
For example, the section GUI may use a fixed valid chest inventory size, but only the configured `` positions can contain shop items.
All non-item positions must remain:
```text
BLACK_STAINED_GLASS_PANE
```
except navigation buttons.
Example with:
```text
slots = 8
```
The page must have:
```text
8 usable shop item positions
```
The ninth unused item-area position must remain:
```text
BLACK_STAINED_GLASS_PANE
```
It must not become usable.
---
# DELETE SECTION COMMAND
The exact command:
```text
/bshop deletesection
```
Example:
```text
/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:
```text
/bshop addhanditem
```
The new exact command must be:
```text
/bshop addhanditem
```
Example:
```text
/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:
```text
slots = 9
```
then the next item goes to:
```text
Page 1, position 9
```
If Page 1 already contains 9 items, then the next item goes to:
```text
Page 2, position 1
```
Do not create extra slots.
Do not expand Page 1.
---
# BUY PRICE FORMAT
The buy price should support:
```text
100
1000
50.5
1000000
```
Also support:
```text
-1
```
The value:
```text
-1
```
means:
```text
Buying Disabled
```
Example:
```text
/bshop addhanditem gear -1
```
The item can be displayed but cannot be bought.
Reject invalid negative values such as:
```text
-2
-100
```
---
# SELL ITEM SYSTEM โ COMPLETELY SEPARATE
Sell items must be configured separately.
Add this exact admin command:
```text
/bshop addhandsellitem
```
Example:
```text
/bshop addhandsellitem 100
```
The administrator must hold an item in their MAIN HAND.
The plugin must save that exact item as a sellable item.
The price is the amount the player receives when selling the item through:
```text
/sell
```
---
# LARGE SELL PRICES
The `` argument for:
```text
/bshop addhandsellitem
```
must support normal and very large finite economy values.
Examples:
```text
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:
```text
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:
```text
/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:
```text
/bshop addhandsellitem
```
Example:
```text
/bshop addhandsellitem 50
```
This saves the currently held item as sellable for:
```text
/sell
```
---
# `/sell` GUI
The player command:
```text
/sell
```
must open the BossShop Sell GUI.
There must be NO:
```text
/sellgui
```
The Sell GUI must only accept items that were previously added through:
```text
/bshop addhandsellitem
```
If an item matches a configured sell item:
- Remove the item.
- Deposit the configured money into the player's account.
If an item is not configured as sellable:
- Do not destroy the item.
- Do not sell the item.
- Return or keep the item safely.
---
# SELL ITEM MATCHING
Match configured sell items safely.
Use important ItemStack data, including where applicable:
- Material
- Custom name
- Lore
- Enchantments
- Custom Model Data
- Important ItemMeta
This prevents custom items from accidentally being treated as ordinary vanilla items.
---
# `sell.yml`
The `sell.yml` file must store items added through:
```text
/bshop addhandsellitem
```
Example concept:
```yml
sell-items:
item-id:
price: 100
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:
```yml
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:
```yml
pages:
1:
items:
...
2:
items:
...
```
---
# DELETE ITEM COMMAND
Keep the exact command:
```text
/bshop deleteitem
```
Example:
```text
/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:
```text
/bshop deletesellitem
```
Tab completion should show configured sell item IDs.
Do not accidentally delete unrelated items.
---
# SHOP ITEM LORE
Buy items should display:
```text
&7Left Click to Buy
&aBuy Price: $100
```
If buying is disabled:
```text
&cBuying Disabled
```
Do NOT automatically display sell prices on buy shop items, because selling is now managed separately through `/sell`.
---
# `/bshop reload`
Command:
```text
/bshop reload
```
Reload:
```text
shop.yml
sell.yml
```
Reload all data without restarting the server.
---
# `/bshop help`
Show the updated command list:
```text
&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:
```text
/shop
/sell
/bshop help
/bshop reload
/bshop addsection
/bshop deletesection
/bshop addhanditem
/bshop addhandsellitem
/bshop deleteitem
```
Do NOT use:
```text
/sellgui
```
Do NOT use:
```text
/bshop addhanditem
```
The sell price must not be part of `addhanditem`.
---
# TAB COMPLETION
`/bshop` should suggest:
```text
help
reload
addsection
deletesection
addhanditem
addhandsellitem
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.
- 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
The following requirements are mandatory:
```text
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
```
For section pages:
```text
slots 8 = EXACTLY 8 ITEM POSITIONS PER PAGE
slots 9 = EXACTLY 9 ITEM POSITIONS PER PAGE
ADDING ITEMS MUST NEVER CREATE EXTRA SLOTS
WHEN A PAGE IS FULL:
AUTOMATICALLY CREATE NEXT PAGE
SHOW NEXT PAGE BUTTON ON THE RIGHT SIDE
```
Commands:
```text
PLAYER:
/shop
/sell
ADMIN:
/bshop addsection
/bshop deletesection
/bshop addhanditem
/bshop addhandsellitem
/bshop deleteitem
/bshop reload
/bshop help
```
Most importantly:
```text
NO /sellgui
NO SELL PRICE IN /bshop addhanditem
BUY ITEMS AND SELL ITEMS MUST BE CONFIGURED SEPARATELY
NO EXTRA GUI SLOTS WHEN ADDING ITEMS
FULL PAGE = NEXT PAGE, NOT INVENTORY EXPANSION
```
The plugin must compile without errors and all data must persist after server restart.
Create the BossShop plugin foundation, Vault integration, and persistent
shop.yml/sell.ymlstorage.Implement
/shop,/sell, and restricted/bshopcommands with tab completion.Add fixed, exploit-safe shop, section pagination, and sell GUIs.
Foundation and persistence are in place.
Commands and admin controls are registered without
/sellgui.Iโm tightening sell-menu item return handling and individual-permission tab completion.Implemented BossShop from scratch.
/shop: fixed 27-slot main GUI, black-pane background, centered section priority.Section pages: fixed 27-slot layout with exactly configured 1โ9 item positions; automatic pagination and navigation.
/sell: separate sell GUI with safe matching, Vault transaction validation, and item-return protection./bshop: admin-only commands, individual permissions, reload, help, section/item/sell-item management, and tab completion.Persistent
shop.ymlandsell.ymlstorage; no default sell items.No
/sellgui, and buy/sell prices are configured separately.
package com.kodari.bossshop;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;
public final class BossShop extends JavaPlugin {
@Getter
private ShopStorage storage;
@Getter
private EconomyService economyService;
@Getter
private ShopGui shopGui;
@Override
public void onEnable() {
this.storage = new ShopStorage(this);
this.economyService = new EconomyService(this);
this.shopGui = new ShopGui(this);
BossShopCommand command = new BossShopCommand(this);
registerCommand("shop", command);
registerCommand("sell", command);
registerCommand("bshop", command);
Bukkit.getPluginManager().registerEvents(new ShopListener(this), this);
}
private void registerCommand(String name, BossShopCommand command) {
PluginCommand pluginCommand = getCommand(name);
if (pluginCommand == null) {
throw new IllegalStateException("Missing command declaration: " + name);
}
pluginCommand.setExecutor(command);
pluginCommand.setTabCompleter(command);
}
}