diff --git a/pom.xml b/pom.xml
index 9554169..3943c2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
ca.tweetzy
auctionhouse
- 2.31.0
+ 2.32.0
UTF-8
@@ -99,9 +99,17 @@
ca.tweetzy.core
${project.groupId}.${project.artifactId}.core
+
+ com.zaxxer.hikari
+ ${project.groupId}.${project.artifactId}.lib.hikari
+
+
+ org.slf4j
+ ${project.groupId}.${project.artifactId}.lib.slf4j
+
co.aikar.taskchain
- ${project.groupId}.${project.artifactId}.taskchain
+ ${project.groupId}.${project.artifactId}.lib.taskchain
@@ -154,7 +162,7 @@
ca.tweetzy
tweetycore
- 2.8.0
+ 2.9.0
org.projectlombok
diff --git a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java
index 00323a4..3ae27ca 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java
@@ -3,6 +3,7 @@ package ca.tweetzy.auctionhouse;
import ca.tweetzy.auctionhouse.api.UpdateChecker;
import ca.tweetzy.auctionhouse.api.hook.PlaceholderAPI;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
+import ca.tweetzy.auctionhouse.auction.AuctionStat;
import ca.tweetzy.auctionhouse.commands.*;
import ca.tweetzy.auctionhouse.database.DataManager;
import ca.tweetzy.auctionhouse.database.migrations.*;
@@ -80,6 +81,9 @@ public class AuctionHouse extends TweetyPlugin {
@Getter
private AuctionBanManager auctionBanManager;
+ @Getter
+ private AuctionStatManager auctionStatManager;
+
@Getter
private DatabaseConnector databaseConnector;
@@ -146,7 +150,8 @@ public class AuctionHouse extends TweetyPlugin {
new _5_TransactionChangeMigration(),
new _6_BigIntMigration(),
new _7_TransactionBigIntMigration(),
- new _8_ItemPerWorldMigration()
+ new _8_ItemPerWorldMigration(),
+ new _9_StatsMigration()
);
dataMigrationManager.runMigrations();
@@ -167,6 +172,9 @@ public class AuctionHouse extends TweetyPlugin {
this.auctionBanManager = new AuctionBanManager();
this.auctionBanManager.loadBans();
+ this.auctionStatManager = new AuctionStatManager();
+ this.auctionStatManager.loadStats();
+
// gui manager
this.guiManager.init();
@@ -241,6 +249,7 @@ public class AuctionHouse extends TweetyPlugin {
this.auctionItemManager.end();
this.filterManager.saveFilterWhitelist(false);
this.auctionBanManager.saveBans(false);
+ this.auctionStatManager.saveStats();
this.dataManager.close();
}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionStat.java b/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionStat.java
new file mode 100644
index 0000000..0e06890
--- /dev/null
+++ b/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionStat.java
@@ -0,0 +1,23 @@
+package ca.tweetzy.auctionhouse.auction;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: September 01 2021
+ * Time Created: 3:23 p.m.
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise
+ */
+@AllArgsConstructor
+@Getter
+@Setter
+public final class AuctionStat {
+
+ private Created created;
+ private Sold sold;
+ private Expired expired;
+ private Earned earned;
+ private Spent spent;
+}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionedItem.java b/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionedItem.java
index a8054e6..2f21dfb 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionedItem.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionedItem.java
@@ -83,6 +83,31 @@ public class AuctionedItem {
this.expiresAt = expiresAt;
}
+ public ItemStack getBidStack() {
+ ItemStack itemStack = this.item.clone();
+ itemStack.setAmount(Math.max(this.item.getAmount(), 1));
+ ItemMeta meta = itemStack.hasItemMeta() ? itemStack.getItemMeta() : Bukkit.getItemFactory().getItemMeta(itemStack.getType());
+ List lore = (meta.hasLore()) ? meta.getLore() : new ArrayList<>();
+ lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_HEADER.getStringList()));
+ lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_SELLER.getStringList().stream().map(s -> s.replace("%seller%", this.ownerName)).collect(Collectors.toList())));
+ lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_CURRENT_PRICE.getStringList().stream().map(s -> s.replace("%currentprice%", Settings.USE_SHORT_NUMBERS_ON_ITEMS.getBoolean() ? AuctionAPI.getInstance().getFriendlyNumber(this.currentPrice) : AuctionAPI.getInstance().formatNumber(this.currentPrice))).collect(Collectors.toList())));
+ lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_HIGHEST_BIDDER.getStringList().stream().map(s -> s.replace("%highestbidder%", this.highestBidder.equals(this.owner) ? AuctionHouse.getInstance().getLocale().getMessage("auction.nobids").getMessage() : this.highestBidderName)).collect(Collectors.toList())));
+
+ long[] times = AuctionAPI.getInstance().getRemainingTimeValues((this.expiresAt - System.currentTimeMillis()) / 1000);
+ lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_DETAILS_TIME_LEFT.getStringList().stream().map(s -> s
+ .replace("%remaining_days%", String.valueOf(times[0]))
+ .replace("%remaining_hours%", String.valueOf(times[1]))
+ .replace("%remaining_minutes%", String.valueOf(times[2]))
+ .replace("%remaining_seconds%", String.valueOf(times[3]))
+ ).collect(Collectors.toList())));
+
+ lore.addAll(TextUtils.formatText(Settings.AUCTION_STACK_PURCHASE_CONTROL_FOOTER.getStringList()));
+
+ meta.setLore(lore);
+ itemStack.setItemMeta(meta);
+ return itemStack;
+ }
+
public ItemStack getDisplayStack(AuctionStackType type) {
ItemStack itemStack = this.item.clone();
itemStack.setAmount(Math.max(this.item.getAmount(), 1));
diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandStatus.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandStatus.java
index 80ad387..054a761 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandStatus.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandStatus.java
@@ -1,6 +1,8 @@
package ca.tweetzy.auctionhouse.commands;
+import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
+import ca.tweetzy.auctionhouse.guis.GUIStats;
import ca.tweetzy.core.commands.AbstractCommand;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -16,15 +18,14 @@ import java.util.List;
public class CommandStatus extends AbstractCommand {
public CommandStatus() {
- super(CommandType.CONSOLE_OK, "status");
+ super(CommandType.PLAYER_ONLY, "status", "stats");
}
@Override
protected ReturnType runCommand(CommandSender sender, String... args) {
if (AuctionAPI.tellMigrationStatus(sender)) return ReturnType.FAILURE;
Player player = (Player) sender;
-
-
+ AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIStats(player));
return ReturnType.SUCCESS;
}
@@ -40,7 +41,7 @@ public class CommandStatus extends AbstractCommand {
@Override
public String getDescription() {
- return "Return plugin statistics";
+ return "Open the auction house statistics";
}
@Override
diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java b/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java
index e846f32..7c588f3 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/database/DataManager.java
@@ -18,10 +18,8 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -182,7 +180,7 @@ public class DataManager extends DataManagerAbstract {
public void getItems(Callback> callback) {
ArrayList items = new ArrayList<>();
- this.databaseConnector.connect(connection -> {
+ this.async(() -> this.databaseConnector.connect(connection -> {
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "auctions")) {
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
@@ -193,12 +191,12 @@ public class DataManager extends DataManagerAbstract {
} catch (Exception e) {
resolveCallback(callback, e);
}
- });
+ }));
}
public void getTransactions(Callback> callback) {
ArrayList transactions = new ArrayList<>();
- this.databaseConnector.connect(connection -> {
+ this.async(() -> this.databaseConnector.connect(connection -> {
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "transactions")) {
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
@@ -209,7 +207,7 @@ public class DataManager extends DataManagerAbstract {
} catch (Exception e) {
resolveCallback(callback, e);
}
- });
+ }));
}
public void insertTransaction(Transaction transaction, Callback callback) {
@@ -285,6 +283,63 @@ public class DataManager extends DataManagerAbstract {
});
}
+ public void getStats(Callback