# 📜 Player Orders

## Information

The Player Orders add-on lets players ask for items they don't have. A player picks an item, sets how many they want and what they pay for each, and the full price is held from their balance straight away. Other players deliver matching items, from their inventory or from inside shulker boxes, and are paid for every item they hand in. The buyer collects the delivered items from **My Orders**.

<figure><img src="../../.gitbook/assets/player-orders/player-orders.png" alt="" width="563"><figcaption><p>Editor (Player Orders)</p></figcaption></figure>

An order ends when it is filled, cancelled by the buyer, removed by staff, or when it runs out of time. The money still held then goes back to the buyer, who is told in chat or, when offline, on their next login. Items already delivered stay in **My Orders** until the buyer collects them, also after the order has ended. Anyone with that order's deliver menu open has it closed and is told the order has ended.

The **Enabled** button of the editor turns the add-on off without removing it. While it is off nobody can create or deliver orders, and collecting, cancelling and refunds keep working.

## Installation

To install this add-on, drag and drop the jar file into the PhoenixShop/addons folder, then restart your server.

> **Warning:**
The add-on requires the Premium edition. On Lite it refuses to load and the console names the jar to remove.

## Files

| File | What it holds |
| ---- | ------------- |
| `PhoenixShop/addons/PlayerOrders/config.yml` | The add-on settings. |
| `PhoenixShop/addons/PlayerOrders/items.yml` | The registered custom items and the items blocked in the editor. |
| `PhoenixShop/addons/PlayerOrders/translations/playerorders.translations.<lang>.yml` | The add-on messages and editor texts, under the `playerorders` section. |
| Plugin database | The orders, the money held for them, the delivered items and the refunds waiting for offline players. |

## What players can order

Players never need to own the item they order. They pick it from a list.

<figure><img src="../../.gitbook/assets/player-orders/registered-items.png" alt="" width="563"><figcaption><p>Player Orders (Custom Items)</p></figcaption></figure>

<figure><img src="../../.gitbook/assets/player-orders/blocked-items.png" alt="" width="563"><figcaption><p>Player Orders (Blocked Items)</p></figcaption></figure>

| Kind | Delivered items must be |
| ---- | ----------------------- |
| Minecraft items | The plain item: no custom name, lore, enchantments or item plugin behind it. |
| Enchanted books | A book with exactly that enchantment at that level. |
| Potions and tipped arrows | That potion type, with no custom effects. |
| Firework rockets | That flight duration, with no firework stars. |
| Item plugin items | The same PhoenixPack, PhoenixCrates, ItemsAdder, Nexo, CraftEngine, MMOItems, MythicItems, ExecutableItems, ExecutableBlocks, Slimefun or Eco item. Its stats and name don't matter. |
| Player heads | Any player head, including heads from HeadDatabase and HeadDB. Heads from other item plugins, such as crate keys, don't count. |
| Server items | Exactly like the registered item or the item sold in your shop. |

An item is never matched by its name, so a renamed item can't fill an order for something else. Damaged tools and armour are refused unless damaged items are allowed in the settings.

HeadDatabase and HeadDB heads are never listed one by one, and this can't be changed. Players order a Player Head instead. To sell one specific head, register it as a custom item.

**Server items** cover items made on your server that no item plugin knows. Every shop item that is more than a plain item and does not come from an item plugin is listed automatically. Others are registered in **Editor > Add-ons > Player Orders > Register Custom Items**, with search names so players can find them. Left-click an entry to edit its search names, which are separated by commas, and right-click it to delete it after a confirmation. Orders already placed for a deleted item stay open.

An item that a plugin hook already recognizes, such as one from PhoenixCrates, ItemsAdder or Nexo, can't be registered: the add-on refuses it with a message, because players can already order it by its plugin key. Heads from HeadDatabase and HeadDB are the exception and can be registered. Duplicate entries registered before this check are marked in their lore as a copy you can delete.

To add an item to **Register Custom Items** or **Blocked Items**, drop it from your cursor on an empty slot of the list, or shift-click it in your inventory. In **Register Custom Items**, left-clicking the green pane registers the item in your main hand. Staff with the admin permission can also block an item by pressing Q on it in the order item list. Right-click an entry in **Blocked Items** to unblock it after a confirmation. Orders already placed for a blocked item stay open.

## Placing an order

