Astral Realms Documentation Help

Actions

AstralShop registers three PaperActions in AstralShop#onEnable, one per record class in com.astralrealms.shop.action (BuyShopItemAction, SellShopItemAction, SellAllAction):

this.registerAction("buy-shop-item", BuyShopItemAction.class); this.registerAction("sell-shop-item", SellShopItemAction.class); this.registerAction("sell-all", SellAllAction.class);

All three use the plain registerAction call, not registerActionGlobally — so, unlike some other products' action sets, they resolve only inside action lists that AstralShop's own configuration loader parses: a shop item's buy-actions/sell-actions (shops/*.yml) and a menu button's actions: block (menus/*.yml, both under AstralShop's own data folder). See Shop Configuration — buy-actions and sell-actions and Menu rendering.

Every argument is declared as a PlaceholderWrapper record component and resolved with context.parseWrapper(...) when the action runs, so each one accepts a literal (wood), a placeholder (%shop_id%, %item_id%), or a mix. The action always acts on context.executor() — the player who triggered it (e.g. the one who clicked the menu slot) — there is no separate "target player" argument.

All three call straight into PaperShopService, the exact same methods backing /shop, /sellall, and /sellhand — same buyable/sellable checks, the same cancellable ShopBuyEvent/ShopSellEvent, the same per-player price modifiers, and the same EconomyService withdraw/deposit. See Overview — Buying, selling, and sell-all for the shared flow in full.

buy-shop-item

Buys amount of item-id from shop-id for the executing player.

Arg

Type

Description

shop-id

String placeholder

The shop's id. See Shop Configuration.

item-id

String placeholder

The item's key under that shop's items: map.

amount

Integer placeholder

Quantity to buy.

- "[buy-shop-item] wood oak_wood 1" - "[buy-shop-item] %shop_id% %item_id% 1" # typical use: inside a rendered shop item's own actions

Calls PaperShopService#buy(player, shopId, itemId, amount): validates buyable, computes the price through per-player modifiers, fires ShopBuyEvent, withdraws via EconomyService, then either grants the item's display stack or runs its buy-actions, depending on give-item. Depending on outcome, sends shop-not-found, item-not-buyable, inventory-full, not-enough-funds, or item-bought — see Messages — Buy.

sell-shop-item

Sells amount of item-id from shop-id, out of the executing player's inventory.

Arg

Type

Description

shop-id

String placeholder

The shop's id.

item-id

String placeholder

The item's key under that shop's items: map.

amount

Integer placeholder

Quantity to sell.

- "[sell-shop-item] wood oak_wood 1" - "[sell-shop-item] %shop_id% %item_id% 1"

Calls PaperShopService#sell(player, shopId, itemId, amount) (the notifying overload — same as a direct player sell): validates sellable and that the player holds at least amount, computes the price, fires ShopSellEvent, deposits via EconomyService, removes the items, and always runs the item's sell-actions if present. Sends shop-not-found, item-not-sellable, not-enough-items, or item-sold — see Messages — Sell.

sell-all

Sells every sellable item the executing player holds, scoped to one shop.

Arg

Type

Description

shop-id

String placeholder

The shop to sweep.

- "[sell-all] wood" - "[sell-all] %shop_id%"

Calls PaperShopService#sellAll(player, shopId) — the shop-scoped overload, distinct from the no-arg sellAll(player) overload behind /sellall, which sweeps every loaded shop instead of one (see Commands — /sellall). Each matching item sells silently (no per-item message); once every sale settles, one combined sold-all-items message reports the total, or nothing-to-sell if the player held nothing sellable in that shop. See Messages — Sell All/Hand.

Wiring example: a shop menu item

The intended home for these three is a rendered shop item's actions: block — the same pattern shown in Placeholders — How these are wired:

items: shop-item-slots: slots: [10, 11, 12, 13, 14, 15, 16] taints: - "shop-item" copy-from: "%item_display%" lore: - "<gray>Buy: <gold>%item_buyPrice%" - "<gray>Sell: <gold>%item_sellPrice%" actions: LEFT: - "[buy-shop-item] %shop_id% %item_id% 1" RIGHT: - "[sell-shop-item] %shop_id% %item_id% 1"

None of the three actions check a permission node themselves — gate who can click a wired button through the menu item's own view-requirements/ click requirements, not the action.

Action Summary Table

ID

Arguments

Effect

buy-shop-item

shop-id item-id amount

Buys amount of item-id from shop-id for the executor.

sell-shop-item

shop-id item-id amount

Sells amount of item-id from shop-id, out of the executor's inventory.

sell-all

shop-id

Sells every sellable item the executor holds, scoped to that one shop.

See also

  • Overview — Buying, selling, and sell-all — the shared buy/sell/sell-all flow these actions trigger.

  • Shop Configurationshop-id/item-id come from a shop's id and its items: map keys.

  • Commands/shop, /sellall, /sellhand, the command-driven equivalents.

  • Messages — the full text and placeholders for every message these actions can send.

  • Placeholders%shop_id%/%item_id%, typically used as these actions' arguments.

  • Developer APIShopBuyEvent/ShopSellEvent, fired before every buy/sell these actions trigger.

Last modified: 25 July 2026