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> <groupId>com.kiranhart</groupId>
<artifactId>AuctionHouse</artifactId> <artifactId>AuctionHouse</artifactId>
<name>AuctionHouse</name> <name>AuctionHouse</name>
<version>1.12.3</version> <version>1.12.6</version>
<description>The ultimate auction house plugin</description> <description>The ultimate auction house plugin</description>
<url>https://www.kiranhart.com</url> <url>https://www.kiranhart.com</url>
<build> <build>
@ -55,38 +55,20 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version> <version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </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> <dependency>
<groupId>com.github.MilkBowl</groupId> <groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId> <artifactId>VaultAPI</artifactId>
<version>1.7</version> <version>1.7</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>org.bukkit</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>

10
pom.xml
View File

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

View File

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

View File

@ -160,8 +160,7 @@ public class AuctionAPI {
* but does not have enough money to bid or purchase it. * but does not have enough money to bid or purchase it.
*/ */
public ItemStack createNotEnoughMoneyIcon() { public ItemStack createNotEnoughMoneyIcon() {
String[] item = Core.getInstance().getConfig().getString("guis.auctionhouse.items.not-enough-money.item").split(":"); ItemStack stack = XMaterial.matchXMaterial(Core.getInstance().getConfig().getString("guis.auctionhouse.items.not-enough-money.item")).get().parseItem();
ItemStack stack = XMaterial.matchXMaterial(item[0].toUpperCase(), Byte.parseByte(item[1])).get().parseItem();
ItemMeta meta = stack.getItemMeta(); ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("guis.auctionhouse.items.not-enough-money.name"))); meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("guis.auctionhouse.items.not-enough-money.name")));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
@ -178,8 +177,7 @@ public class AuctionAPI {
* @return the generated configuration item based on params * @return the generated configuration item based on params
*/ */
public ItemStack createConfigurationItem(String node, int activeAuctions, int expiredAuctions) { public ItemStack createConfigurationItem(String node, int activeAuctions, int expiredAuctions) {
String[] item = Core.getInstance().getConfig().getString(node + ".item").split(":"); ItemStack stack = XMaterial.matchXMaterial(Core.getInstance().getConfig().getString(node + ".item")).get().parseItem();
ItemStack stack = XMaterial.matchXMaterial(item[0].toUpperCase(), Byte.parseByte(item[1])).get().parseItem();
ItemMeta meta = stack.getItemMeta(); ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString(node + ".name"))); meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString(node + ".name")));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
@ -199,8 +197,7 @@ public class AuctionAPI {
* @return * @return
*/ */
public ItemStack createTransactionConfigItem(String node, String buyer, String seller, int startPrice, int bidincrement, int buynowprice) { 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(Core.getInstance().getConfig().getString(node + ".item")).get().parseItem();
ItemStack stack = XMaterial.matchXMaterial(rawItem[0].toUpperCase(), Byte.parseByte(rawItem[1])).get().parseItem();
ItemMeta meta = stack.getItemMeta(); ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString(node + ".name"))); meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString(node + ".name")));
List<String> lore = new ArrayList<>(); 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 AUTO_REFRESH_AUCTION_PAGES = true;
public static boolean INCREASE_AUCTION_TIME_ON_BID = true; public static boolean INCREASE_AUCTION_TIME_ON_BID = true;
public static boolean USE_SHORT_NUMBERS_ON_ITEMS = false; 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 TIME_TO_INCREASE_BY_BID = 10;
public static int DECREASE_SECONDS_BY_TICK = 5; public static int DECREASE_SECONDS_BY_TICK = 5;
@ -33,7 +34,6 @@ public class AuctionSettings {
public static int AUTO_SAVE_EVERY = 1800; public static int AUTO_SAVE_EVERY = 1800;
public static boolean DB_ENABLED = false; 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 String DB_HOST = "localhost";
public static int DB_PORT = 3306; public static int DB_PORT = 3306;
public static String DB_NAME = "auctionhouse"; 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"); DECREASE_SECONDS_BY_TICK = Core.getInstance().getConfig().getInt("settings.decrease-seconds-by-tick");
UPDATE_EVERY_TICK = Core.getInstance().getConfig().getInt("settings.update-every-tick"); UPDATE_EVERY_TICK = Core.getInstance().getConfig().getInt("settings.update-every-tick");
AUTO_SAVE_EVERY = Core.getInstance().getConfig().getInt("settings.auto-save-every"); 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"); 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"); // 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 com.kiranhart.auctionhouse.api.version.XMaterial;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -43,8 +42,7 @@ public class Receipt {
} }
public ItemStack getReceipt() { public ItemStack getReceipt() {
String[] item = Core.getInstance().getConfig().getString("receipt.item").split(":"); ItemStack stack = XMaterial.matchXMaterial(Core.getInstance().getConfig().getString("receipt.item")).get().parseItem();
ItemStack stack = XMaterial.matchXMaterial(item[0].toUpperCase(), Byte.parseByte(item[1])).get().parseItem();
ItemMeta meta = stack.getItemMeta(); ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("receipt.name"))); 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()); 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) { private static ItemStack getTransactionItem(String node) {
String[] stack = Core.getInstance().getConfig().getString("transaction.item").split(":"); ItemStack item = XMaterial.matchXMaterial(Core.getInstance().getConfig().getString("transaction.item")).get().parseItem();
ItemStack item = XMaterial.matchXMaterial(stack[0].toUpperCase(), Byte.parseByte(stack[1])).get().parseItem();
ItemMeta meta = item.getItemMeta(); 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")))); 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<>(); 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.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -67,12 +68,17 @@ public class CommandManager implements CommandExecutor {
if (args.length == 0) { if (args.length == 0) {
if (sender instanceof Player) { if (sender instanceof Player) {
Player p = (Player) sender; Player p = (Player) sender;
p.openInventory(new AuctionGUI(p).getInventory());
if (Core.getInstance().getCurrentAuctionPage().containsKey(p)) { if (Core.getInstance().getCurrentAuctionPage().containsKey(p)) {
Core.getInstance().getCurrentAuctionPage().remove(p); Core.getInstance().getCurrentAuctionPage().remove(p);
} }
Core.getInstance().getCurrentAuctionPage().put(p, 1); Core.getInstance().getCurrentAuctionPage().put(p, 1);
Inventory inventory = new AuctionGUI(p).getInventory();
p.openInventory(inventory);
} }
return true; return true;
} }

View File

@ -37,7 +37,6 @@ public class AuctionGUI implements AGUI {
public AuctionGUI(Player p) { public AuctionGUI(Player p) {
this.p = p; this.p = p;
chunks = Lists.partition(Core.getInstance().getAuctionItems(), 45);
} }
private int page = 1; private int page = 1;
@ -106,10 +105,35 @@ public class AuctionGUI implements AGUI {
AuctionItem possibleAuctionItem = null; 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;
}
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 //Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey"); String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) { for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
@ -130,6 +154,7 @@ public class AuctionGUI implements AGUI {
} }
//Set the highest bidder //Set the highest bidder
possibleAuctionItem.setHighestBidder(p.getUniqueId()); possibleAuctionItem.setHighestBidder(p.getUniqueId());
p.openInventory(new AuctionGUI(p).getInventory());
} else { } else {
//Owner cannot bid on own item. //Owner cannot bid on own item.
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BID_ON_OWN).sendPrefixedMessage(p); Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BID_ON_OWN).sendPrefixedMessage(p);
@ -144,6 +169,7 @@ public class AuctionGUI implements AGUI {
} }
//Set the highest bidder //Set the highest bidder
possibleAuctionItem.setHighestBidder(p.getUniqueId()); possibleAuctionItem.setHighestBidder(p.getUniqueId());
p.openInventory(new AuctionGUI(p).getInventory());
} }
//Increase time on bid? //Increase time on bid?
@ -156,15 +182,9 @@ public class AuctionGUI implements AGUI {
p.closeInventory(); p.closeInventory();
p.openInventory(new AuctionGUI(p).getInventory()); p.openInventory(new AuctionGUI(p).getInventory());
} }
return;
} }
} else if (e.getClick() == ClickType.RIGHT) {
/* if (AuctionSettings.USE_BIDDING_SYSTEM) {
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 //Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey"); String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) { for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
@ -190,46 +210,9 @@ public class AuctionGUI implements AGUI {
p.closeInventory(); p.closeInventory();
p.openInventory(new AuctionGUI(p).getInventory()); p.openInventory(new AuctionGUI(p).getInventory());
} }
return;
} }
} else if (e.getClick() == ClickType.MIDDLE) {
/* if (p.hasPermission(AuctionPermissions.ADMIN) || p.isOp()) {
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);
}
} else {
p.closeInventory();
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
}
} else {
//Not enough money to purchase
p.closeInventory();
p.openInventory(new AuctionGUI(p).getInventory());
}
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 //Get the key of the auction item
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey"); String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) { for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
@ -246,11 +229,21 @@ public class AuctionGUI implements AGUI {
} }
} }
} }
}
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("guis.auctionhouse.title"))); Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("guis.auctionhouse.title")));
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(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(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(48, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.previouspage", 0, 0));
@ -259,12 +252,8 @@ public class AuctionGUI implements AGUI {
inventory.setItem(51, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.transactions", 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(52, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.howtosell", 0, 0));
inventory.setItem(53, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.guide", 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; return inventory;
} }

View File

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

View File

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

View File

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