Players open the item list with `/orders create` or the **Create Order** button, left-click an item, type the amount and the price for each item, and confirm. The full price is taken at once. The order is refused when the player is at their order limit, still in the create cooldown, in a world where orders are off, cannot afford it, or asks for an amount or a price outside the limits of the settings.

The **Items** button of the list filters it by kind. A filter only shows when it holds items.

| Filter | Shows |
| ------ | ----- |
| Everything | Every item. |
| Minecraft | Minecraft items. |
| Enchanted Books | One entry for every enchantment and level. |
| Potions | Potions, splash potions, lingering potions and tipped arrows. |
| Fireworks | Firework rockets. |
| Custom | Items of every item plugin, such as PhoenixPack, ItemsAdder or Nexo. |
| Server Items | The registered custom items and the shop items. |

<figure><img src="../../.gitbook/assets/player-orders/order-items-filter.png" alt="" width="563"><figcaption><p>Order item picker (Items)</p></figcaption></figure>

The **Currency** button picks which currency the order is paid in. It starts on the first currency linked in the settings and only shows when more than one is usable.

**Search** finds items by name, and registered items also by their search names.

<figure><img src="../../.gitbook/assets/player-orders/order-search.png" alt="" width="563"><figcaption><p>Order item picker (Search)</p></figcaption></figure>

## Delivering

Players open an order from the order list, put the items in the deliver menu and confirm. The order only takes what it still needs. Matching items go to the buyer, the deliverer is paid for them straight away minus the delivery tax, and everything else is given back. Closing the menu without confirming gives every item back. Nobody can deliver to their own order.

With shulker delivery on, a single shulker box put in the menu is searched for matching items. They are taken out and the box comes back with the rest.

If the order is filled, cancelled, removed or runs out of time while the deliver menu is open, the menu closes with a message and the items are given back.

## Managing orders

**My Orders** lists a player's orders and can be filtered by active or finished. Left-click an order to collect its delivered items, or use **Collect All**. Items that don't fit in the inventory stay in the order. Right-click an active order to cancel it after a confirmation. Staff press Q on an order in the order list, or right-click it in a player's orders, to remove it after a confirmation, and the buyer is told.

## Settings

