Skip to content

Commit 796cd6d

Browse files
authored
Merge pull request #16 from ez-plugins/@feature/order-only-mode
Order only mode
2 parents f34e920 + 9b0de00 commit 796cd6d

34 files changed

Lines changed: 1343 additions & 358 deletions

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [📑 Table of Contents](#-table-of-contents)
1616
- [📦 Requirements](#-requirements)
1717
- [🚀 Installation](#-installation)
18+
- [New Installation](#new-installation)
1819
- [✨ Features](#-features)
1920
- [⚙️ Configuration](#️-configuration)
2021
- [🛡️ Permissions \& Commands](#️-permissions--commands)
@@ -55,6 +56,8 @@
5556
- **NEW in 2.0**: Low-price warnings in confirmation dialogs
5657
- **NEW in 2.0**: Consolidated "My Activity" menu
5758
- Actively maintained and open source
59+
- **NEW in 2.0.1** Orders-Only Mode
60+
If you only want the Orders feature (buy orders, no auction house), set `orders-only-mode: true` in `orders-only.yml`. This disables all auction house features and enables the `/orders` and `/order` commands for players to create and manage buy orders.
5861

5962
## ⚙️ Configuration
6063
Default configuration files are generated on first run in `plugins/EzAuction/`.
@@ -73,6 +76,14 @@ After editing, reload the plugin or restart the server to apply changes.
7376

7477
## 🛡️ Permissions & Commands
7578

79+
**Orders-Only Mode Command:**
80+
81+
| Command | Description | Permission |
82+
|-----------|------------------------------------|---------------------------|
83+
| `/orders` | Open the Orders (buy orders) menu | `ezauction.auction.order` |
84+
85+
When `orders-only-mode` is enabled, all other auction commands are disabled.
86+
7687
**Main Commands:**
7788

7889
| Command | Description | Permission |

docs/configuration.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ Configuration files are generated in the `plugins/EzAuction/` directory on first
1010

1111
---
1212

13+
14+
## Orders-Only Mode (`orders-only.yml`)
15+
16+
To enable only the Orders feature (disabling all auction house functionality), create or edit `orders-only.yml`:
17+
18+
```yaml
19+
orders-only-mode: true
20+
```
21+
22+
When enabled, the `/orders` command and its `/order` alias are available for players to create and manage buy orders. All other auction commands and GUIs are disabled.
23+
24+
---
25+
1326
## Main Configuration (`config.yml`)
1427

1528
| Option | Type | Default | Description |

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.skyblockexp</groupId>
88
<artifactId>ezauction</artifactId>
9-
<version>2.0.0</version>
9+
<version>2.0.1</version>
1010
<name>EzAuction Plugin</name>
1111
<description>Standalone auction house plugin for many of your advanced auction features.</description>
1212
<packaging>jar</packaging>
@@ -144,11 +144,11 @@
144144
</resource>
145145
</resources>
146146
<plugins>
147-
<plugin>
148-
<groupId>org.apache.maven.plugins</groupId>
149-
<artifactId>maven-surefire-plugin</artifactId>
150-
<version>3.1.2</version>
151-
</plugin>
147+
<plugin>
148+
<groupId>org.apache.maven.plugins</groupId>
149+
<artifactId>maven-surefire-plugin</artifactId>
150+
<version>3.1.2</version>
151+
</plugin>
152152
<plugin>
153153
<artifactId>maven-resources-plugin</artifactId>
154154
<executions>

src/main/java/com/skyblockexp/ezauction/AuctionManager.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import com.skyblockexp.ezauction.history.AuctionTransactionHistoryService;
1616
import org.bukkit.entity.Player;
1717
import org.bukkit.inventory.ItemStack;
18+
import org.bukkit.inventory.meta.ItemMeta;
19+
import org.bukkit.ChatColor;
1820
import org.bukkit.plugin.java.JavaPlugin;
1921
import org.bukkit.scheduler.BukkitTask;
2022

@@ -26,6 +28,7 @@
2628
import com.skyblockexp.ezauction.service.AuctionExpiryService;
2729
import com.skyblockexp.ezauction.service.AuctionQueryService;
2830
import com.skyblockexp.ezauction.util.AuctionValidationUtils;
31+
import com.skyblockexp.ezauction.util.DateUtil;
2932

3033
public class AuctionManager {
3134
// Services
@@ -342,4 +345,37 @@ public long countActiveOrders() {
342345
public AuctionConfiguration getConfiguration() {
343346
return configuration;
344347
}
348+
349+
/**
350+
* Returns a list of ItemStacks representing all active orders placed by the given player.
351+
*
352+
* @param player the player whose orders to fetch
353+
* @return a list of ItemStacks for the player's active orders
354+
*/
355+
public List<ItemStack> getOpenOrdersForPlayer(Player player) {
356+
List<ItemStack> result = new ArrayList<>();
357+
if (player == null) return result;
358+
UUID buyerId = player.getUniqueId();
359+
long now = System.currentTimeMillis();
360+
for (AuctionOrder order : queryService.listActiveOrders()) {
361+
if (buyerId.equals(order.buyerId()) && order.expiryEpochMillis() > now) {
362+
ItemStack item = order.requestedItem();
363+
if (item != null) {
364+
ItemMeta meta = item.getItemMeta();
365+
List<String> lore = new ArrayList<>();
366+
lore.add(ChatColor.GOLD + "Order ID: " + order.id());
367+
lore.add(ChatColor.GRAY + "Price per Item: " + ChatColor.GOLD + order.pricePerItem());
368+
lore.add(ChatColor.GRAY + "Quantity: " + ChatColor.AQUA + order.quantity());
369+
lore.add(ChatColor.GRAY + "Total Price: " + ChatColor.GOLD + order.offeredPrice());
370+
lore.add(ChatColor.GRAY + "Expires: " + ChatColor.YELLOW + DateUtil.formatDate(order.expiryEpochMillis()));
371+
if (meta != null) {
372+
meta.setLore(lore);
373+
item.setItemMeta(meta);
374+
}
375+
result.add(item);
376+
}
377+
}
378+
}
379+
return result;
380+
}
345381
}

src/main/java/com/skyblockexp/ezauction/EzAuctionPlugin.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.skyblockexp.ezauction;
22

33
import com.skyblockexp.ezauction.bootstrap.PluginRegistry;
4+
import com.skyblockexp.ezauction.config.OrdersOnlyConfig;
45
import com.skyblockexp.ezauction.bootstrap.PluginConfigs;
56
import java.io.File;
67
import java.util.Locale;
@@ -32,6 +33,8 @@ public final class EzAuctionPlugin extends JavaPlugin {
3233

3334
public static final String DISPLAY_NAME = "EzAuction";
3435
private PluginRegistry registry;
36+
private static volatile EzAuctionPlugin instance;
37+
private static volatile PluginRegistry staticRegistry;
3538

3639
/**
3740
* Called when the plugin is enabled by the server.
@@ -43,10 +46,16 @@ public final class EzAuctionPlugin extends JavaPlugin {
4346
*/
4447
@Override
4548
public void onEnable() {
49+
instance = this;
50+
4651
logStartupHeader();
4752
ensureDefaultConfig();
53+
// Load orders-only config before registry
54+
OrdersOnlyConfig.load(this);
4855
// PluginRegistry will handle all initialization and registration
49-
registry = new PluginRegistry(this);
56+
registry = new PluginRegistry(instance);
57+
staticRegistry = registry;
58+
registry.load();
5059
registry.enableAll();
5160
getLogger().info(DISPLAY_NAME + " plugin enabled.");
5261
}
@@ -107,4 +116,27 @@ private void logStartupHeader() {
107116
getLogger().info(DISPLAY_NAME + " v" + version + " starting up.");
108117
}
109118

119+
/**
120+
* Gets the plugin's registry containing all managers and services.
121+
* @return
122+
*/
123+
public PluginRegistry getRegistry() {
124+
return registry;
125+
}
126+
127+
/**
128+
* Gets the static plugin registry (for global access).
129+
* @return
130+
*/
131+
public static PluginRegistry getStaticRegistry() {
132+
return staticRegistry;
133+
}
134+
135+
/**
136+
* Gets the singleton instance of the EzAuctionPlugin.
137+
* @return
138+
*/
139+
public static EzAuctionPlugin getInstance() {
140+
return instance;
141+
}
110142
}

src/main/java/com/skyblockexp/ezauction/bootstrap/PluginConfigs.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public final class PluginConfigs {
1616
"auction.yml",
1717
"auction-storage.yml",
1818
"messages.yml",
19+
"orders-only.yml",
1920
"messages/messages_en.yml",
2021
"messages/messages_es.yml",
2122
"messages/messages_nl.yml",

0 commit comments

Comments
 (0)