π
pasted-code-1788059609657.txt
txt
930 lines
βΆ
# BOSS SHOP β UPDATE / COMPLETE REQUIREMENTS
Modify the existing BossShop plugin according to ALL requirements below.
Keep the plugin name:
`BossShop`
Do not rename the plugin.
The plugin must remain lightweight and production-ready.
---
# IMPORTANT COMMAND REQUIREMENT
Player commands must be exactly:
```text
/shop
/sell
```
Admin command must be:
```text
/bshop
```
There must be NO:
```text
/sellgui
```
The `/sell` command itself must directly open the Sell GUI.
Do not register `/sellgui` as an alias.
---
# ADMIN PERMISSIONS
The `/bshop` command and all of its subcommands are ADMIN ONLY.
Main permission:
```text
bossshop.admin
```
Normal players must not be able to use `/bshop`.
Players without permission must receive:
```text
&cYou do not have permission to use this command.
```
Support individual permissions if possible:
```text
bossshop.admin.help
bossshop.admin.reload
bossshop.admin.addsection
bossshop.admin.deletesection
bossshop.admin.additem
bossshop.admin.deleteitem
```
---
# MAIN SHOP GUI DESIGN β VERY IMPORTANT
The main `/shop` GUI must look similar to the provided reference screenshot.
The main shop GUI must contain exactly:
```text
3 rows
27 total inventory slots
```
The inventory size must be:
```text
27
```
The layout should be similar to a normal chest GUI with:
```text
Row 1 = slots 0β8
Row 2 = slots 9β17
Row 3 = slots 18β26
```
---
# BLACK GLASS PANE BACKGROUND
All unused slots in the main `/shop` GUI must automatically be filled with:
```text
BLACK_STAINED_GLASS_PANE
```
The glass pane should:
- Have no visible name, or use `" "`.
- Be impossible for players to take.
- Be impossible to move.
- Be impossible to shift-click.
- Be impossible to drag.
- Act only as a background decoration.
Example concept:
```text
[ BLACK GLASS ][ SECTION ][ BLACK GLASS ][ BLACK GLASS ]
[ SECTION ][ BLACK GLASS ][ SECTION ][ BLACK GLASS ]
[ BLACK GLASS ][ BLACK GLASS ][ BLACK GLASS ][ SECTION ]
```
Only section show-items should replace the black glass panes.
---
# SECTION 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
```
Command arguments:
### ``
The internal section ID/name.
Example:
```text
gear
blocks
food
ores
```
### ``
The Minecraft material used as the section icon in the main `/shop` GUI.
Examples:
```text
DIAMOND_CHESTPLATE
GRASS_BLOCK
DIAMOND_PICKAXE
GOLDEN_APPLE
IRON_INGOT
```
The plugin must validate that the material exists.
### ``
A color prefix using Minecraft color codes.
Examples:
```text
&a
&e
&b
&c
&6
```
Example result:
```text
/bshop addsection gear DIAMOND_CHESTPLATE &a 8
```
The section display name should become:
```text
&aGear
```
The plugin should automatically combine:
```text
+
```
for the displayed section name.
### ``
This determines how many usable item slots the section contains.
Examples:
```text
1
2
3
4
5
6
7
8
9
```
IMPORTANT:
The number of usable slots must remain exactly as specified.
For example:
```text
/bshop addsection gear DIAMOND_CHESTPLATE &a 8
```
The Gear section must contain exactly:
```text
8 usable shop item positions
```
It must NOT automatically change 8 into 9.
---
# SECTION GUI SLOT BEHAVIOR β VERY IMPORTANT
If a section is created with:
```text
slots = 8
```
then only 8 positions must be available for shop items.
The section GUI should still use a valid Minecraft inventory size if necessary, but only the configured number of slots can contain shop items.
Example for 8 usable slots:
```text
[ ITEM ][ ITEM ][ ITEM ][ ITEM ][ ITEM ][ ITEM ][ ITEM ][ ITEM ][ BLACK GLASS ]
```
The unused remaining slot must automatically contain:
```text
BLACK_STAINED_GLASS_PANE
```
The player must not be able to put items into the unused slot.
---
# EXAMPLES OF SLOT CONFIGURATION
If:
```text
slots = 1
```
Only position 1 is usable.
If:
```text
slots = 5
```
Only positions 1β5 are usable.
If:
```text
slots = 8
```
Only positions 1β8 are usable.
If:
```text
slots = 9
```
All positions 1β9 are usable.
Do not automatically round 8 to 9.
The configured amount represents the exact number of usable item positions.
---
# MAIN SHOP SECTION PLACEMENT
The main `/shop` GUI contains 27 slots.
Sections should automatically occupy available non-background positions.
Each created section should display its configured:
```text
showitem
```
The section item should have the display name:
```text
```
Example:
```text
/bshop addsection gear DIAMOND_CHESTPLATE &a 8
```
Displays:
```text
DIAMOND_CHESTPLATE
Name: &aGear
```
Clicking the item opens the Gear section.
All other empty positions remain filled with black glass panes.
---
# DELETE SECTION COMMAND
The exact command must be:
```text
/bshop deletesection
```
Example:
```text
/bshop deletesection gear
```
This must:
- Remove the section.
- Remove its main GUI icon.
- Remove its buy items.
- Remove its sell data associated with that section if applicable.
- Save the changes permanently.
Show a confirmation message.
---
# ADD ITEM COMMAND
The exact command must be:
```text
/bshop addhanditem
```
Example:
```text
/bshop addhanditem gear 100 50
```
The administrator must hold the item in their MAIN HAND.
The plugin must save the complete ItemStack.
The command must automatically add the item to the next available configured usable slot inside that section.
Example:
Section:
```text
Gear
Slots: 8
```
If there are currently 3 items, the new item should be placed in the next available usable position.
---
# BUY PRICE FORMAT β ECONOMYSHOPGUI STYLE
The `` argument must support these values:
```text
100
1000
50.5
-1
```
Examples:
```text
/bshop addhanditem gear 100 50
```
Buy price:
```text
100
```
Sell price:
```text
50
```
---
# PRICE VALUE `-1`
The value:
```text
-1
```
must mean:
```text
DISABLED / NOT AVAILABLE
```
Example:
```text
/bshop addhanditem gear 100 -1
```
Means:
```text
Buy price = 100
Sell price = disabled
```
Example:
```text
/bshop addhanditem gear -1 50
```
Means:
```text
Buy price = disabled
Sell price = 50
```
Example:
```text
/bshop addhanditem gear -1 -1
```
Must be rejected because the item cannot be bought or sold.
---
# PRICE VALIDATION
Allow:
```text
-1
0.01
1
10
100
1000
5000.50
```
Reject:
```text
-2
-100
invalid text
NaN
Infinity
```
Only `-1` is allowed as a special disabled price.
All other prices must be zero or greater according to the configured economy rules.
---
# BUY AND SELL CLICK SYSTEM
Each shop item can have both a buy price and sell price.
Example:
```text
Buy: 100
Sell: 50
```
Click behavior:
```text
LEFT CLICK = BUY
RIGHT CLICK = SELL
```
Example:
```text
Left Click
```
Player buys one item using the configured Buy Price.
```text
Right Click
```
Player sells one matching item using the configured Sell Price.
If Buy Price is:
```text
-1
```
Buying must be disabled.
If Sell Price is:
```text
-1
```
Selling must be disabled.
---
# ITEM LORE
Every shop item should automatically display its configured prices.
Example:
```text
&7Left Click to Buy
&aBuy Price: $100
&7Right Click to Sell
&cSell Price: $50
```
If buying is disabled:
```text
&cBuying Disabled
```
If selling is disabled:
```text
&cSelling Disabled
```
The original item name and lore must be preserved as much as possible.
---
# SELL GUI
The player command:
```text
/sell
```
must open the BossShop Sell GUI.
There must be NO `/sellgui`.
The Sell GUI should check items against the configured sell prices stored by `/bshop addhanditem`.
If a player places a matching configured item inside `/sell`:
- The item is sold.
- The player receives the configured sell price.
If the item does not have a valid sell price or has:
```text
sellprice = -1
```
the item must NOT be sold.
It must be safely returned to the player.
---
# ITEM MATCHING
Items should be matched safely.
By default match:
- Material
- Custom name
- Lore
- Enchantments
- Custom Model Data
- Important ItemMeta
This is important so custom items do not accidentally sell as normal vanilla items.
---
# DELETE ITEM COMMAND
Add the exact command:
```text
/bshop deleteitem
```
Example:
```text
/bshop deleteitem gear DiamondSword
```
This must:
- Remove the item from the section.
- Remove its buy configuration.
- Remove its sell configuration.
- Free the item slot.
- Save changes immediately.
IMPORTANT:
Use `/bshop deleteitem`, because the main admin command for BossShop is `/bshop`.
Do not use `/eshop deleteitem` unless an additional `/eshop` alias is intentionally required.
---
# ITEM NAME REQUIREMENT
The item name used for:
```text
/bshop deleteitem
```
should be stored as a unique internal ID when the item is added.
If multiple items of the same material are added, the plugin must generate or manage unique IDs safely.
Example:
```text
DiamondSword
DiamondSword_2
DiamondSword_3
```
Tab completion should suggest the correct item IDs.
---
# COMMAND TREE
The final exact command structure must be:
```text
/shop
/sell
/bshop help
/bshop reload
/bshop addsection
/bshop deletesection
/bshop addhanditem
/bshop deleteitem
```
Do not rename:
```text
/sell
```
to:
```text
/sellgui
```
---
# TAB COMPLETION
`/bshop` should suggest:
```text
help
reload
addsection
deletesection
addhanditem
deleteitem
```
For section arguments, show existing sections.
For:
```text
/bshop deleteitem
```
suggest items inside that section.
---
# FILE STRUCTURE
The plugin folder must contain at minimum:
```text
plugins/
βββ BossShop/
βββ shop.yml
βββ sell.yml
```
`shop.yml` stores:
- Sections
- Section icon/showitem
- Prefix
- Configured slots
- Shop items
- Buy prices
- Sell prices
`sell.yml` may store sell matching/index information if required by the implementation.
On a fresh installation, no default shop sections or items should be added automatically.
---
# EXAMPLE DATA
Example command:
```text
/bshop addsection gear DIAMOND_CHESTPLATE &a 8
```
Creates:
```text
Section: gear
Display Name: &aGear
Icon: DIAMOND_CHESTPLATE
Usable Slots: 8
```
Then:
```text
/bshop addhanditem gear 100 50
```
Adds the item currently held by the admin.
Result:
```text
Buy Price: 100
Sell Price: 50
```
Another example:
```text
/bshop addhanditem gear 100 -1
```
Result:
```text
Buy Enabled
Sell Disabled
```
Another example:
```text
/bshop addhanditem gear -1 50
```
Result:
```text
Buy Disabled
Sell Enabled
```
---
# SECURITY REQUIREMENTS
Prevent:
- Item duplication.
- Money duplication.
- Shift-click exploits.
- Number-key exploits.
- Drag exploits.
- Double-click exploits.
- Taking black glass panes.
- Taking section icons.
- Invalid section slot access.
- Adding more items than configured section slots.
- Negative prices except `-1`.
- Invalid economy transactions.
- Inventory desynchronization.
- Item loss.
All GUI interactions must be validated.
---
# ECONOMY
Use Vault for the economy system.
Check that:
- Vault is installed.
- An economy provider exists.
- Withdraw/deposit succeeds.
Never remove an item or money unless the transaction is successful.
---
# FINAL REQUIREMENT
Generate the complete working source code and modify the existing plugin instead of creating an unrelated command system.
The GUI must match these core requirements:
```text
MAIN SHOP:
3 ROWS
27 TOTAL SLOTS
EMPTY SLOTS = BLACK_STAINED_GLASS_PANE
SECTION:
EXACTLY THE NUMBER OF USABLE SLOTS SPECIFIED
Example: slots 8 = exactly 8 usable item positions
PLAYER COMMANDS:
/shop
/sell
ADMIN COMMAND:
/bshop
```
Final command tree:
```text
/bshop addsection
/bshop deletesection
/bshop addhanditem
/bshop deleteitem
```
The plugin must compile without errors and all changes must persist after restart.
Create the Vault-backed BossShop plugin foundation and persistent
shop.yml/sell.ymlstorage.Implement
/shop,/sell, and permission-protected/bshopwith tab completion.Build secured 27-slot main/section/sell inventories with black-pane backgrounds and exact usable section slots.
Add validated buying, selling, item matching, and safe transaction handling.
Created the complete BossShop plugin source.
Vault-backed economy with transaction-success validation.
/shop,/sell, and admin-only/bshopcommand tree with tab completion.27-slot main shop with protected black-glass background.
Exact configured section item capacityβno slot rounding.
Secure buy/sell interactions, sell GUI, item metadata matching, and protected GUI actions.
Persistent
shop.ymlandsell.ymldata with no default sections or items.
package com.bossshop;
import com.bossshop.command.BossShopCommand;
import com.bossshop.command.PlayerShopCommand;
import com.bossshop.gui.ShopGuiListener;
import com.bossshop.storage.ShopStorage;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
public final class BossShopPlugin extends JavaPlugin {
@Getter
private ShopStorage shopStorage;
@Getter
private Economy economy;
@Override
public void onEnable() {
saveResource("shop.yml", false);
saveResource("sell.yml", false);
if (!setupEconomy()) {
getLogger().severe("Vault or an economy provider is unavailable. Disabling BossShop.");
getServer().getPluginManager().disablePlugin(this);
return;
}
shopStorage = new ShopStorage(this);
ShopGuiListener guiListener = new ShopGuiListener(this);
getServer().getPluginManager().registerEvents(guiListener, this);
PlayerShopCommand playerShopCommand = new PlayerShopCommand(guiListener);
getCommand("shop").setExecutor(playerShopCommand);
getCommand("sell").setExecutor(playerShopCommand);
BossShopCommand adminCommand = new BossShopCommand(this);
getCommand("bshop").setExecutor(adminCommand);
getCommand("bshop").setTabCompleter(adminCommand);
}
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> registration = getServer().getServicesManager().getRegistration(Economy.class);
if (registration == null || registration.getProvider() == null) {
return false;
}
economy = registration.getProvider();
return true;
}
}