mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-22 05:25:11 +01:00
1.16 Support
This commit is contained in:
parent
8ddaa2b88a
commit
cb86eafb05
@ -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,39 +55,21 @@
|
|||||||
<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>
|
|
||||||
<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>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
10
pom.xml
10
pom.xml
@ -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>
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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<>();
|
||||||
|
@ -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");
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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());
|
||||||
|
@ -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<>();
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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,22 +105,62 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
//Get the key of the auction item
|
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getBuyNowPrice())) {
|
||||||
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
|
//Check if the person who clicked is the owner
|
||||||
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
|
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
|
||||||
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
|
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
|
//Check if player has enough money to bid
|
||||||
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement())) {
|
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement())) {
|
||||||
//Check if the person who clicked is the owner
|
//Check if the person who clicked is the owner
|
||||||
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
|
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
|
||||||
//can the owner bid on their own item?
|
//can the owner bid on their own item?
|
||||||
if (AuctionSettings.OWNER_CAN_BID_ON_OWN) {
|
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
|
//Update the price
|
||||||
possibleAuctionItem.setCurrentPrice(possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement());
|
possibleAuctionItem.setCurrentPrice(possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement());
|
||||||
//Alert the previous bidder someone has a higher bid than them
|
//Alert the previous bidder someone has a higher bid than them
|
||||||
@ -130,119 +169,64 @@ public class AuctionGUI implements AGUI {
|
|||||||
}
|
}
|
||||||
//Set the highest bidder
|
//Set the highest bidder
|
||||||
possibleAuctionItem.setHighestBidder(p.getUniqueId());
|
possibleAuctionItem.setHighestBidder(p.getUniqueId());
|
||||||
} else {
|
p.openInventory(new AuctionGUI(p).getInventory());
|
||||||
//Owner cannot bid on own item.
|
|
||||||
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BID_ON_OWN).sendPrefixedMessage(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Increase time on bid?
|
||||||
|
if (AuctionSettings.INCREASE_AUCTION_TIME_ON_BID) {
|
||||||
|
possibleAuctionItem.setTime(possibleAuctionItem.getTime() + AuctionSettings.TIME_TO_INCREASE_BY_BID);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//Clicked user is not the original owner
|
//Not enough money to bid
|
||||||
//Update the price
|
p.closeInventory();
|
||||||
possibleAuctionItem.setCurrentPrice(possibleAuctionItem.getCurrentPrice() + possibleAuctionItem.getBidIncrement());
|
p.openInventory(new AuctionGUI(p).getInventory());
|
||||||
//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());
|
} else if (e.getClick() == ClickType.RIGHT) {
|
||||||
}
|
if (AuctionSettings.USE_BIDDING_SYSTEM) {
|
||||||
//Set the highest bidder
|
//Get the key of the auction item
|
||||||
possibleAuctionItem.setHighestBidder(p.getUniqueId());
|
String auctionItemKey = NBTEditor.getString(clicked, "AuctionItemKey");
|
||||||
|
for (AuctionItem auctionItem : Core.getInstance().getAuctionItems()) {
|
||||||
|
if (auctionItem.getKey().equalsIgnoreCase(auctionItemKey)) possibleAuctionItem = auctionItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Increase time on bid?
|
if (Core.getInstance().getEconomy().hasBalance(p, possibleAuctionItem.getBuyNowPrice())) {
|
||||||
if (AuctionSettings.INCREASE_AUCTION_TIME_ON_BID) {
|
|
||||||
possibleAuctionItem.setTime(possibleAuctionItem.getTime() + AuctionSettings.TIME_TO_INCREASE_BY_BID);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
//Check if the person who clicked is the owner
|
||||||
//Not enough money to bid
|
if (possibleAuctionItem.getOwner().equals(p.getUniqueId())) {
|
||||||
p.closeInventory();
|
if (AuctionSettings.OWNER_CAN_PURCHASE_OWN) {
|
||||||
p.openInventory(new AuctionGUI(p).getInventory());
|
p.closeInventory();
|
||||||
}
|
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
|
||||||
|
} else {
|
||||||
return;
|
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BUY_OWN).sendPrefixedMessage(p);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
/*
|
|
||||||
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) {
|
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
|
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
|
||||||
} else {
|
|
||||||
Core.getInstance().getLocale().getMessage(AuctionLang.CANT_BUY_OWN).sendPrefixedMessage(p);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
//Not enough money to purchase
|
||||||
p.closeInventory();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
if (AuctionAPI.getInstance().availableSlots(p.getInventory()) == 0) {
|
||||||
Perform the proper steps if the user left clicks (Without the bid system)
|
p.getWorld().dropItem(p.getLocation(), possibleAuctionItem.getItem());
|
||||||
*/
|
|
||||||
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 {
|
} else {
|
||||||
p.closeInventory();
|
p.getInventory().addItem(possibleAuctionItem.getItem());
|
||||||
p.openInventory(new ConfirmationGUI(possibleAuctionItem).getInventory());
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//Not enough money to purchase
|
Core.getInstance().getAuctionItems().remove(possibleAuctionItem);
|
||||||
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
|
|
||||||
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() {
|
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")));
|
||||||
|
|
||||||
inventory.setItem(45, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.yourauctions", new AuctionPlayer(p).getTotalActiveAuctions(), 0));
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(Core.getInstance(), () -> {
|
||||||
inventory.setItem(46, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.collectionbin", 0, new AuctionPlayer(p).getTotalExpiredAuctions()));
|
chunks = Lists.partition(Core.getInstance().getAuctionItems(), 45);
|
||||||
inventory.setItem(48, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.previouspage", 0, 0));
|
|
||||||
inventory.setItem(49, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.refresh", 0, 0));
|
//Pagination
|
||||||
inventory.setItem(50, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.nextpage", 0, 0));
|
if (chunks.size() != 0) {
|
||||||
inventory.setItem(51, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.transactions", 0, 0));
|
List<AuctionItem> sorted = chunks.get(getPage() - 1);
|
||||||
inventory.setItem(52, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.howtosell", 0, 0));
|
chunks.get(getPage() - 1).forEach(item -> inventory.setItem(inventory.firstEmpty(), item.getAuctionStack(AuctionItem.AuctionItemType.MAIN)));
|
||||||
inventory.setItem(53, AuctionAPI.getInstance().createConfigurationItem("guis.auctionhouse.items.guide", 0, 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(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;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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());
|
||||||
transaction.saveTransaction();
|
|
||||||
|
if (AuctionSettings.SAVE_TRANSACTIONS) {
|
||||||
|
transaction.saveTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
auctionItem.setTime(0);
|
auctionItem.setTime(0);
|
||||||
Core.getInstance().getAuctionItems().remove(auctionItem);
|
Core.getInstance().getAuctionItems().remove(auctionItem);
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
|
@ -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());
|
||||||
transaction.saveTransaction();
|
if (AuctionSettings.SAVE_TRANSACTIONS) {
|
||||||
|
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());
|
||||||
transaction.saveTransaction();
|
if (AuctionSettings.SAVE_TRANSACTIONS) {
|
||||||
|
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
|
||||||
|
@ -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 ========"
|
||||||
|
Loading…
Reference in New Issue
Block a user