diff --git a/.idea/libraries/Maven__com_zaxxer_HikariCP_3_2_0.xml b/.idea/libraries/Maven__com_zaxxer_HikariCP_3_2_0.xml
new file mode 100644
index 0000000..8f760a2
--- /dev/null
+++ b/.idea/libraries/Maven__com_zaxxer_HikariCP_3_2_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml b/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml
index 45e8681..f731fab 100644
--- a/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml
+++ b/.idea/libraries/Maven__net_md_5_bungeecord_chat_1_12_SNAPSHOT.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml b/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml
new file mode 100644
index 0000000..20e8163
--- /dev/null
+++ b/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml b/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
index d6aca8f..2176a30 100644
--- a/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
+++ b/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/Auction House.iml b/Auction House.iml
index db7e255..a755055 100644
--- a/Auction House.iml
+++ b/Auction House.iml
@@ -35,5 +35,7 @@
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index a53700b..b743c95 100644
--- a/pom.xml
+++ b/pom.xml
@@ -87,5 +87,11 @@
1.6
provided
+
+ com.zaxxer
+ HikariCP
+ LATEST
+ compile
+
diff --git a/src/main/java/com/shadebyte/auctionhouse/Core.java b/src/main/java/com/shadebyte/auctionhouse/Core.java
index c2dc16b..b58891c 100644
--- a/src/main/java/com/shadebyte/auctionhouse/Core.java
+++ b/src/main/java/com/shadebyte/auctionhouse/Core.java
@@ -1,6 +1,8 @@
package com.shadebyte.auctionhouse;
import com.massivestats.MassiveStats;
+import com.shadebyte.auctionhouse.api.AuctionAPI;
+import com.shadebyte.auctionhouse.api.enums.Lang;
import com.shadebyte.auctionhouse.api.event.AuctionEndEvent;
import com.shadebyte.auctionhouse.auction.AuctionItem;
import com.shadebyte.auctionhouse.cmds.CommandManager;
@@ -10,7 +12,10 @@ import com.shadebyte.auctionhouse.util.Debugger;
import com.shadebyte.auctionhouse.util.Locale;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.HorseInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider;
@@ -18,6 +23,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.List;
+import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
public final class Core extends JavaPlugin {
@@ -43,22 +49,27 @@ public final class Core extends JavaPlugin {
//Storage
public List auctionItems;
+ //Timing
+ private Long startTime;
+
@Override
public void onEnable() {
// Plugin startup logic
instance = this;
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bStarted to load Auction Items from data file."));
+ startTime = System.currentTimeMillis();
+
setupEconomy();
+ initDataFiles();
//Locales
Locale.init(this);
Locale.saveDefaultLocale("en_US");
- this.locale = Locale.getLocale(this.getConfig().getString("Locale", "en_US"));
+ this.locale = Locale.getLocale(this.getConfig().getString("Locale", getConfig().getString("lang")));
settings = new Settings();
- initDataFiles();
-
commandManager = new CommandManager();
commandManager.initialize();
@@ -73,10 +84,9 @@ public final class Core extends JavaPlugin {
}
try {
-
ConfigurationSection section = data.getConfig().getConfigurationSection("active");
if (section.getKeys(false).size() != 0) {
-
+ int size = section.getKeys(false).size();
Bukkit.getServer().getScheduler().runTaskAsynchronously(this, () -> {
for (String node : section.getKeys(false)) {
int xNode = Integer.parseInt(node);
@@ -88,18 +98,23 @@ public final class Core extends JavaPlugin {
int currentPrice = data.getConfig().getInt("active." + xNode + ".currentprice");
int time = data.getConfig().getInt("active." + xNode + ".time");
String key = data.getConfig().getString("active." + xNode + ".key");
+ String highestBidder = data.getConfig().getString("active." + xNode + ".highestbidder");
- AuctionItem item = new AuctionItem(owner, stack, startPrice, bidIncrement, buyNowPrice, currentPrice, time, key);
+ AuctionItem item = new AuctionItem(owner, highestBidder, stack, startPrice, bidIncrement, buyNowPrice, currentPrice, time, key);
auctionItems.add(item);
data.getConfig().set("active." + xNode, null);
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&eLoaded Auction Item with key&f: &b" + item.getKey()));
}
data.saveConfig();
});
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&eLoaded a total of &f: &b" + size + "&e items"));
}
} catch (Exception e) {
Debugger.report(e);
}
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bAuction House finished loading, took " + (System.currentTimeMillis() - startTime) + " ms"));
+
try {
Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(this, () -> {
if (auctionItems.size() != 0) {
@@ -109,12 +124,34 @@ public final class Core extends JavaPlugin {
AuctionEndEvent auctionEndEvent = new AuctionEndEvent(auctionItem);
getServer().getPluginManager().callEvent(auctionEndEvent);
if (!auctionEndEvent.isCancelled()) {
- if (auctionItem.getHighestBidder().equalsIgnoreCase("")) {
+ if (auctionItem.getHighestBidder().equalsIgnoreCase(auctionItem.getOwner())) {
data.getConfig().set("expired." + auctionItem.getOwner() + "." + System.currentTimeMillis() + System.nanoTime(), auctionItem.getItem());
data.saveConfig();
auctionItems.remove(auctionItem);
} else {
- //TODO give highest bidder item
+ Player highestBidder = Bukkit.getPlayer(UUID.fromString(auctionItem.getHighestBidder()));
+ if (highestBidder != null) {
+ if (getEconomy().getBalance(highestBidder) < auctionItem.getCurrentPrice()) {
+ highestBidder.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NOT_ENOUGH_MONEY.getNode()));
+ data.getConfig().set("expired." + auctionItem.getOwner() + "." + System.currentTimeMillis() + System.nanoTime(), auctionItem.getItem());
+ } else {
+ highestBidder.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.AUCTION_BUY.getNode()).replace("{itemname}", auctionItem.getDisplayName()).replace("{price}", AuctionAPI.getInstance().friendlyNumber(auctionItem.getCurrentPrice())));
+ if (AuctionAPI.getInstance().availableSlots(highestBidder.getInventory()) < 1)
+ highestBidder.getWorld().dropItemNaturally(highestBidder.getLocation(), auctionItem.getItem());
+ else
+ highestBidder.getInventory().addItem(auctionItem.getItem());
+ }
+ data.saveConfig();
+ auctionItems.remove(auctionItem);
+ } else {
+ if (getEconomy().getBalance(highestBidder) < auctionItem.getCurrentPrice()) {
+ data.getConfig().set("expired." + auctionItem.getOwner() + "." + System.currentTimeMillis() + System.nanoTime(), auctionItem.getItem());
+ } else {
+ data.getConfig().set("expired." + auctionItem.getHighestBidder() + "." + System.currentTimeMillis() + System.nanoTime(), auctionItem.getItem());
+ }
+ data.saveConfig();
+ auctionItems.remove(auctionItem);
+ }
}
}
}
@@ -134,6 +171,7 @@ public final class Core extends JavaPlugin {
int node = 1;
for (AuctionItem auctionItem : auctionItems) {
data.getConfig().set("active." + node + ".owner", auctionItem.getOwner());
+ data.getConfig().set("active." + node + ".highestbidder", auctionItem.getHighestBidder());
data.getConfig().set("active." + node + ".startprice", auctionItem.getStartPrice());
data.getConfig().set("active." + node + ".bidincrement", auctionItem.getBidIncrement());
data.getConfig().set("active." + node + ".currentprice", auctionItem.getCurrentPrice());
@@ -145,7 +183,6 @@ public final class Core extends JavaPlugin {
}
data.saveConfig();
-
}
private boolean setupEconomy() {
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/AuctionAPI.java b/src/main/java/com/shadebyte/auctionhouse/api/AuctionAPI.java
index 96230ac..50b07c0 100644
--- a/src/main/java/com/shadebyte/auctionhouse/api/AuctionAPI.java
+++ b/src/main/java/com/shadebyte/auctionhouse/api/AuctionAPI.java
@@ -63,7 +63,7 @@ public class AuctionAPI {
public boolean isNumeric(String number) {
try {
- Double.parseDouble(number);
+ Integer.parseInt(number);
} catch (NumberFormatException nfe) {
Debugger.report(nfe);
return false;
@@ -98,7 +98,7 @@ public class AuctionAPI {
public String friendlyNumber(double value) {
int power;
- String suffix = " kmbt";
+ String suffix = " KMBT";
String formattedNumber = "";
NumberFormat formatter = new DecimalFormat("#,###.#");
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/enums/Lang.java b/src/main/java/com/shadebyte/auctionhouse/api/enums/Lang.java
index 963aab8..5faf8c5 100644
--- a/src/main/java/com/shadebyte/auctionhouse/api/enums/Lang.java
+++ b/src/main/java/com/shadebyte/auctionhouse/api/enums/Lang.java
@@ -13,6 +13,8 @@ public enum Lang {
PLAYERS_ONLY("playersonly"),
NOT_A_NUMBER("notanumber"),
NOT_ENOUGH_MONEY("notenoughmoney"),
+ CANNOT_BUY_OWN("cantbuyown"),
+ CANNOT_BID_OWN("cantbidonown"),
AUCTION_LISTED("auction.listed"),
AUCTION_BUY("auction.buy"),
diff --git a/src/main/java/com/shadebyte/auctionhouse/auction/AuctionItem.java b/src/main/java/com/shadebyte/auctionhouse/auction/AuctionItem.java
index 6d64f91..982f8ba 100644
--- a/src/main/java/com/shadebyte/auctionhouse/auction/AuctionItem.java
+++ b/src/main/java/com/shadebyte/auctionhouse/auction/AuctionItem.java
@@ -2,12 +2,11 @@ package com.shadebyte.auctionhouse.auction;
import com.shadebyte.auctionhouse.api.AuctionAPI;
import com.shadebyte.auctionhouse.util.NBTEditor;
+import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -32,7 +31,7 @@ public class AuctionItem {
private int time;
private String key;
- public AuctionItem(String owner, ItemStack item, int startPrice, int bidIncrement, int buyNowPrice, int currentPrice, int time, String key) {
+ public AuctionItem(String owner, String highestBidder, ItemStack item, int startPrice, int bidIncrement, int buyNowPrice, int currentPrice, int time, String key) {
this.owner = owner;
this.item = item;
this.startPrice = startPrice;
@@ -41,7 +40,7 @@ public class AuctionItem {
this.time = time;
this.currentPrice = currentPrice;
this.key = key;
- this.highestBidder = owner;
+ this.highestBidder = highestBidder;
}
public AuctionItem(String owner, ItemStack item, int time, int startPrice, int bidIncrement, int buyNowPrice) {
@@ -124,6 +123,19 @@ public class AuctionItem {
this.highestBidder = highestBidder;
}
+ public String getDisplayName() {
+ String name = key;
+ if (item.hasItemMeta()) {
+ if (item.getItemMeta().hasDisplayName())
+ name = item.getItemMeta().getDisplayName();
+ else
+ name = StringUtils.capitalize(item.getType().name().toLowerCase().replace("_", " "));
+ } else {
+ name = StringUtils.capitalize(item.getType().name().toLowerCase().replace("_", " "));
+ }
+ return name;
+ }
+
public void updateTime(int removeAmount) {
if (time - removeAmount <= 0) {
time = 0;
diff --git a/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/SellCommand.java b/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/SellCommand.java
index e6e437a..f4ef9a3 100644
--- a/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/SellCommand.java
+++ b/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/SellCommand.java
@@ -5,6 +5,7 @@ import com.shadebyte.auctionhouse.api.AuctionAPI;
import com.shadebyte.auctionhouse.api.enums.Lang;
import com.shadebyte.auctionhouse.api.enums.Permissions;
import com.shadebyte.auctionhouse.auction.AuctionItem;
+import com.shadebyte.auctionhouse.auction.AuctionPlayer;
import com.shadebyte.auctionhouse.cmds.SubCommand;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -37,11 +38,38 @@ public class SellCommand extends SubCommand {
return;
}
+ if (args.length == 2) {
+ if (AuctionAPI.getInstance().isNumeric(args[1])) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.CMD_SELL.getNode()));
+ } else {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NOT_A_NUMBER.getNode()));
+ }
+ }
+
+ if (args.length == 3) {
+ if (AuctionAPI.getInstance().isNumeric(args[1]) && AuctionAPI.getInstance().isNumeric(args[2])) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.CMD_SELL.getNode()));
+ } else {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NOT_A_NUMBER.getNode()));
+ }
+ }
+
if (args.length == 4) {
- int buyNow = Integer.parseInt(args[1]);
- int startPrice = Integer.parseInt(args[2]);
- int increment = Integer.parseInt(args[3]);
- Core.getInstance().auctionItems.add(0, new AuctionItem(p.getUniqueId().toString(), AuctionAPI.getItemInHand(p), 3600, startPrice, increment, buyNow));
+ if (AuctionAPI.getInstance().isNumeric(args[1]) && AuctionAPI.getInstance().isNumeric(args[2]) && AuctionAPI.getInstance().isNumeric(args[3])) {
+ if (new AuctionPlayer(p).hasMaximumAuctionsActive()) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.AUCTION_MAX.getNode()));
+ return;
+ }
+
+ int buyNow = Integer.parseInt(args[1]);
+ int startPrice = Integer.parseInt(args[2]);
+ int increment = Integer.parseInt(args[3]);
+ AuctionItem auctionItem = new AuctionItem(p.getUniqueId().toString(), AuctionAPI.getItemInHand(p), 3600, startPrice, increment, buyNow);
+ Core.getInstance().auctionItems.add(0, auctionItem);
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.AUCTION_LISTED.getNode()).replace("{itemname}", auctionItem.getDisplayName()).replace("{price}", AuctionAPI.getInstance().friendlyNumber(startPrice)));
+ } else {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NOT_A_NUMBER.getNode()));
+ }
}
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/AuctionGUI.java b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/AuctionGUI.java
index 9db69dd..f097320 100644
--- a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/AuctionGUI.java
+++ b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/AuctionGUI.java
@@ -3,6 +3,7 @@ package com.shadebyte.auctionhouse.inventory.inventories;
import com.google.common.collect.Lists;
import com.shadebyte.auctionhouse.Core;
import com.shadebyte.auctionhouse.api.AuctionAPI;
+import com.shadebyte.auctionhouse.api.enums.Lang;
import com.shadebyte.auctionhouse.auction.AuctionItem;
import com.shadebyte.auctionhouse.auction.AuctionPlayer;
import com.shadebyte.auctionhouse.inventory.AGUI;
@@ -76,17 +77,28 @@ public class AuctionGUI implements AGUI {
if (Core.getEconomy().getBalance(p) < item.getBidIncrement()) {
e.getClickedInventory().setItem(slot, AuctionAPI.getInstance().createConfigItem("gui.auction.items.not-enough-money", 0, 0));
- Bukkit.getServer().getScheduler().runTaskLater(Core.getInstance(), () -> {
+ Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(Core.getInstance(), () -> {
p.closeInventory();
p.openInventory(AuctionGUI.getInstance(p).getInventory());
- }, 1);
-
- // p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NOT_ENOUGH_MONEY.getNode()));
+ }, 20);
return;
}
- item.setCurrentPrice(item.getCurrentPrice() + item.getBidIncrement());
- item.setHighestBidder(p.getUniqueId().toString());
+ if (item.getOwner().equalsIgnoreCase(p.getUniqueId().toString())) {
+ if (Core.getInstance().getConfig().getBoolean("settings.owner-can-bid-own")) {
+ item.setCurrentPrice(item.getCurrentPrice() + item.getBidIncrement());
+ item.setHighestBidder(p.getUniqueId().toString());
+ } else {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.CANNOT_BID_OWN.getNode()));
+ }
+ } else {
+ item.setCurrentPrice(item.getCurrentPrice() + item.getBidIncrement());
+ item.setHighestBidder(p.getUniqueId().toString());
+ }
+
+ if (Core.getInstance().getConfig().getBoolean("settings.bid.increase-on-bid"))
+ item.setTime(item.getTime() + Core.getInstance().getConfig().getInt("settings.bid.increase-amount"));
+
p.closeInventory();
p.openInventory(AuctionGUI.getInstance(p).getInventory());
}
@@ -97,14 +109,26 @@ public class AuctionGUI implements AGUI {
if (auctionItem.getKey().equalsIgnoreCase(key)) item = auctionItem;
}
- p.closeInventory();
- p.openInventory(ConfirmationGUI.getInstance(item).getInventory());
-// p.getInventory().addItem(item.getItem());
-// item.setTime(0);
-// Core.getInstance().auctionItems.remove(item);
-//
-// p.closeInventory();
-// p.openInventory(AuctionGUI.getInstance(p).getInventory());
+ if (Core.getEconomy().getBalance(p) < item.getBuyNowPrice()) {
+ e.getClickedInventory().setItem(slot, AuctionAPI.getInstance().createConfigItem("gui.auction.items.not-enough-money", 0, 0));
+ Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(Core.getInstance(), () -> {
+ p.closeInventory();
+ p.openInventory(AuctionGUI.getInstance(p).getInventory());
+ }, 20);
+ return;
+ } else {
+ if (item.getOwner().equalsIgnoreCase(p.getUniqueId().toString())) {
+ if (Core.getInstance().getConfig().getBoolean("settings.owner-can-purchase-own")) {
+ p.closeInventory();
+ p.openInventory(ConfirmationGUI.getInstance(item).getInventory());
+ } else {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.CANNOT_BUY_OWN.getNode()));
+ }
+ } else {
+ p.closeInventory();
+ p.openInventory(ConfirmationGUI.getInstance(item).getInventory());
+ }
+ }
}
}
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ConfirmationGUI.java b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ConfirmationGUI.java
index 03e7482..e91df02 100644
--- a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ConfirmationGUI.java
+++ b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ConfirmationGUI.java
@@ -2,16 +2,18 @@ package com.shadebyte.auctionhouse.inventory.inventories;
import com.shadebyte.auctionhouse.Core;
import com.shadebyte.auctionhouse.api.AuctionAPI;
+import com.shadebyte.auctionhouse.api.enums.Lang;
import com.shadebyte.auctionhouse.auction.AuctionItem;
import com.shadebyte.auctionhouse.inventory.AGUI;
-import org.apache.commons.lang.math.IntRange;
import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
-import java.util.stream.IntStream;
+import java.util.UUID;
/**
* The current file has been created by Kiran Hart
@@ -38,16 +40,40 @@ public class ConfirmationGUI implements AGUI {
@Override
public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
e.setCancelled(true);
+ Player p = (Player) e.getWhoClicked();
+ if (clicked.isSimilar(AuctionAPI.getInstance().fill("&a&lYes", 5))) {
+ if (Core.getInstance().auctionItems.contains(auctionItem)) {
+ if (Core.getEconomy().getBalance(p) < auctionItem.getBuyNowPrice()) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NOT_ENOUGH_MONEY.getNode()));
+ } else {
+ Core.getEconomy().withdrawPlayer(p, auctionItem.getBuyNowPrice());
+ p.getInventory().addItem(auctionItem.getItem());
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.AUCTION_BUY.getNode()).replace("{itemname}", auctionItem.getDisplayName()).replace("{price}", AuctionAPI.getInstance().friendlyNumber(auctionItem.getBuyNowPrice())));
+ Player owner = Bukkit.getPlayer(UUID.fromString(auctionItem.getOwner()));
+
+ if (owner != null) {
+ owner.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.AUCTION_SOLD.getNode()).replace("{player}", p.getName()).replace("{item}", auctionItem.getDisplayName()).replace("{price}", AuctionAPI.getInstance().friendlyNumber(auctionItem.getBuyNowPrice())));
+ }
+
+ auctionItem.setTime(0);
+ Core.getInstance().auctionItems.remove(auctionItem);
+ p.closeInventory();
+ }
+ }
+ } else if (clicked.isSimilar(AuctionAPI.getInstance().fill("&c&lNo", 14))) {
+ p.closeInventory();
+ p.openInventory(AuctionGUI.getInstance(p).getInventory());
+ }
}
@Override
public void close(InventoryCloseEvent e) {
- Bukkit.getServer().getScheduler().runTaskLater(Core.getInstance(), () -> e.getPlayer().openInventory(e.getInventory()),1);
+ // Bukkit.getServer().getScheduler().runTaskLater(Core.getInstance(), () -> e.getPlayer().openInventory(e.getInventory()), 1);
}
@Override
public Inventory getInventory() {
- Inventory inventory = Bukkit.createInventory(this, 9, Core.getInstance().getConfig().getString("gui.confirm.title"));
+ Inventory inventory = Bukkit.createInventory(this, 9, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.confirm.title")));
for (int i = 0; i <= 3; i++) {
inventory.setItem(i, AuctionAPI.getInstance().fill("&a&lYes", 5));
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 0a0e3c4..671db61 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,8 +1,22 @@
+#If this file (en_US.lang) is somehow missing it will load any other valid
+#.lang file. It's safer to translate the original file change the name and
+#have it in the same locale folder, just set new lang name here.
+#Lang name formats: https://www.science.co.il/language/Locale-codes.php
+lang: "en_US"
+
settings:
default-auction-time: 3600 # 60 Minutes by default
max-auction-price: 2000000000
-
-
+ max-auction-start: 2000000000
+ max-auction-increment: 2000000000
+ min-auction-price: 25000
+ min-auction-start: 25000
+ min-auction-increment: 1
+ owner-can-purchase-own: false
+ owner-can-bid-own: false
+ bid:
+ increase-on-bid: true
+ increase-amount: 10 #10 Seconds by default
gui:
confirm:
diff --git a/src/main/resources/en_US.lang b/src/main/resources/en_US.lang
index 50497f7..10594c0 100644
--- a/src/main/resources/en_US.lang
+++ b/src/main/resources/en_US.lang
@@ -7,6 +7,8 @@ nopermission = "&cYou do not have permission to do that!"
playersonly = "&cOnly player's may use the command!"
notanumber = "&CThat isn't a valid number"
notenoughmoney = "&CYou do not have enough money!"
+cantbidonown = "&cYou cannot bid on your own item!"
+cantbuyown = "&cYou cannot buy your own item!"
auction.listed = "&eYou listed &6{itemname} &efor &a${price}"
auction.max = "&cYou cannot auction more items, please upgrade to do so."