The command and its aliases are set with the other [commands](../../configurations/main-configuration.md#commands), under `player-orders`.

> **Info:**
Everything below is set in **Editor > Add-ons > Player Orders > Settings**, and saved in addons/PlayerOrders/config.yml.

| Option | What it does |
| ------ | ------------ |
| `currencies` | The currency orders are paid in. See below. |
| `order-limit` | How many active orders a player can have, from 0 to 10000. `0` means no limit. |
| `max-amount` | The most items one order can ask for, up to 1000000. |
| `min-price-each`, `max-price-each` | The lowest and highest price a player can offer for each item. The minimum has to stay above 0 and at most the maximum. |
| `expires-after` | How long an order stays open, such as `12h`, `7d`, `1w` or `1d12h`. Every order keeps the time it was created with, so changing this only affects new orders. |
| `delivery-tax` | The percent taken from what a deliverer earns, from 0 to 100. |
| `allow-damaged` | Whether damaged tools and armour can fill an order. |
| `shulker-delivery` | Whether matching items inside a delivered shulker box are taken out of it. |
| `broadcast-new-orders` | Whether new orders are announced in chat to the players who can browse orders. |
| `create-cooldown` | Seconds a player waits between two new orders, from 0 to 3600. |
| `worlds.mode` | `OFF` allows orders in every world, `WHITELIST` only in the worlds under `worlds.whitelist`, `BLACKLIST` everywhere except the worlds under `worlds.blacklist`. |
| `sources.*` | Which kinds of item players can order. See below. |
| `blocked-items` | Items nobody can order. `*` matches any text, as in `minecraft:*_spawn_egg`. It starts with items that can't be obtained or break the game, such as bedrock, command blocks, spawners, spawn eggs, written books and filled maps. Items blocked in the editor are kept in `items.yml` instead. |

The worlds setting only decides where orders can be created. Delivering, collecting and cancelling work in every world.

### Currencies

Choose which currencies orders can be paid in. The picker lists every currency of your shop, such as Vault, PhoenixCurrencies or PlayerPoints.

<figure><img src="../../.gitbook/assets/player-orders/settings-currencies.png" alt="" width="563"><figcaption><p>Player Orders (Settings > Currencies)</p></figcaption></figure>

<figure><img src="../../.gitbook/assets/player-orders/currencies-picker.png" alt="" width="563"><figcaption><p>Currencies (Money)</p></figcaption></figure>

<figure><img src="../../.gitbook/assets/player-orders/currencies-filter-all.png" alt="" width="563"><figcaption><p>Currencies (Filter: All)</p></figcaption></figure>

<figure><img src="../../.gitbook/assets/player-orders/currencies-filter-selected.png" alt="" width="563"><figcaption><p>Currencies (Filter: Selected Only)</p></figcaption></figure>

When more than one currency is chosen, the player picks one in the item picker while creating an order. It defaults to the first chosen currency that is available, and to the default currency when none is chosen or none is available. Open orders keep the currency they were created with.

### Item Sources

The **Item Sources** button holds one toggle for every kind of item players can order. A source that is turned off is left out of the item list.

<figure><img src="../../.gitbook/assets/player-orders/item-sources.png" alt="" width="563"><figcaption><p>Player Orders (Item Sources)</p></figcaption></figure>

| Source | What it lists |
| ------ | ------------- |
| Minecraft Items | Every Minecraft item that is not a book, potion or rocket variant. |
| Enchanted Books | Every enchantment at every level. |
| Potions | Every potion type, as potion, splash potion, lingering potion and tipped arrow. |
| Fireworks | Firework rockets by flight duration, from 1 to 3. |
| Item Plugins | The items of every item plugin the shop reads, except HeadDatabase and HeadDB heads, which are always left out. |
| Custom Items | The items registered in the editor. |
| Shop Items | The items sold in your shops. |

The menus are customizable in PhoenixShop/menus: `orders-browse`, `orders-mine`, `orders-create`, `orders-deliver` and the `orders-confirm-*` files. Every message is in the translation file listed above.

### Performance

These two options have no editor entry and are set in the add-on config.

```yaml
performance:
  item-cache-size: 4096
  network-sync-seconds: 5
```

`item-cache-size` is how many item icons the picker keeps ready, at least 64. A lower value saves memory, a higher one makes large item lists open faster. `network-sync-seconds` is explained under Networks.

## Networks

With the PhoenixShop Network add-on installed and the shop on MySQL, several servers share the same player orders. Every change to an order is checked against the database, so two servers can never pay out, refund or deliver the same order twice. A payout is paid once, on whichever server pays it first.

Each server reads the changes of the others every few seconds (`network-sync-seconds`, from 1 to 300, default 5). New orders show up on the other servers within that time, and a payout earned on another server is paid while the player is online here. On SQLite or without the Network add-on, orders belong to one server.

## Commands

`/order` and `/playerorders` work as aliases.

| Command | Description |
| ------- | ----------- |
| `/orders` | Opens every open order. |
| `/orders create` | Opens the item list to create an order. |
| `/orders mine` | Opens your orders and the items delivered to you. |
| `/orders search <item>` | Opens the orders that match an item or buyer name. |
| `/orders list [player]` | Lists the open orders with their id, or every order of one player. Shows the first 15. |
| `/orders view <player>` | Opens the orders of one player, where staff can remove them. Use the exact name or the UUID. |
| `/orders cancel <order> [confirm]` | Cancels one open order by its id and gives the buyer the money back. Without `confirm` it only shows what it would do. |
| `/orders purge expired [confirm]` | Ends every open order whose own time has run out and refunds its buyer. Delivered items stay ready to collect. Without `confirm` it only says how many it would end. |
| `/orders reload` | Reloads the add-on. |

The last five need the admin permission.

## Permissions

| Permission | What it allows |
| ---------- | -------------- |
| `phoenixshop.orders.use` | Browsing orders and collecting delivered items. |
| `phoenixshop.orders.create` | Creating orders. |
| `phoenixshop.orders.deliver` | Delivering to other players' orders. |
| `phoenixshop.orders.admin` | Removing any order, blocking items, and the staff commands. |
| `phoenixshop.orders.limit.<number>` | Raises the active order limit to that number. `unlimited` or `*` removes it. |

The first three are given to everyone by default. The admin permission is for operators.

Source: https://www.phoenixplugins.com/docs/phoenix-shop/add-ons/player-orders