1.16 Support

This commit is contained in:
Kiran Hart 2020-07-09 11:46:19 -04:00
parent 8ddaa2b88a
commit cb86eafb05
14 changed files with 1305 additions and 1162 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.kiranhart</groupId>
<artifactId>AuctionHouse</artifactId>
<name>AuctionHouse</name>
<version>1.12.3</version>
<version>1.12.6</version>
<description>The ultimate auction house plugin</description>
<url>https://www.kiranhart.com</url>
<build>
@ -55,39 +55,21 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>commons-lang</artifactId>
<groupId>commons-lang</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>gson</artifactId>
<groupId>com.google.code.gson</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>org.bukkit</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

10
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>com.kiranhart</groupId>
<artifactId>AuctionHouse</artifactId>
<version>1.12.3</version>
<version>1.12.6</version>
<packaging>jar</packaging>
<name>AuctionHouse</name>
@ -69,13 +69,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -25,8 +25,8 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
public final class Core extends JavaPlugin {
@ -43,7 +43,7 @@ public final class Core extends JavaPlugin {
private Economy economy;
private Locale locale;
private ArrayList<AuctionItem> auctionItems;
private LinkedList<AuctionItem> auctionItems;
private Map<Player, Integer> currentAuctionPage;
private ConfigWrapper transactions;
@ -102,7 +102,7 @@ public final class Core extends JavaPlugin {
console.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&6AuctionHouse&8]&a Loading Settings"));
auctionSettings = new AuctionSettings();
auctionItems = new ArrayList<>();
auctionItems = new LinkedList<>();
console.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&6AuctionHouse&8]&a Setting up command system"));
commandManager = new CommandManager();
@ -216,7 +216,7 @@ public final class Core extends JavaPlugin {
return auctionSettings;
}
public ArrayList<AuctionItem> getAuctionItems() {
public LinkedList<AuctionItem> getAuctionItems() {
return auctionItems;
}

View File

@ -160,8 +160,7 @@ public class AuctionAPI {
* but does not have enough money to bid or purchase it.
*/
public ItemStack createNotEnoughMoneyIcon() {
String[] item = Core.getInstance().getConfig().getString("guis.auctionhouse.items.not-enough-money.item").split(":");
ItemStack stack = XMaterial.matchXMaterial(item[0].toUpperCase(), Byte.parseByte(item[1])).get().parseItem();
ItemStack stack = XMaterial.matchXMaterial(Core.getInstance().getConfig().getString("guis.auctionhouse.items.not-enough-money.item")).get().parseItem();
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("guis.auctionhouse.items.not-enough-money.name")));
List<String> lore = new ArrayList<>();
@ -178,8 +177,7 @@ public class AuctionAPI {
* @return the generated configuration item based on params
*/
public ItemStack createConfigurationItem(String node, int activeAuctions, int expiredAuctions) {
String[] item = Core.getInstance().getConfig().getString(node + ".item").split(":");
ItemStack stack = XMaterial.matchXMaterial(item[0].toUpperCase(), Byte.parseByte(item[1])).get().parseItem();
ItemStack stack = XMaterial.matchXMaterial(Core.getInstance().getConfig().getString(node + ".item")).get().parseItem();
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString(node + ".name")));
List<String> lore = new ArrayList<>();
@ -199,8 +197,7 @@ public class AuctionAPI {
* @return
*/
public ItemStack createTransactionConfigItem(String node, String buyer, String seller, int startPrice, int bidincrement, int buynowprice) {
String[] rawItem = Core.getInstance().getConfig().getString(node + ".item").split(":");
ItemStack stack = XMaterial.matchXMaterial(rawItem[0].toUpperCase(), Byte.parseByte(rawItem[1])).get().parseItem();
ItemStack stack = XMaterial.matchXMaterial(Core.getInstance().getConfig().getString(node + ".item")).get().parseItem();
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString(node + ".name")));
List<String> lore = new ArrayList<>();

View File

@ -26,6 +26,7 @@ public class AuctionSettings {
public static boolean AUTO_REFRESH_AUCTION_PAGES = true;
public static boolean INCREASE_AUCTION_TIME_ON_BID = true;
public static boolean USE_SHORT_NUMBERS_ON_ITEMS = false;
public static boolean SAVE_TRANSACTIONS = true;
public static int TIME_TO_INCREASE_BY_BID = 10;
public static int DECREASE_SECONDS_BY_TICK = 5;
@ -33,7 +34,6 @@ public class AuctionSettings {
public static int AUTO_SAVE_EVERY = 1800;
public static boolean DB_ENABLED = false;
// public static boolean ATTEMPT_TO_CREATE_DB_TABLES_ON_START = true;
public static String DB_HOST = "localhost";
public static int DB_PORT = 3306;
public static String DB_NAME = "auctionhouse";
@ -60,6 +60,7 @@ public class AuctionSettings {
DECREASE_SECONDS_BY_TICK = Core.getInstance().getConfig().getInt("settings.decrease-seconds-by-tick");
UPDATE_EVERY_TICK = Core.getInstance().getConfig().getInt("settings.update-every-tick");
AUTO_SAVE_EVERY = Core.getInstance().getConfig().getInt("settings.auto-save-every");
SAVE_TRANSACTIONS = Core.getInstance().getConfig().getBoolean("settings.save-transactions");
DB_ENABLED = Core.getInstance().getConfig().getBoolean("database.enabled");
// ATTEMPT_TO_CREATE_DB_TABLES_ON_START = Core.getInstance().getConfig().getBoolean("database.attempt-table-creation-on-start");

View File

@ -12,7 +12,6 @@ import com.kiranhart.auctionhouse.api.version.NBTEditor;
import com.kiranhart.auctionhouse.api.version.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -43,8 +42,7 @@ public class Receipt {
}
public ItemStack getReceipt() {
String[] item = Core.getInstance().getConfig().getString("receipt.item").split(":");
ItemStack stack = XMaterial.matchXMaterial(item[0].toUpperCase(), Byte.parseByte(item[1])).get().parseItem();
ItemStack stack = XMaterial.matchXMaterial(Core.getInstance().getConfig().getString("receipt.item")).get().parseItem();
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("receipt.name")));
List<String> lore = Core.getInstance().getConfig().getStringList("receipt.lore").stream().map(node -> ChatColor.translateAlternateColorCodes('&', node.replace("{time}", time).replace("{date}", date).replace("{price}", NumberFormat.getInstance().format(total)).replace("{seller}", Bukkit.getOfflinePlayer(seller).getName()))).collect(Collectors.toList());

View File

@ -95,8 +95,7 @@ public class Transaction {
}
private static ItemStack getTransactionItem(String node) {
String[] stack = Core.getInstance().getConfig().getString("transaction.item").split(":");
ItemStack item = XMaterial.matchXMaterial(stack[0].toUpperCase(), Byte.parseByte(stack[1])).get().parseItem();
ItemStack item = XMaterial.matchXMaterial(Core.getInstance().getConfig().getString("transaction.item")).get().parseItem();
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("transaction.name").replace("{transaction_id}", Core.getInstance().getTransactions().getConfig().getString("transactions." + node + ".auction-id"))));
List<String> lore = new ArrayList<>();

View File

@ -10,6 +10,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.ArrayList;
import java.util.Arrays;
@ -67,12 +68,17 @@ public class CommandManager implements CommandExecutor {
if (args.length == 0) {
if (sender instanceof Player) {
Player p = (Player) sender;
p.openInventory(new AuctionGUI(p).getInventory());
if (Core.getInstance().getCurrentAuctionPage().containsKey(p)) {
Core.getInstance().getCurrentAuctionPage().remove(p);
}
Core.getInstance().getCurrentAuctionPage().put(p, 1);
Inventory inventory = new AuctionGUI(p).getInventory();
p.openInventory(inventory);
}
return true;
}

View File

@ -37,7 +37,6 @@ public class AuctionGUI implements AGUI {
public AuctionGUI(Player p) {
this.p = p;
chunks = Lists.partition(Core.getInstance().getAuctionItems(), 45);
}
private int page = 1;
@ -106,22 +105,62 @@ public class AuctionGUI implements AGUI {
AuctionItem possibleAuctionItem = null;
/*
Perform the proper steps if the user left-clicks (using bid system)
Perform the proper steps if the user left clicks (Without the bid system)
*/
if (e.getClick() == ClickType.LEFT && AuctionSettings.USE_BIDDING_SYSTEM) {
if (e.getClick() == ClickType.LEFT) {
if (!AuctionSettings.USE_BIDDING_SYSTEM) {
//Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
}
//Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
}
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getBuyNowPrice())) {
//Check if the person who clicked is the owner
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
if (AuctionSettings.OWNER_CAN_PURCHASE_OWN) {
p.closeInventory();
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
} else {
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BUY_OWN).sendPrefixedMessage(p);
}
} else {
p.closeInventory();
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
}
} else {
//Not enough money to purchase
p.closeInventory();
p.openInventory(new AuctionGUI(p).getInventory());
}
} else {
//Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
}
//Check if player has enough money to bid
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement())) {
//Check if the person who clicked is the owner
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
//can the owner bid on their own item?
if (AuctionSettings.OWNER_CAN_BID_ON_OWN) {
//Check if player has enough money to bid
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement())) {
//Check if the person who clicked is the owner
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
//can the owner bid on their own item?
if (AuctionSettings.OWNER_CAN_BID_ON_OWN) {
//Update the price
possibleAuctionItem.setCurrentPrice(possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement());
//Alert the previous bidder someone has a higher bid than them
if (!possibleAuctionItem.getHighestBidder().equals(p.getUniqueId())) {
Core.getInstance().getLocale().getMessage(AuctionLang.OUT_BIDDED).processPlaceholder("player", p.getName()).sendPrefixedMessage(Bukkit.getOfflinePlayer(possibleAuctionItem.getHighestBidder()).getPlayer());
}
//Set the highest bidder
possibleAuctionItem.setHighestBidder(p.getUniqueId());
p.openInventory(new AuctionGUI(p).getInventory());
} else {
//Owner cannot bid on own item.
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BID_ON_OWN).sendPrefixedMessage(p);
}
} else {
//Clicked user is not the original owner
//Update the price
possibleAuctionItem.setCurrentPrice(possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement());
//Alert the previous bidder someone has a higher bid than them
@ -130,119 +169,64 @@ public class AuctionGUI implements AGUI {
}
//Set the highest bidder
possibleAuctionItem.setHighestBidder(p.getUniqueId());
} else {
//Owner cannot bid on own item.
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BID_ON_OWN).sendPrefixedMessage(p);
p.openInventory(new AuctionGUI(p).getInventory());
}
//Increase time on bid?
if (AuctionSettings.INCREASE_AUCTION_TIME_ON_BID) {
possibleAuctionItem.setTime(possibleAuctionItem.getTime() + AuctionSettings.TIME_TO_INCREASE_BY_BID);
}
} else {
//Clicked user is not the original owner
//Update the price
possibleAuctionItem.setCurrentPrice(possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement());
//Alert the previous bidder someone has a higher bid than them
if (!possibleAuctionItem.getHighestBidder().equals(p.getUniqueId())) {
Core.getInstance().getLocale().getMessage(AuctionLang.OUT_BIDDED).processPlaceholder("player", p.getName()).sendPrefixedMessage(Bukkit.getOfflinePlayer(possibleAuctionItem.getHighestBidder()).getPlayer());
}
//Set the highest bidder
possibleAuctionItem.setHighestBidder(p.getUniqueId());
//Not enough money to bid
p.closeInventory();
p.openInventory(new AuctionGUI(p).getInventory());
}
}
} else if (e.getClick() == ClickType.RIGHT) {
if (AuctionSettings.USE_BIDDING_SYSTEM) {
//Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
}
//Increase time on bid?
if (AuctionSettings.INCREASE_AUCTION_TIME_ON_BID) {
possibleAuctionItem.setTime(possibleAuctionItem.getTime() + AuctionSettings.TIME_TO_INCREASE_BY_BID);
}
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getBuyNowPrice())) {
} else {
//Not enough money to bid
p.closeInventory();
p.openInventory(new AuctionGUI(p).getInventory());
}
return;
}
/*
Perform the proper steps if the user right-clicks (using bid system)
*/
if (e.getClick() == ClickType.RIGHT && AuctionSettings.USE_BIDDING_SYSTEM) {
//Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
}
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getBuyNowPrice())) {
//Check if the person who clicked is the owner
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
if (AuctionSettings.OWNER_CAN_PURCHASE_OWN) {
//Check if the person who clicked is the owner
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
if (AuctionSettings.OWNER_CAN_PURCHASE_OWN) {
p.closeInventory();
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
} else {
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BUY_OWN).sendPrefixedMessage(p);
}
} else {
p.closeInventory();
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
} else {
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BUY_OWN).sendPrefixedMessage(p);
}
} else {
//Not enough money to purchase
p.closeInventory();
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
p.openInventory(new AuctionGUI(p).getInventory());
}
} else {
//Not enough money to purchase
p.closeInventory();
p.openInventory(new AuctionGUI(p).getInventory());
}
return;
}
} else if (e.getClick() == ClickType.MIDDLE) {
if (p.hasPermission(AuctionPermissions.ADMIN) || p.isOp()) {
//Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
}
/*
Perform the proper steps if the user left clicks (Without the bid system)
*/
if (e.getClick() == ClickType.LEFT && !AuctionSettings.USE_BIDDING_SYSTEM) {
//Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
}
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getBuyNowPrice())) {
//Check if the person who clicked is the owner
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
if (AuctionSettings.OWNER_CAN_PURCHASE_OWN) {
p.closeInventory();
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
} else {
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BUY_OWN).sendPrefixedMessage(p);
}
if (AuctionAPI.getInstance().availableSlots(p.getInventory()) == 0) {
p.getWorld().dropItem(p.getLocation(), possibleAuctionItem.getItem());
} else {
p.closeInventory();
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
p.getInventory().addItem(possibleAuctionItem.getItem());
}
} else {
//Not enough money to purchase
p.closeInventory();
p.openInventory(new AuctionGUI(p).getInventory());
Core.getInstance().getAuctionItems().remove(possibleAuctionItem);
}
return;
}
/*
Admin remove item from auction house
*/
if (e.getClick() == ClickType.MIDDLE && p.hasPermission(AuctionPermissions.ADMIN) || p.isOp()) {
//Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
}
if (AuctionAPI.getInstance().availableSlots(p.getInventory()) == 0) {
p.getWorld().dropItem(p.getLocation(), possibleAuctionItem.getItem());
} else {
p.getInventory().addItem(possibleAuctionItem.getItem());
}
Core.getInstance().getAuctionItems().remove(possibleAuctionItem);
}
}
}
@ -251,20 +235,25 @@ public class AuctionGUI implements AGUI {
public Inventory getInventory() {
Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("guis.auctionhouse.title")));
inventory.setItem(45, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.yourauctions", new AuctionPlayer(p).getTotalActiveAuctions(), 0));
inventory.setItem(46, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.collectionbin", 0, new AuctionPlayer(p).getTotalExpiredAuctions()));
inventory.setItem(48, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.previouspage", 0, 0));
inventory.setItem(49, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.refresh", 0, 0));
inventory.setItem(50, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.nextpage", 0, 0));
inventory.setItem(51, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.transactions", 0, 0));
inventory.setItem(52, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.howtosell", 0, 0));
inventory.setItem(53, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.guide", 0, 0));
Bukkit.getServer().getScheduler().runTaskAsynchronously(Core.getInstance(), () -> {
chunks = Lists.partition(Core.getInstance().getAuctionItems(), 45);
//Pagination
if (chunks.size() != 0) {
List<AuctionItem> sorted = chunks.get(getPage() - 1);
chunks.get(getPage() - 1).forEach(item -> inventory.setItem(inventory.firstEmpty(), item.getAuctionStack(AuctionItem.AuctionItemType.MAIN)));
}
inventory.setItem(45, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.yourauctions", new AuctionPlayer(p).getTotalActiveAuctions(), 0));
inventory.setItem(46, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.collectionbin", 0, new AuctionPlayer(p).getTotalExpiredAuctions()));
inventory.setItem(48, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.previouspage", 0, 0));
inventory.setItem(49, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.refresh", 0, 0));
inventory.setItem(50, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.nextpage", 0, 0));
inventory.setItem(51, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.transactions", 0, 0));
inventory.setItem(52, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.howtosell", 0, 0));
inventory.setItem(53, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.guide", 0, 0));
});
//Pagination
if (chunks.size() != 0) {
List<AuctionItem> sorted = chunks.get(getPage() - 1);
chunks.get(getPage() - 1).forEach(item -> inventory.setItem(inventory.firstEmpty(), item.getAuctionStack(AuctionItem.AuctionItemType.MAIN)));
}
return inventory;
}

View File

@ -11,6 +11,7 @@ import com.kiranhart.auctionhouse.Core;
import com.kiranhart.auctionhouse.api.AuctionAPI;
import com.kiranhart.auctionhouse.api.events.TransactionCompleteEvent;
import com.kiranhart.auctionhouse.api.statics.AuctionLang;
import com.kiranhart.auctionhouse.api.statics.AuctionSettings;
import com.kiranhart.auctionhouse.auction.AuctionItem;
import com.kiranhart.auctionhouse.auction.Transaction;
import com.kiranhart.auctionhouse.inventory.AGUI;
@ -75,7 +76,11 @@ public class ConfirmationGUI implements AGUI {
//Perform the transaction
Transaction transaction = new Transaction(Transaction.TransactionType.BOUGHT, auctionItem, p.getUniqueId(), System.currentTimeMillis());
transaction.saveTransaction();
if (AuctionSettings.SAVE_TRANSACTIONS) {
transaction.saveTransaction();
}
auctionItem.setTime(0);
Core.getInstance().getAuctionItems().remove(auctionItem);
p.closeInventory();

View File

@ -93,7 +93,10 @@ public class TickAuctionsTask extends BukkitRunnable {
//Perform the transaction
Transaction transaction = new Transaction(Transaction.TransactionType.AUCTION_WON, auctionItem, highestBidder.getPlayer().getUniqueId(), System.currentTimeMillis());
transaction.saveTransaction();
if (AuctionSettings.SAVE_TRANSACTIONS) {
transaction.saveTransaction();
}
Core.getInstance().getPm().callEvent(new TransactionCompleteEvent(transaction));
} else {
//Doesn't have enough money
@ -116,7 +119,10 @@ public class TickAuctionsTask extends BukkitRunnable {
//Perform the transaction
Transaction transaction = new Transaction(Transaction.TransactionType.AUCTION_WON, auctionItem, auctionItem.getHighestBidder(), System.currentTimeMillis());
transaction.saveTransaction();
if (AuctionSettings.SAVE_TRANSACTIONS) {
transaction.saveTransaction();
}
Core.getInstance().getPm().callEvent(new TransactionCompleteEvent(transaction));
} else {
//Doesn't have enough money

View File

@ -22,6 +22,7 @@ settings:
decrease-seconds-by-tick: 5
update-every-tick: 5
auto-save-every: 1800
save-transactions: true
help-msg:
- "&6======== &eAuction House&6 ========"