diff --git a/.idea/artifacts/AuctionHouse_jar.xml b/.idea/artifacts/AuctionHouse_jar.xml
new file mode 100644
index 0000000..4e49fbc
--- /dev/null
+++ b/.idea/artifacts/AuctionHouse_jar.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/artifacts/Auction_House_jar.xml b/.idea/artifacts/Auction_House_jar.xml
deleted file mode 100644
index 6da4101..0000000
--- a/.idea/artifacts/Auction_House_jar.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- $USER_HOME$/Desktop/Plugin Testing/Pepper API/plugins
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index d23209c..a677b49 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -6,11 +6,12 @@
-
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..f64e7d6
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_github_kevinsawicki_http_request_6_0.xml b/.idea/libraries/Maven__com_github_kevinsawicki_http_request_6_0.xml
new file mode 100644
index 0000000..e7bc56d
--- /dev/null
+++ b/.idea/libraries/Maven__com_github_kevinsawicki_http_request_6_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_zaxxer_HikariCP_3_2_0.xml b/.idea/libraries/Maven__com_zaxxer_HikariCP_3_2_0.xml
deleted file mode 100644
index 8f760a2..0000000
--- a/.idea/libraries/Maven__com_zaxxer_HikariCP_3_2_0.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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 f731fab..a472890 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_projectlombok_lombok_1_16_12.xml b/.idea/libraries/Maven__org_projectlombok_lombok_1_16_12.xml
new file mode 100644
index 0000000..0efd40f
--- /dev/null
+++ b/.idea/libraries/Maven__org_projectlombok_lombok_1_16_12.xml
@@ -0,0 +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
deleted file mode 100644
index 20e8163..0000000
--- a/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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 2176a30..42f0d6f 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/.idea/modules.xml b/.idea/modules.xml
index cdfd61a..06291b3 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/Auction House.iml b/Auction House.iml
index a755055..7a4acff 100644
--- a/Auction House.iml
+++ b/Auction House.iml
@@ -36,6 +36,6 @@
-
+
\ No newline at end of file
diff --git a/auctionhouse.iml b/auctionhouse.iml
new file mode 100644
index 0000000..d989abc
--- /dev/null
+++ b/auctionhouse.iml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+ SPIGOT
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index b743c95..6c41f2b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,10 +88,15 @@
provided
- com.zaxxer
- HikariCP
- LATEST
- compile
+ org.projectlombok
+ lombok
+ 1.16.12
+ provided
+
+
+ com.github.kevinsawicki
+ http-request
+ 6.0
diff --git a/src/main/java/com/shadebyte/auctionhouse/Core.java b/src/main/java/com/shadebyte/auctionhouse/Core.java
index b58891c..4d50b85 100644
--- a/src/main/java/com/shadebyte/auctionhouse/Core.java
+++ b/src/main/java/com/shadebyte/auctionhouse/Core.java
@@ -4,24 +4,30 @@ 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.api.event.AuctionStartEvent;
+import com.shadebyte.auctionhouse.api.event.TransactionCompleteEvent;
import com.shadebyte.auctionhouse.auction.AuctionItem;
+import com.shadebyte.auctionhouse.auction.Transaction;
import com.shadebyte.auctionhouse.cmds.CommandManager;
import com.shadebyte.auctionhouse.events.AGUIListener;
-import com.shadebyte.auctionhouse.util.ConfigWrapper;
+import com.shadebyte.auctionhouse.events.TransactionListener;
import com.shadebyte.auctionhouse.util.Debugger;
import com.shadebyte.auctionhouse.util.Locale;
+import com.shadebyte.auctionhouse.util.storage.ConfigWrapper;
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;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -42,6 +48,7 @@ public final class Core extends JavaPlugin {
//Data config instance from the config wrapper
private ConfigWrapper data;
+ private ConfigWrapper transactions;
//Language system instance
private Locale locale;
@@ -49,6 +56,12 @@ public final class Core extends JavaPlugin {
//Storage
public List auctionItems;
+ //Database
+ private Connection connection;
+ public String host, database, username, password;
+ public int port;
+ public boolean dbConnected;
+
//Timing
private Long startTime;
@@ -56,11 +69,17 @@ public final class Core extends JavaPlugin {
public void onEnable() {
// Plugin startup logic
instance = this;
+ dbConnected = false;
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bStarted to load Auction Items from data file."));
startTime = System.currentTimeMillis();
- setupEconomy();
+ if (!setupEconomy()) {
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cVault could not be loaded/was found. Disabling Auction House!"));
+ getServer().getPluginManager().disablePlugin(this);
+ return;
+ }
+
initDataFiles();
//Locales
@@ -76,6 +95,8 @@ public final class Core extends JavaPlugin {
initEvents();
initStorage();
+ if (getConfig().getBoolean("database.enabled")) mysqlSetup();
+
try {
MassiveStats stats = new MassiveStats(this);
stats.setListenerDisabled(false);
@@ -83,6 +104,54 @@ public final class Core extends JavaPlugin {
Debugger.report(e);
}
+ loadAuctions();
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bAuction House finished loading, took " + (System.currentTimeMillis() - startTime) + " ms"));
+ tickAuctions();
+ }
+
+ @Override
+ public void onDisable() {
+ saveAuctions();
+ }
+
+
+ private void mysqlSetup() {
+ host = this.getConfig().getString("database.host");
+ port = this.getConfig().getInt("database.port");
+ database = this.getConfig().getString("database.database");
+ username = this.getConfig().getString("database.username");
+ password = this.getConfig().getString("database.password");
+
+ try {
+
+ synchronized (this) {
+ if (getConnection() != null && !getConnection().isClosed()) {
+ return;
+ }
+
+ Class.forName("com.mysql.jdbc.Driver");
+ setConnection(DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.username, this.password));
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSuccessfully Connected to MySQL"));
+ dbConnected = true;
+ }
+ } catch (SQLException e) {
+ Debugger.report(e);
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCould not connect to MySQL"));
+ } catch (ClassNotFoundException e) {
+ Debugger.report(e);
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCould not connect to MySQL"));
+ }
+ }
+
+ public Connection getConnection() {
+ return connection;
+ }
+
+ public void setConnection(Connection connection) {
+ this.connection = connection;
+ }
+
+ private void loadAuctions() {
try {
ConfigurationSection section = data.getConfig().getConfigurationSection("active");
if (section.getKeys(false).size() != 0) {
@@ -103,6 +172,8 @@ public final class Core extends JavaPlugin {
AuctionItem item = new AuctionItem(owner, highestBidder, stack, startPrice, bidIncrement, buyNowPrice, currentPrice, time, key);
auctionItems.add(item);
data.getConfig().set("active." + xNode, null);
+ AuctionStartEvent auctionStartEvent = new AuctionStartEvent(item);
+ getServer().getPluginManager().callEvent(auctionStartEvent);
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&eLoaded Auction Item with key&f: &b" + item.getKey()));
}
data.saveConfig();
@@ -112,9 +183,9 @@ public final class Core extends JavaPlugin {
} catch (Exception e) {
Debugger.report(e);
}
+ }
- Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bAuction House finished loading, took " + (System.currentTimeMillis() - startTime) + " ms"));
-
+ private void tickAuctions() {
try {
Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(this, () -> {
if (auctionItems.size() != 0) {
@@ -125,7 +196,8 @@ public final class Core extends JavaPlugin {
getServer().getPluginManager().callEvent(auctionEndEvent);
if (!auctionEndEvent.isCancelled()) {
if (auctionItem.getHighestBidder().equalsIgnoreCase(auctionItem.getOwner())) {
- data.getConfig().set("expired." + auctionItem.getOwner() + "." + System.currentTimeMillis() + System.nanoTime(), auctionItem.getItem());
+ data.getConfig().set("expired." + auctionItem.getOwner() + "." + auctionItem.getKey() + ".item", auctionItem.getItem());
+ data.getConfig().set("expired." + auctionItem.getOwner() + "." + auctionItem.getKey() + ".display", AuctionAPI.getInstance().expiredAuctionItem(auctionItem));
data.saveConfig();
auctionItems.remove(auctionItem);
} else {
@@ -133,21 +205,30 @@ public final class Core extends JavaPlugin {
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());
+ data.getConfig().set("expired." + auctionItem.getOwner() + "." + auctionItem.getKey() + ".item", auctionItem.getItem());
+ data.getConfig().set("expired." + auctionItem.getOwner() + "." + auctionItem.getKey() + ".display", AuctionAPI.getInstance().expiredAuctionItem(auctionItem));
} 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());
+ Transaction transaction = new Transaction(Transaction.TransactionType.AUCTION_WON, auctionItem, highestBidder.getUniqueId().toString(), System.currentTimeMillis());
+ transaction.saveTransaction();
+ getServer().getPluginManager().callEvent(new TransactionCompleteEvent(transaction));
}
data.saveConfig();
auctionItems.remove(auctionItem);
} else {
if (getEconomy().getBalance(highestBidder) < auctionItem.getCurrentPrice()) {
- data.getConfig().set("expired." + auctionItem.getOwner() + "." + System.currentTimeMillis() + System.nanoTime(), auctionItem.getItem());
+ data.getConfig().set("expired." + auctionItem.getOwner() + "." + auctionItem.getKey() + ".item", auctionItem.getItem());
+ data.getConfig().set("expired." + auctionItem.getOwner() + "." + auctionItem.getKey() + ".display", AuctionAPI.getInstance().expiredAuctionItem(auctionItem));
} else {
- data.getConfig().set("expired." + auctionItem.getHighestBidder() + "." + System.currentTimeMillis() + System.nanoTime(), auctionItem.getItem());
+ data.getConfig().set("expired." + auctionItem.getHighestBidder() + "." + auctionItem.getKey() + ".item", auctionItem.getItem());
+ data.getConfig().set("expired." + auctionItem.getHighestBidder() + "." + auctionItem.getKey() + ".display", AuctionAPI.getInstance().expiredAuctionItem(auctionItem));
+ Transaction transaction = new Transaction(Transaction.TransactionType.AUCTION_WON, auctionItem, highestBidder.getUniqueId().toString(), System.currentTimeMillis());
+ transaction.saveTransaction();
+ getServer().getPluginManager().callEvent(new TransactionCompleteEvent(transaction));
}
data.saveConfig();
auctionItems.remove(auctionItem);
@@ -159,14 +240,10 @@ public final class Core extends JavaPlugin {
}
}, 0, 20 * 5);
} catch (Exception e) {
- //Debugger.report(e);
}
}
- @Override
- public void onDisable() {
- // Plugin shutdown logic
-
+ private void saveAuctions() {
//Save Auctions to file.
int node = 1;
for (AuctionItem auctionItem : auctionItems) {
@@ -181,7 +258,6 @@ public final class Core extends JavaPlugin {
data.getConfig().set("active." + node + ".item", auctionItem.getItem());
node++;
}
-
data.saveConfig();
}
@@ -201,15 +277,21 @@ public final class Core extends JavaPlugin {
getConfig().options().copyDefaults(true);
saveDefaultConfig();
data = new ConfigWrapper(this, "", "data.yml");
+ transactions = new ConfigWrapper(this, "", "transactions.yml");
if (!new File(this.getDataFolder(), "data.yml").exists()) {
data.getConfig().createSection("active");
}
+ if (!new File(this.getDataFolder(), "transactions.yml").exists()) {
+ transactions.getConfig().createSection("transactions");
+ }
data.saveConfig();
+ transactions.saveConfig();
}
private void initEvents() {
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new AGUIListener(), this);
+ pm.registerEvents(new TransactionListener(), this);
}
private void initStorage() {
@@ -232,6 +314,10 @@ public final class Core extends JavaPlugin {
return data;
}
+ public ConfigWrapper getTransactions() {
+ return transactions;
+ }
+
public static Economy getEconomy() {
return economy;
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/AuctionAPI.java b/src/main/java/com/shadebyte/auctionhouse/api/AuctionAPI.java
index 50b07c0..8e68371 100644
--- a/src/main/java/com/shadebyte/auctionhouse/api/AuctionAPI.java
+++ b/src/main/java/com/shadebyte/auctionhouse/api/AuctionAPI.java
@@ -2,9 +2,13 @@ package com.shadebyte.auctionhouse.api;
import com.shadebyte.auctionhouse.Core;
import com.shadebyte.auctionhouse.api.enums.Version;
+import com.shadebyte.auctionhouse.auction.AuctionItem;
import com.shadebyte.auctionhouse.util.Debugger;
+import com.shadebyte.auctionhouse.util.NBTEditor;
+import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
+import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@@ -12,8 +16,11 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.text.DecimalFormat;
import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
+import java.util.TreeMap;
/**
* The current file has been created by Kiran Hart
@@ -24,6 +31,7 @@ import java.util.List;
public class AuctionAPI {
private static char[] c = new char[]{'k', 'm', 'b', 't'};
+ private final static TreeMap map = new TreeMap();
private static AuctionAPI instance;
@@ -37,6 +45,50 @@ public class AuctionAPI {
return instance;
}
+ static {
+
+ map.put(1000, "M");
+ map.put(900, "CM");
+ map.put(500, "D");
+ map.put(400, "CD");
+ map.put(100, "C");
+ map.put(90, "XC");
+ map.put(50, "L");
+ map.put(40, "XL");
+ map.put(10, "X");
+ map.put(9, "IX");
+ map.put(5, "V");
+ map.put(4, "IV");
+ map.put(1, "I");
+
+ }
+
+ public String toRoman(int number) {
+ int l = map.floorKey(number);
+ if (number == l) {
+ return map.get(number);
+ }
+ return map.get(l) + toRoman(number - l);
+ }
+
+ public ItemStack expiredAuctionItem(AuctionItem stack) {
+ ItemStack item = stack.getItem();
+ item = NBTEditor.setItemTag(item, stack.getKey(), "ExpiredAuctionItem");
+ return item;
+ }
+
+ public List getAllExpiredItems(Player p) {
+ List items = new ArrayList<>();
+ if (Core.getInstance().getData().getConfig().getConfigurationSection("expired." + p.getUniqueId().toString()) != null) {
+ if (Core.getInstance().getData().getConfig().getConfigurationSection("expired." + p.getUniqueId().toString()).getKeys(false).size() >= 1) {
+ for (String s : Core.getInstance().getData().getConfig().getConfigurationSection("expired." + p.getUniqueId().toString()).getKeys(false)) {
+ items.add(Core.getInstance().getData().getConfig().getItemStack("expired." + p.getUniqueId().toString() + "." + s + ".display"));
+ }
+ }
+ }
+ return items;
+ }
+
public ItemStack createConfigItem(String node, int activeAuctions, int expiredAuctions) {
String[] rawItem = Core.getInstance().getConfig().getString(node + ".item").split(":");
ItemStack stack = new ItemStack(Material.valueOf(rawItem[0].toUpperCase()), 1, Short.parseShort(rawItem[1]));
@@ -44,8 +96,8 @@ public class AuctionAPI {
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString(node + ".name")));
List lore = new ArrayList<>();
Core.getInstance().getConfig().getStringList(node + ".lore").forEach(s -> lore.add(ChatColor.translateAlternateColorCodes('&', s
- .replace("{active_player_auctions}", String.valueOf(activeAuctions))
- .replace("{expired_player_auctions}", String.valueOf(expiredAuctions)))));
+ .replace("{active_player_auctions}", String.valueOf(activeAuctions))
+ .replace("{expired_player_auctions}", String.valueOf(expiredAuctions)))));
meta.setLore(lore);
stack.setItemMeta(meta);
return stack;
@@ -96,6 +148,12 @@ public class AuctionAPI {
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
}
+ public String getDate(long milli) {
+ Date date = new Date(milli);
+ SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yy");
+ return df2.format(date);
+ }
+
public String friendlyNumber(double value) {
int power;
String suffix = " KMBT";
@@ -124,4 +182,49 @@ public class AuctionAPI {
stack.setItemMeta(meta);
return stack;
}
+
+ public String getSQLDisplayName(ItemStack item) {
+ String name;
+ if (item.hasItemMeta()) {
+ name = (item.getItemMeta().hasDisplayName()) ? item.getItemMeta().getDisplayName() : StringUtils.capitalize(item.getType().name().toLowerCase().replace("_", " "));
+ } else {
+ name = StringUtils.capitalize(item.getType().name().toLowerCase().replace("_", " "));
+ }
+ return name;
+ }
+
+ public String getSQLLore(ItemStack item) {
+ String lore = "";
+ if (item.hasItemMeta()) {
+ if (!item.getItemMeta().hasLore()) {
+ lore = "No Lore";
+ } else {
+ for (String s : item.getItemMeta().getLore()) {
+ lore += ChatColor.stripColor(s) + ";";
+ }
+ }
+ } else {
+ lore = "No Lore";
+ }
+ return lore;
+ }
+
+ public String getSQLEnchantments(ItemStack item) {
+ String lore = "";
+ if (item.hasItemMeta()) {
+ if (!item.getItemMeta().hasEnchants()) {
+ lore = "No Enchantments";
+ } else {
+ for (Enchantment enchantment : item.getItemMeta().getEnchants().keySet()) {
+ String name = enchantment.getName().replace("_", " ").toLowerCase();
+ String level = toRoman(item.getItemMeta().getEnchantLevel(enchantment));
+ String e = StringUtils.capitalize(name) + "," + level;
+ lore += e + ";";
+ }
+ }
+ } else {
+ lore = "No Enchantments";
+ }
+ return lore;
+ }
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/DiscordEmbed.java b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/DiscordEmbed.java
new file mode 100644
index 0000000..cdd3db2
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/DiscordEmbed.java
@@ -0,0 +1,78 @@
+package com.shadebyte.auctionhouse.api.discordwebhook;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: 7/21/2018
+ * Time Created: 12:20 PM
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
+ */
+
+import com.shadebyte.auctionhouse.api.discordwebhook.embed.*;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A discord embed
+ *
+ * @author MrPowerGamerBR
+ */
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+public class DiscordEmbed {
+ String title;
+ String type;
+ String description;
+ String url;
+ String timestamp;
+ int color;
+ ImageEmbed image;
+ ThumbnailEmbed thumbnail;
+ ProviderEmbed provider;
+ AuthorEmbed author;
+ List fields = new ArrayList();
+
+ public DiscordEmbed() {
+
+ }
+
+ public DiscordEmbed(String title, String description) {
+ this(title, description, null);
+ }
+
+ public DiscordEmbed(String title, String description, String url) {
+ setTitle(title);
+ setDescription(description);
+ setUrl(url);
+ }
+
+ public static DiscordMessage toDiscordMessage(DiscordEmbed embed, String username, String avatarUrl) {
+ DiscordMessage dm = DiscordMessage.builder()
+ .username(username)
+ .avatarUrl(avatarUrl)
+ .content("")
+ .embed(embed)
+ .build();
+
+ return dm;
+ }
+
+ public DiscordMessage toDiscordMessage(String username, String avatarUrl) {
+ return DiscordEmbed.toDiscordMessage(this, username, avatarUrl);
+ }
+
+ public static class DiscordEmbedBuilder {
+ List fields = new ArrayList();
+
+ public DiscordEmbedBuilder field(FieldEmbed field) {
+ fields.add(field);
+ return this;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/DiscordHook.java b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/DiscordHook.java
new file mode 100644
index 0000000..04c7b0f
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/DiscordHook.java
@@ -0,0 +1,39 @@
+package com.shadebyte.auctionhouse.api.discordwebhook;
+
+import com.github.kevinsawicki.http.HttpRequest;
+import com.google.gson.Gson;
+import com.shadebyte.auctionhouse.Core;
+import com.shadebyte.auctionhouse.util.Debugger;
+import org.bukkit.Bukkit;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: 7/21/2018
+ * Time Created: 12:28 PM
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
+ */
+public class DiscordHook {
+
+ public static final Gson gson = new Gson();
+ public String url;
+
+ public DiscordHook(String url) {
+ this.url = url;
+ }
+
+ public void send(DiscordMessage dm) {
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(Core.getInstance(), ()-> {
+ String strResponse = HttpRequest.post(url).acceptJson().contentType("application/json").header("User-Agent", "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11").send(gson.toJson(dm)).body();
+ if(!strResponse.isEmpty()) {
+ Response response = gson.fromJson(strResponse, Response.class);
+ try {
+ if (response.getMessage().equals("You are being rate limited.")) {
+ Bukkit.getConsoleSender().sendMessage("Error");
+ }
+ } catch (Exception e) {
+ Debugger.report(e);
+ }
+ }
+ });
+ }
+}
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/DiscordMessage.java b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/DiscordMessage.java
new file mode 100644
index 0000000..03bd3b5
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/DiscordMessage.java
@@ -0,0 +1,65 @@
+package com.shadebyte.auctionhouse.api.discordwebhook;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: 7/21/2018
+ * Time Created: 12:26 PM
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
+ */
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.*;
+
+/**
+ * A discord message
+ *
+ * @author MrPowerGamerBR
+ */
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+public class DiscordMessage {
+ String username;
+ String content;
+ @SerializedName("avatar_url")
+ String avatarUrl;
+ @SerializedName("tts")
+ boolean textToSpeech;
+ List embeds = new ArrayList();
+
+ public DiscordMessage() {
+
+ }
+
+ public DiscordMessage(String username, String content, String avatar_url) {
+ this(username, content, avatar_url, false);
+ }
+
+ public DiscordMessage(String username, String content, String avatar_url, boolean tts) {
+ setUsername(username);
+ setContent(content);
+ setAvatarUrl(avatar_url);
+ setTextToSpeech(tts);
+ }
+
+ public void setUsername(String username) {
+ if (username != null) {
+ this.username = username.substring(0, Math.min(31, username.length()));
+ } else {
+ this.username = null;
+ }
+ }
+
+ public static class DiscordMessageBuilder {
+ List embeds = new ArrayList();
+
+ public DiscordMessageBuilder embed(DiscordEmbed embed) {
+ embeds.add(embed);
+ return this;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/Response.java b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/Response.java
new file mode 100644
index 0000000..acd05f0
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/Response.java
@@ -0,0 +1,18 @@
+package com.shadebyte.auctionhouse.api.discordwebhook;
+
+import com.google.gson.annotations.SerializedName;
+
+import lombok.Getter;
+
+/**
+ * Discord response
+ *
+ * @author MrPowerGamerBR
+ */
+@Getter
+public class Response {
+ boolean global;
+ String message;
+ @SerializedName("retry_after")
+ int retryAfter;
+}
\ No newline at end of file
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/AuthorEmbed.java b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/AuthorEmbed.java
new file mode 100644
index 0000000..97bbdf5
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/AuthorEmbed.java
@@ -0,0 +1,17 @@
+package com.shadebyte.auctionhouse.api.discordwebhook.embed;
+
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+
+public class AuthorEmbed {
+ String name;
+ String url;
+ String icon_url;
+ String proxy_icon_url;
+}
\ No newline at end of file
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/FieldEmbed.java b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/FieldEmbed.java
new file mode 100644
index 0000000..b4174e8
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/FieldEmbed.java
@@ -0,0 +1,14 @@
+package com.shadebyte.auctionhouse.api.discordwebhook.embed;
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class FieldEmbed {
+ String name;
+ String value;
+ boolean inline;
+}
\ No newline at end of file
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/ImageEmbed.java b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/ImageEmbed.java
new file mode 100644
index 0000000..3d2335d
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/ImageEmbed.java
@@ -0,0 +1,15 @@
+package com.shadebyte.auctionhouse.api.discordwebhook.embed;
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ImageEmbed {
+ String url;
+ String proxy_url;
+ int height;
+ int width;
+}
\ No newline at end of file
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/ProviderEmbed.java b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/ProviderEmbed.java
new file mode 100644
index 0000000..29f0d1c
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/ProviderEmbed.java
@@ -0,0 +1,13 @@
+package com.shadebyte.auctionhouse.api.discordwebhook.embed;
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ProviderEmbed {
+ String name;
+ String url;
+}
\ No newline at end of file
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/ThumbnailEmbed.java b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/ThumbnailEmbed.java
new file mode 100644
index 0000000..90f0306
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/discordwebhook/embed/ThumbnailEmbed.java
@@ -0,0 +1,15 @@
+package com.shadebyte.auctionhouse.api.discordwebhook.embed;
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class ThumbnailEmbed {
+ String url;
+ String proxy_url;
+ int height;
+ int width;
+}
\ No newline at end of file
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 5faf8c5..f29860a 100644
--- a/src/main/java/com/shadebyte/auctionhouse/api/enums/Lang.java
+++ b/src/main/java/com/shadebyte/auctionhouse/api/enums/Lang.java
@@ -21,6 +21,14 @@ public enum Lang {
AUCTION_MAX("auction.max"),
AUCTION_SOLD("auction.sold"),
+ MAX_START_PRICE("price.max.start"),
+ MAX_AUCTION_PRICE("price.max.auction"),
+ MAX_INCREMENT_PRICE("price.max.increment"),
+
+ MIN_START_PRICE("price.min.start"),
+ MIN_AUCTION_PRICE("price.min.auction"),
+ MIN_INCREMENT_PRICE("price.min.increment"),
+
INVALID_SUBCOMMAND("cmd.invalid"),
CMD_SELL("cmd.sell"),
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/enums/Permissions.java b/src/main/java/com/shadebyte/auctionhouse/api/enums/Permissions.java
index 4976f11..52a020f 100644
--- a/src/main/java/com/shadebyte/auctionhouse/api/enums/Permissions.java
+++ b/src/main/java/com/shadebyte/auctionhouse/api/enums/Permissions.java
@@ -9,6 +9,9 @@ package com.shadebyte.auctionhouse.api.enums;
public enum Permissions {
BASE("AuctionHouse"),
+ RELOAD_CMD(BASE.getNode() + ".cmd.reload"),
+ SELL_CMD(BASE.getNode() + ".cmd.sell"),
+ EXPIRED_CMD(BASE.getNode() + ".cmd.expired"),
MAX_AUCTIONS(BASE.getNode() + ".maxauctions"),
;
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/event/AuctionCancelEvent.java b/src/main/java/com/shadebyte/auctionhouse/api/event/AuctionCancelEvent.java
deleted file mode 100644
index 5980f38..0000000
--- a/src/main/java/com/shadebyte/auctionhouse/api/event/AuctionCancelEvent.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.shadebyte.auctionhouse.api.event;
-
-/**
- * The current file has been created by Kiran Hart
- * Date Created: 7/6/2018
- * Time Created: 11:55 AM
- * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
- */
-public class AuctionCancelEvent {
-}
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/event/AuctionStartEvent.java b/src/main/java/com/shadebyte/auctionhouse/api/event/AuctionStartEvent.java
index 93b2622..0015e45 100644
--- a/src/main/java/com/shadebyte/auctionhouse/api/event/AuctionStartEvent.java
+++ b/src/main/java/com/shadebyte/auctionhouse/api/event/AuctionStartEvent.java
@@ -1,10 +1,48 @@
package com.shadebyte.auctionhouse.api.event;
+import com.shadebyte.auctionhouse.auction.AuctionItem;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
/**
* The current file has been created by Kiran Hart
* Date Created: 7/6/2018
* Time Created: 11:54 AM
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
*/
-public class AuctionStartEvent {
+public class AuctionStartEvent extends Event implements Cancellable {
+
+ private static final HandlerList handlers = new HandlerList();
+ private boolean cancelled;
+
+ private AuctionItem auctionItem;
+
+ public AuctionStartEvent(AuctionItem auctionItem) {
+ this.auctionItem = auctionItem;
+ }
+
+ public AuctionItem getAuctionItem() {
+ return auctionItem;
+ }
+
+ public void setAuctionItem(AuctionItem auctionItem) {
+ this.auctionItem = auctionItem;
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ }
+
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/api/event/TransactionCompleteEvent.java b/src/main/java/com/shadebyte/auctionhouse/api/event/TransactionCompleteEvent.java
new file mode 100644
index 0000000..e38a475
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/api/event/TransactionCompleteEvent.java
@@ -0,0 +1,38 @@
+package com.shadebyte.auctionhouse.api.event;
+
+import com.shadebyte.auctionhouse.auction.Transaction;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: 7/13/2018
+ * Time Created: 11:44 AM
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
+ */
+public class TransactionCompleteEvent extends Event {
+
+ private static final HandlerList handlers = new HandlerList();
+
+ private Transaction transaction;
+
+ public TransactionCompleteEvent(Transaction transaction) {
+ this.transaction = transaction;
+ }
+
+ public Transaction getTransaction() {
+ return transaction;
+ }
+
+ public void setAuctionItem(Transaction transaction) {
+ this.transaction = transaction;
+ }
+
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/com/shadebyte/auctionhouse/auction/AuctionItem.java b/src/main/java/com/shadebyte/auctionhouse/auction/AuctionItem.java
index 982f8ba..f606b22 100644
--- a/src/main/java/com/shadebyte/auctionhouse/auction/AuctionItem.java
+++ b/src/main/java/com/shadebyte/auctionhouse/auction/AuctionItem.java
@@ -148,12 +148,7 @@ public class AuctionItem {
ItemStack stack = item.clone();
stack.setAmount((stack.getAmount() > 1) ? stack.getAmount() : 1);
ItemMeta meta = stack.getItemMeta();
- List lore = null;
- if (meta.hasLore()) {
- lore = meta.getLore();
- } else {
- lore = new ArrayList<>();
- }
+ List lore = (meta.hasLore() ? meta.getLore() : new ArrayList<>());
lore.add(translateAlternateColorCodes('&', "&7-------------------------"));
if (owner == null)
lore.add(translateAlternateColorCodes('&', "&eSeller&f: &bSample User"));
@@ -175,4 +170,21 @@ public class AuctionItem {
return stack;
}
+ public ItemStack listingStack() {
+ ItemStack stack = item.clone();
+ stack.setAmount((stack.getAmount() > 1) ? stack.getAmount() : 1);
+ ItemMeta meta = stack.getItemMeta();
+ List lore = (meta.hasLore() ? meta.getLore() : new ArrayList<>());
+ lore.add(translateAlternateColorCodes('&', "&7-------------------------"));
+ lore.add(translateAlternateColorCodes('&', "&eBuy Now: &a$" + AuctionAPI.getInstance().friendlyNumber(buyNowPrice)));
+ lore.add(translateAlternateColorCodes('&', "&eCurrent Price: &a$" + AuctionAPI.getInstance().friendlyNumber(currentPrice)));
+ lore.add(translateAlternateColorCodes('&', "&eBid Increment: &a$" + AuctionAPI.getInstance().friendlyNumber(bidIncrement)));
+ lore.add(translateAlternateColorCodes('&', ""));
+ lore.add(translateAlternateColorCodes('&', "&eTime Left: &b" + AuctionAPI.getInstance().timeLeft(getTime())));
+ lore.add(translateAlternateColorCodes('&', "&7-------------------------"));
+ meta.setLore(lore);
+ stack.setItemMeta(meta);
+ stack = NBTEditor.setItemTag(stack, getKey(), "AuctionItemKey");
+ return stack;
+ }
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/auction/AuctionPlayer.java b/src/main/java/com/shadebyte/auctionhouse/auction/AuctionPlayer.java
index 70f02a3..77530a9 100644
--- a/src/main/java/com/shadebyte/auctionhouse/auction/AuctionPlayer.java
+++ b/src/main/java/com/shadebyte/auctionhouse/auction/AuctionPlayer.java
@@ -23,13 +23,7 @@ public class AuctionPlayer {
}
public int getTotalActiveAuctions() {
- int total = 0;
- for (AuctionItem item : Core.getInstance().auctionItems) {
- if (item.getOwner().equals(player.getUniqueId().toString())) {
- total++;
- }
- }
- return total;
+ return getAuctionItems().size();
}
public List getAuctionItems() {
@@ -49,12 +43,17 @@ public class AuctionPlayer {
return total;
}
-
- public boolean hasMaximumAuctionsActive() {
- if (!player.hasPermission(Permissions.MAX_AUCTIONS.getNode() + "." + getTotalActiveAuctions())) {
- return true;
+ public int getLimit() {
+ if (player.hasPermission(Permissions.MAX_AUCTIONS.getNode() + ".*")) {
+ return Integer.MAX_VALUE;
}
- return false;
+
+ for (int i = 1001; i > 0; i--) {
+ if (player.hasPermission(Permissions.MAX_AUCTIONS.getNode() + "." + i)) {
+ return i;
+ }
+ }
+ return 0;
}
public Player getPlayer() {
diff --git a/src/main/java/com/shadebyte/auctionhouse/auction/Receipt.java b/src/main/java/com/shadebyte/auctionhouse/auction/Receipt.java
new file mode 100644
index 0000000..acdd17c
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/auction/Receipt.java
@@ -0,0 +1,68 @@
+package com.shadebyte.auctionhouse.auction;
+
+import com.shadebyte.auctionhouse.Core;
+import com.shadebyte.auctionhouse.util.NBTEditor;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import javax.swing.text.NumberFormatter;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: 7/25/2018
+ * Time Created: 11:32 PM
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
+ */
+public class Receipt {
+
+ private int total;
+ private String seller, buyer, date, time;
+ private Transaction transaction;
+
+ public Receipt(Transaction transaction) {
+ this.transaction = transaction;
+ this.total = (transaction.getTransactionType() == Transaction.TransactionType.BOUGHT) ? transaction.getAuctionItem().getBuyNowPrice() : transaction.getAuctionItem().getCurrentPrice();
+ this.seller = transaction.getAuctionItem().getOwner();
+ this.buyer = transaction.getBuyer();
+ this.date = new SimpleDateFormat("MMMM dd yyyy").format(new Date(transaction.getTimeCompleted()));
+ this.time = new SimpleDateFormat("h:mm a").format(new Date());
+ }
+
+ public ItemStack getReceipt() {
+ String[] item = Core.getInstance().getConfig().getString("receipt.item").split(":");
+ ItemStack stack = new ItemStack(Material.valueOf(item[0].toUpperCase()), 1, Short.parseShort(item[1]));
+ ItemMeta meta = stack.getItemMeta();
+ meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("receipt.name")));
+ List 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(UUID.fromString(seller)).getName()))).collect(Collectors.toList());
+ meta.setLore(lore);
+ stack.setItemMeta(meta);
+ stack = NBTEditor.setItemTag(stack, transaction.getTimeCompleted() + transaction.getAuctionItem().getKey(), "AuctionReceipt");
+ return stack;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public String getSeller() {
+ return seller;
+ }
+
+ public String getBuyer() {
+ return buyer;
+ }
+
+ public String getDate() {
+ return date;
+ }
+}
diff --git a/src/main/java/com/shadebyte/auctionhouse/auction/Transaction.java b/src/main/java/com/shadebyte/auctionhouse/auction/Transaction.java
new file mode 100644
index 0000000..0460c4f
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/auction/Transaction.java
@@ -0,0 +1,87 @@
+package com.shadebyte.auctionhouse.auction;
+
+import com.shadebyte.auctionhouse.Core;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: 7/11/2018
+ * Time Created: 3:06 PM
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
+ */
+public class Transaction {
+
+ public enum TransactionType {
+
+ AUCTION_WON("Won Auction"),
+ BOUGHT("Bought Immediately");
+
+ private String transactionType;
+
+ TransactionType(String transactionType) {
+ this.transactionType = transactionType;
+ }
+
+ public String getTransactionType() {
+ return transactionType;
+ }
+ }
+
+ private TransactionType transactionType;
+ private AuctionItem auctionItem;
+ private String buyer;
+ private long timeCompleted;
+
+ public Transaction(TransactionType transactionType, AuctionItem auctionItem, String buyer, long timeCompleted) {
+ this.transactionType = transactionType;
+ this.auctionItem = auctionItem;
+ this.buyer = buyer;
+ this.timeCompleted = timeCompleted;
+ }
+
+ public void saveTransaction() {
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".transaction-type", transactionType.name());
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".seller", auctionItem.getOwner());
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".buyer", buyer);
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".start-price", auctionItem.getStartPrice());
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".bid-increment", auctionItem.getBidIncrement());
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".current-price", auctionItem.getCurrentPrice());
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".buy-now-price", auctionItem.getBuyNowPrice());
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".time-left", auctionItem.getTime());
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".auction-id", auctionItem.getKey());
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".time-completed", timeCompleted);
+ Core.getInstance().getTransactions().getConfig().set("transactions." + timeCompleted + auctionItem.getKey() + ".item", auctionItem.getItem());
+ Core.getInstance().getTransactions().saveConfig();
+ }
+
+ public TransactionType getTransactionType() {
+ return transactionType;
+ }
+
+ public void setTransactionType(TransactionType transactionType) {
+ this.transactionType = transactionType;
+ }
+
+ public AuctionItem getAuctionItem() {
+ return auctionItem;
+ }
+
+ public void setAuctionItem(AuctionItem auctionItem) {
+ this.auctionItem = auctionItem;
+ }
+
+ public String getBuyer() {
+ return buyer;
+ }
+
+ public void setBuyer(String buyer) {
+ this.buyer = buyer;
+ }
+
+ public long getTimeCompleted() {
+ return timeCompleted;
+ }
+
+ public void setTimeCompleted(long timeCompleted) {
+ this.timeCompleted = timeCompleted;
+ }
+}
diff --git a/src/main/java/com/shadebyte/auctionhouse/cmds/CommandManager.java b/src/main/java/com/shadebyte/auctionhouse/cmds/CommandManager.java
index 0518e8c..34d770d 100644
--- a/src/main/java/com/shadebyte/auctionhouse/cmds/CommandManager.java
+++ b/src/main/java/com/shadebyte/auctionhouse/cmds/CommandManager.java
@@ -3,6 +3,7 @@ package com.shadebyte.auctionhouse.cmds;
import com.shadebyte.auctionhouse.Core;
import com.shadebyte.auctionhouse.api.enums.Lang;
import com.shadebyte.auctionhouse.api.enums.Permissions;
+import com.shadebyte.auctionhouse.cmds.subcmds.ReloadCommand;
import com.shadebyte.auctionhouse.cmds.subcmds.SellCommand;
import com.shadebyte.auctionhouse.inventory.inventories.AuctionGUI;
import com.shadebyte.auctionhouse.util.Debugger;
@@ -40,6 +41,7 @@ public class CommandManager implements CommandExecutor {
public void initialize() {
Core.getInstance().getCommand(main).setExecutor(this);
this.commands.add(new SellCommand());
+ this.commands.add(new ReloadCommand());
}
@Override
@@ -55,7 +57,7 @@ public class CommandManager implements CommandExecutor {
if (args.length == 0) {
if (sender instanceof Player) {
Player p = (Player) sender;
- p.openInventory(AuctionGUI.getInstance(p).getInventory());
+ p.openInventory(new AuctionGUI(p).getInventory());
}
return true;
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/ExpiredCommand.java b/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/ExpiredCommand.java
index 4ec7215..0250cbf 100644
--- a/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/ExpiredCommand.java
+++ b/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/ExpiredCommand.java
@@ -1,10 +1,50 @@
package com.shadebyte.auctionhouse.cmds.subcmds;
+import com.shadebyte.auctionhouse.Core;
+import com.shadebyte.auctionhouse.api.enums.Lang;
+import com.shadebyte.auctionhouse.api.enums.Permissions;
+import com.shadebyte.auctionhouse.cmds.SubCommand;
+import com.shadebyte.auctionhouse.inventory.inventories.ExpiredGUI;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
/**
* The current file has been created by Kiran Hart
* Date Created: 7/6/2018
* Time Created: 11:51 AM
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
*/
-public class ExpiredCommand {
+public class ExpiredCommand extends SubCommand {
+
+ @Override
+ public void onCommand(CommandSender sender, String[] args) {
+
+ if (!sender.hasPermission(Permissions.EXPIRED_CMD.getNode())) {
+ sender.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NO_PERMISSION.getNode()));
+ return;
+ }
+
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.PLAYERS_ONLY.getNode()));
+ return;
+ }
+
+ Player p = (Player) sender;
+ p.openInventory(new ExpiredGUI(p).getInventory());
+ }
+
+ @Override
+ public String name() {
+ return Core.getInstance().getCommandManager().expired;
+ }
+
+ @Override
+ public String info() {
+ return null;
+ }
+
+ @Override
+ public String[] aliases() {
+ return new String[0];
+ }
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/ReloadCommand.java b/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/ReloadCommand.java
index 21e437f..2c2bb3b 100644
--- a/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/ReloadCommand.java
+++ b/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/ReloadCommand.java
@@ -1,10 +1,58 @@
package com.shadebyte.auctionhouse.cmds.subcmds;
+import com.shadebyte.auctionhouse.Core;
+import com.shadebyte.auctionhouse.api.enums.Lang;
+import com.shadebyte.auctionhouse.api.enums.Permissions;
+import com.shadebyte.auctionhouse.cmds.SubCommand;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.CommandSender;
+
/**
* The current file has been created by Kiran Hart
* Date Created: 7/6/2018
* Time Created: 11:51 AM
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
*/
-public class ReloadCommand {
+public class ReloadCommand extends SubCommand {
+
+ @Override
+ public void onCommand(CommandSender sender, String[] args) {
+
+ if (!sender.hasPermission(Permissions.RELOAD_CMD.getNode())) {
+ sender.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NO_PERMISSION.getNode()));
+ return;
+ }
+
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cStarting reload process"));
+ long start = System.currentTimeMillis();
+
+ sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bReloading config.yml"));
+ Core.getInstance().saveConfig();
+ Core.getInstance().reloadConfig();
+ sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bReloading transactions.yml"));
+ Core.getInstance().getTransactions().saveConfig();
+ Core.getInstance().getTransactions().reloadConfig();
+ sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bReloading data.yml"));
+ Core.getInstance().getData().saveConfig();
+ Core.getInstance().getData().reloadConfig();
+ sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&bReloading language file."));
+ Core.getInstance().getLocale().reloadMessages();
+ sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&eAuction House reloaded, took &a" + (System.currentTimeMillis() - start) + "ms"));
+ }
+
+ @Override
+ public String name() {
+ return Core.getInstance().getCommandManager().reload;
+ }
+
+ @Override
+ public String info() {
+ return null;
+ }
+
+ @Override
+ public String[] aliases() {
+ return new String[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 f4ef9a3..8f5a755 100644
--- a/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/SellCommand.java
+++ b/src/main/java/com/shadebyte/auctionhouse/cmds/subcmds/SellCommand.java
@@ -2,14 +2,22 @@ package com.shadebyte.auctionhouse.cmds.subcmds;
import com.shadebyte.auctionhouse.Core;
import com.shadebyte.auctionhouse.api.AuctionAPI;
+import com.shadebyte.auctionhouse.api.discordwebhook.DiscordEmbed;
+import com.shadebyte.auctionhouse.api.discordwebhook.DiscordHook;
+import com.shadebyte.auctionhouse.api.discordwebhook.DiscordMessage;
+import com.shadebyte.auctionhouse.api.discordwebhook.embed.FieldEmbed;
import com.shadebyte.auctionhouse.api.enums.Lang;
import com.shadebyte.auctionhouse.api.enums.Permissions;
+import com.shadebyte.auctionhouse.api.event.AuctionStartEvent;
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;
+import java.util.Arrays;
+import java.util.concurrent.ThreadLocalRandom;
+
/**
* The current file has been created by Kiran Hart
* Date Created: 7/6/2018
@@ -21,7 +29,7 @@ public class SellCommand extends SubCommand {
@Override
public void onCommand(CommandSender sender, String[] args) {
- if (!sender.hasPermission(Permissions.BASE.getNode())) {
+ if (!sender.hasPermission(Permissions.SELL_CMD.getNode())) {
sender.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NO_PERMISSION.getNode()));
return;
}
@@ -54,9 +62,24 @@ public class SellCommand extends SubCommand {
}
}
+ if (args.length == 5) {
+ int buyNow = ThreadLocalRandom.current().nextInt(2, 100000);
+ int startPrice = ThreadLocalRandom.current().nextInt(2, 10000);
+ int increment = ThreadLocalRandom.current().nextInt(2, 10000);
+
+ AuctionItem auctionItem = new AuctionItem(p.getUniqueId().toString(), AuctionAPI.getItemInHand(p), Core.getInstance().getConfig().getInt("settings.default-auction-time"), startPrice, increment, buyNow);
+ Core.getInstance().auctionItems.add(0, auctionItem);
+
+ if (AuctionAPI.getItemInHand(p).getAmount() >= 2) {
+ AuctionAPI.getItemInHand(p).setAmount(AuctionAPI.getItemInHand(p).getAmount() - 1);
+ } else {
+ AuctionAPI.setItemInHand(p, null);
+ }
+ }
+
if (args.length == 4) {
if (AuctionAPI.getInstance().isNumeric(args[1]) && AuctionAPI.getInstance().isNumeric(args[2]) && AuctionAPI.getInstance().isNumeric(args[3])) {
- if (new AuctionPlayer(p).hasMaximumAuctionsActive()) {
+ if (new AuctionPlayer(p).getLimit() - 1 < new AuctionPlayer(p).getTotalActiveAuctions()) {
p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.AUCTION_MAX.getNode()));
return;
}
@@ -64,9 +87,73 @@ public class SellCommand extends SubCommand {
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)));
+
+ //Max Prices
+ if (buyNow > Core.getInstance().getConfig().getInt("settings.max-auction-price")) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.MAX_AUCTION_PRICE.getNode()));
+ return;
+ }
+
+ if (startPrice > Core.getInstance().getConfig().getInt("settings.max-auction-start")) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.MAX_START_PRICE.getNode()));
+ return;
+ }
+
+ if (increment > Core.getInstance().getConfig().getInt("settings.max-auction-increment")) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.MAX_INCREMENT_PRICE.getNode()));
+ return;
+ }
+
+ //Min Prices
+ if (buyNow < Core.getInstance().getConfig().getInt("settings.min-auction-price")) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.MIN_AUCTION_PRICE.getNode()));
+ return;
+ }
+
+ if (startPrice < Core.getInstance().getConfig().getInt("settings.min-auction-start")) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.MIN_START_PRICE.getNode()));
+ return;
+ }
+
+ if (increment < Core.getInstance().getConfig().getInt("settings.min-auction-increment")) {
+ p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.MIN_INCREMENT_PRICE.getNode()));
+ return;
+ }
+
+ AuctionItem auctionItem = new AuctionItem(p.getUniqueId().toString(), AuctionAPI.getItemInHand(p), Core.getInstance().getConfig().getInt("settings.default-auction-time"), startPrice, increment, buyNow);
+ AuctionStartEvent auctionStartEvent = new AuctionStartEvent(auctionItem);
+ Core.getInstance().getServer().getPluginManager().callEvent(auctionStartEvent);
+
+ if (!auctionStartEvent.isCancelled()) {
+ 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)));
+
+ //Discord Hook
+ if (Core.getInstance().getConfig().getBoolean("discord.enabled")) {
+ DiscordHook discordHook = new DiscordHook(Core.getInstance().getConfig().getString("discord.webhook"));
+ DiscordEmbed de = DiscordEmbed.builder()
+ .title(Core.getInstance().getConfig().getString("discord.title"))
+ .description(Core.getInstance().getConfig().getString("discord.description"))
+ .color(1)
+ .fields(Arrays.asList(
+ FieldEmbed.builder().name("Seller").value(p.getName()).inline(true).build(),
+ FieldEmbed.builder().name("Start Price").value(AuctionAPI.getInstance().friendlyNumber(startPrice)).build(),
+ FieldEmbed.builder().name("Increment").value(AuctionAPI.getInstance().friendlyNumber(increment)).build(),
+ FieldEmbed.builder().name("Buy Now").value(AuctionAPI.getInstance().friendlyNumber(buyNow)).build(),
+ FieldEmbed.builder().name("Item").value(auctionItem.getItem().getType().name() + ":" + auctionItem.getItem().getDurability()).build()
+ ))
+ .build();
+
+ DiscordMessage dm = DiscordMessage.builder().username(Core.getInstance().getConfig().getString("discord.username")).content("").avatarUrl(Core.getInstance().getConfig().getString("discord.profilepicture")).embeds(Arrays.asList(de)).build();
+ discordHook.send(dm);
+ }
+
+ if (AuctionAPI.getItemInHand(p).getAmount() >= 2) {
+ AuctionAPI.getItemInHand(p).setAmount(AuctionAPI.getItemInHand(p).getAmount() - 1);
+ } else {
+ AuctionAPI.setItemInHand(p, null);
+ }
+ }
} 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/events/TransactionListener.java b/src/main/java/com/shadebyte/auctionhouse/events/TransactionListener.java
new file mode 100644
index 0000000..b243771
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/events/TransactionListener.java
@@ -0,0 +1,73 @@
+package com.shadebyte.auctionhouse.events;
+
+import com.shadebyte.auctionhouse.Core;
+import com.shadebyte.auctionhouse.api.AuctionAPI;
+import com.shadebyte.auctionhouse.api.discordwebhook.DiscordEmbed;
+import com.shadebyte.auctionhouse.api.discordwebhook.DiscordHook;
+import com.shadebyte.auctionhouse.api.discordwebhook.DiscordMessage;
+import com.shadebyte.auctionhouse.api.discordwebhook.embed.FieldEmbed;
+import com.shadebyte.auctionhouse.api.event.TransactionCompleteEvent;
+import com.shadebyte.auctionhouse.auction.Receipt;
+import com.shadebyte.auctionhouse.auction.Transaction;
+import com.shadebyte.auctionhouse.util.Debugger;
+import com.shadebyte.auctionhouse.util.storage.MySQL;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+
+import java.util.Arrays;
+import java.util.UUID;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: 7/24/2018
+ * Time Created: 12:08 PM
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
+ */
+public class TransactionListener implements Listener {
+
+ @EventHandler
+ public void onTransactionComplete(TransactionCompleteEvent e) {
+
+ if (Core.getInstance().getConfig().getBoolean("receipt.give-on-transaction")) {
+ Player buyer = Bukkit.getPlayer(UUID.fromString(e.getTransaction().getBuyer()));
+ Player seller = Bukkit.getPlayer(UUID.fromString(e.getTransaction().getAuctionItem().getOwner()));
+
+ if (buyer != null) {
+ buyer.getInventory().addItem(new Receipt(e.getTransaction()).getReceipt());
+ }
+
+ if (seller != null) {
+ seller.getInventory().addItem(new Receipt(e.getTransaction()).getReceipt());
+ }
+ }
+ try {
+ if (Core.getInstance().getConfig().getBoolean("database.enabled") && Core.getInstance().dbConnected) {
+ new MySQL().logTransaction(e.getTransaction());
+ }
+
+ if (Core.getInstance().getConfig().getBoolean("discord.enabled")) {
+ DiscordHook discordHook = new DiscordHook(Core.getInstance().getConfig().getString("discord.webhook"));
+ DiscordEmbed de = DiscordEmbed.builder()
+ .title(Core.getInstance().getConfig().getString("discord.title"))
+ .description(Core.getInstance().getConfig().getString("discord.description-complete"))
+ .color(1)
+ .fields(Arrays.asList(
+ FieldEmbed.builder().name("Seller").value(Bukkit.getOfflinePlayer(UUID.fromString(e.getTransaction().getAuctionItem().getOwner())).getName()).inline(true).build(),
+ FieldEmbed.builder().name("Buyer").value(Bukkit.getOfflinePlayer(UUID.fromString(e.getTransaction().getBuyer())).getName()).build(),
+ FieldEmbed.builder().name("Transaction Type").value(e.getTransaction().getTransactionType().getTransactionType()).build(),
+ FieldEmbed.builder().name("Price").value(AuctionAPI.getInstance().friendlyNumber((e.getTransaction().getTransactionType() == Transaction.TransactionType.BOUGHT) ? e.getTransaction().getAuctionItem().getBuyNowPrice() : e.getTransaction().getAuctionItem().getCurrentPrice())).build(),
+ FieldEmbed.builder().name("Item").value(e.getTransaction().getAuctionItem().getItem().getType().name() + ":" + e.getTransaction().getAuctionItem().getItem().getDurability()).build()
+ ))
+ .build();
+
+ DiscordMessage dm = DiscordMessage.builder().username(Core.getInstance().getConfig().getString("discord.username")).content("").avatarUrl(Core.getInstance().getConfig().getString("discord.profilepicture")).embeds(Arrays.asList(de)).build();
+ discordHook.send(dm);
+ }
+ } catch (Exception e1) {
+ Debugger.report(e1);
+ }
+ }
+
+}
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 f097320..a0449cd 100644
--- a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/AuctionGUI.java
+++ b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/AuctionGUI.java
@@ -28,18 +28,12 @@ import java.util.List;
*/
public class AuctionGUI implements AGUI {
- private static AuctionGUI instance;
private Player p;
+ private List> chunks;
- private AuctionGUI(Player p) {
+ public AuctionGUI(Player p) {
this.p = p;
- }
-
- public static AuctionGUI getInstance(Player p) {
- if (instance == null) {
- instance = new AuctionGUI(p);
- }
- return instance;
+ chunks = Lists.partition(Core.getInstance().auctionItems, 45);
}
private int page = 1;
@@ -59,7 +53,17 @@ public class AuctionGUI implements AGUI {
if (slot == 49) {
p.closeInventory();
- p.openInventory(AuctionGUI.getInstance(p).getInventory());
+ p.openInventory(new AuctionGUI(p).getInventory());
+ }
+
+ if (slot == 45) {
+ p.closeInventory();
+ p.openInventory(new ListingsGUI(p).getInventory());
+ }
+
+ if (slot == 46) {
+ p.closeInventory();
+ p.openInventory(new ExpiredGUI(p).getInventory());
}
if (slot >= 0 & slot <= 44) {
@@ -79,7 +83,7 @@ public class AuctionGUI implements AGUI {
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());
+ p.openInventory(new AuctionGUI(p).getInventory());
}, 20);
return;
}
@@ -100,7 +104,7 @@ public class AuctionGUI implements AGUI {
item.setTime(item.getTime() + Core.getInstance().getConfig().getInt("settings.bid.increase-amount"));
p.closeInventory();
- p.openInventory(AuctionGUI.getInstance(p).getInventory());
+ p.openInventory(new AuctionGUI(p).getInventory());
}
if (e.getClick() == ClickType.RIGHT) {
@@ -113,20 +117,20 @@ public class AuctionGUI implements AGUI {
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());
+ p.openInventory(new AuctionGUI(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());
+ p.openInventory(new ConfirmationGUI(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());
+ p.openInventory(new ConfirmationGUI(item).getInventory());
}
}
}
@@ -152,11 +156,10 @@ public class AuctionGUI implements AGUI {
inventory.setItem(53, AuctionAPI.getInstance().createConfigItem("gui.auction.items.guide", 0, 0));
//Pagination
- List> chunks = Lists.partition(Core.getInstance().auctionItems, 45);
+
if (chunks.size() != 0)
chunks.get(getPage() - 1).forEach(item -> inventory.setItem(inventory.firstEmpty(), item.auctionStack()));
-
return inventory;
}
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 e91df02..d61501c 100644
--- a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ConfirmationGUI.java
+++ b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ConfirmationGUI.java
@@ -3,7 +3,9 @@ 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.api.event.TransactionCompleteEvent;
import com.shadebyte.auctionhouse.auction.AuctionItem;
+import com.shadebyte.auctionhouse.auction.Transaction;
import com.shadebyte.auctionhouse.inventory.AGUI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -23,20 +25,12 @@ import java.util.UUID;
*/
public class ConfirmationGUI implements AGUI {
- private static ConfirmationGUI instance;
private AuctionItem auctionItem;
- private ConfirmationGUI(AuctionItem auctionItem) {
+ public ConfirmationGUI(AuctionItem auctionItem) {
this.auctionItem = auctionItem;
}
- public static ConfirmationGUI getInstance(AuctionItem auctionItem) {
- if (instance == null) {
- instance = new ConfirmationGUI(auctionItem);
- }
- return instance;
- }
-
@Override
public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
e.setCancelled(true);
@@ -47,6 +41,7 @@ public class ConfirmationGUI implements AGUI {
p.sendMessage(Core.getInstance().getSettings().getPrefix() + Core.getInstance().getLocale().getMessage(Lang.NOT_ENOUGH_MONEY.getNode()));
} else {
Core.getEconomy().withdrawPlayer(p, auctionItem.getBuyNowPrice());
+ Core.getEconomy().depositPlayer(Bukkit.getOfflinePlayer(UUID.fromString(auctionItem.getOwner())), 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()));
@@ -55,14 +50,20 @@ public class ConfirmationGUI implements AGUI {
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())));
}
+ long time = System.currentTimeMillis();
+ Transaction transaction = new Transaction(Transaction.TransactionType.BOUGHT, auctionItem, p.getUniqueId().toString(), time);
+ transaction.saveTransaction();
auctionItem.setTime(0);
Core.getInstance().auctionItems.remove(auctionItem);
p.closeInventory();
+ TransactionCompleteEvent completeEvent = new TransactionCompleteEvent(transaction);
+ Core.getInstance().getServer().getPluginManager().callEvent(completeEvent);
+ p.openInventory(new AuctionGUI(p).getInventory());
}
}
} else if (clicked.isSimilar(AuctionAPI.getInstance().fill("&c&lNo", 14))) {
p.closeInventory();
- p.openInventory(AuctionGUI.getInstance(p).getInventory());
+ p.openInventory(new AuctionGUI(p).getInventory());
}
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ExpiredGUI.java b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ExpiredGUI.java
index 74000f3..e464f0b 100644
--- a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ExpiredGUI.java
+++ b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ExpiredGUI.java
@@ -1,10 +1,129 @@
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.auction.AuctionPlayer;
+import com.shadebyte.auctionhouse.inventory.AGUI;
+import com.shadebyte.auctionhouse.util.NBTEditor;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+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.List;
+
/**
* The current file has been created by Kiran Hart
* Date Created: 7/6/2018
* Time Created: 11:56 AM
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
*/
-public class ExpiredGUI {
+public class ExpiredGUI implements AGUI {
+
+ private Player p;
+ private List> chunks;
+ private int page = 1;
+
+ public ExpiredGUI(Player p) {
+ this.p = p;
+ chunks = Lists.partition(AuctionAPI.getInstance().getAllExpiredItems(p), 45);
+ }
+
+ @Override
+ public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
+ e.setCancelled(true);
+
+ try {
+ if (page >= 1 && slot == 48) p.openInventory(this.setPage(this.getPage() - 1).getInventory());
+ if (page >= 1 && slot == 50) p.openInventory(this.setPage(this.getPage() + 1).getInventory());
+ } catch (Exception e1) {
+ }
+
+ if (slot >= 0 & slot <= 44) {
+
+ if (clicked == null || clicked.getType() == Material.AIR) {
+ return;
+ }
+
+ String key = (String) NBTEditor.getItemTag(clicked, "ExpiredAuctionItem");
+ ItemStack stack = Core.getInstance().getData().getConfig().getItemStack("expired." + p.getUniqueId().toString() + "." + key + ".item");
+ Core.getInstance().getData().getConfig().set("expired." + p.getUniqueId().toString() + "." + key, null);
+ Core.getInstance().getData().saveConfig();
+ if (AuctionAPI.getInstance().availableSlots(p.getInventory()) >= 1) {
+ p.getInventory().addItem(stack);
+ } else {
+ p.getWorld().dropItemNaturally(p.getLocation(), stack);
+ }
+ p.closeInventory();
+ p.openInventory(new ExpiredGUI(p).getInventory());
+ }
+
+ if (slot == 49) {
+ if (Core.getInstance().getData().getConfig().getConfigurationSection("expired." + p.getUniqueId().toString()) != null) {
+ if (Core.getInstance().getData().getConfig().getConfigurationSection("expired." + p.getUniqueId().toString()).getKeys(false).size() >= 1) {
+ Core.getInstance().getData().getConfig().getConfigurationSection("expired." + p.getUniqueId().toString()).getKeys(false).forEach(node -> {
+ ItemStack stack = Core.getInstance().getData().getConfig().getItemStack("expired." + p.getUniqueId().toString() + "." + node + ".item");
+ Core.getInstance().getData().getConfig().set("expired." + p.getUniqueId().toString() + "." + node, null);
+ Core.getInstance().getData().saveConfig();
+ if (AuctionAPI.getInstance().availableSlots(p.getInventory()) >= 1) {
+ p.getInventory().addItem(stack);
+ } else {
+ p.getWorld().dropItemNaturally(p.getLocation(), stack);
+ }
+ });
+
+ p.closeInventory();
+ p.openInventory(new ExpiredGUI(p).getInventory());
+ }
+ }
+ }
+
+ if (slot == 45) {
+ p.closeInventory();
+ p.openInventory(new AuctionGUI(p).getInventory());
+ }
+ }
+
+ @Override
+ public void close(InventoryCloseEvent e) {
+
+ }
+
+ @Override
+ public Inventory getInventory() {
+ Inventory inventory = Bukkit.createInventory(this, 54, ChatColor.translateAlternateColorCodes('&', Core.getInstance().getConfig().getString("gui.collection.title")));
+
+ //Bottom Row
+ inventory.setItem(45, AuctionAPI.getInstance().createConfigItem("gui.collection.items.return", 0, 0));
+ inventory.setItem(48, AuctionAPI.getInstance().createConfigItem("gui.collection.items.previouspage", 0, 0));
+ inventory.setItem(49, AuctionAPI.getInstance().createConfigItem("gui.collection.items.claimall", 0, 0));
+ inventory.setItem(50, AuctionAPI.getInstance().createConfigItem("gui.collection.items.nextpage", 0, 0));
+ inventory.setItem(53, AuctionAPI.getInstance().createConfigItem("gui.collection.items.tutorial", 0, 0));
+
+ if (new AuctionPlayer(p).getTotalExpiredAuctions() == 0) {
+ return inventory;
+ }
+
+ if (chunks.size() != 0)
+ chunks.get(getPage() - 1).forEach(item -> inventory.setItem(inventory.firstEmpty(), item));
+
+ return inventory;
+ }
+
+ public ExpiredGUI setPage(int page) {
+ if (page <= 0)
+ this.page = 1;
+ else
+ this.page = page;
+ return this;
+ }
+
+ public int getPage() {
+ return page;
+ }
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ListingsGUI.java b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ListingsGUI.java
index dd4cd83..ee95d9f 100644
--- a/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ListingsGUI.java
+++ b/src/main/java/com/shadebyte/auctionhouse/inventory/inventories/ListingsGUI.java
@@ -1,10 +1,107 @@
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.auction.AuctionItem;
+import com.shadebyte.auctionhouse.auction.AuctionPlayer;
+import com.shadebyte.auctionhouse.inventory.AGUI;
+import com.shadebyte.auctionhouse.util.NBTEditor;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.ClickType;
+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.List;
+
/**
* The current file has been created by Kiran Hart
* Date Created: 7/6/2018
* Time Created: 11:56 AM
* Usage of any code found within this class is prohibited unless given explicit permission otherwise.
*/
-public class ListingsGUI {
+public class ListingsGUI implements AGUI {
+
+ private Player p;
+ private List> chunks;
+ private int page = 1;
+
+ public ListingsGUI(Player p) {
+ this.p = p;
+ chunks = Lists.partition(new AuctionPlayer(p).getAuctionItems(), 45);
+ }
+
+
+ @Override
+ public void click(InventoryClickEvent e, ItemStack clicked, int slot) {
+ e.setCancelled(true);
+
+ try {
+ if (page >= 1 && slot == 48) p.openInventory(this.setPage(this.getPage() - 1).getInventory());
+ if (page >= 1 && slot == 50) p.openInventory(this.setPage(this.getPage() + 1).getInventory());
+ } catch (Exception e1) {
+ }
+
+ if (slot >= 0 & slot <= 44) {
+ if (clicked == null || clicked.getType() == Material.AIR) {
+ return;
+ }
+
+ AuctionItem item = null;
+ if (e.getClick() == ClickType.LEFT) {
+ String key = (String) NBTEditor.getItemTag(clicked, "AuctionItemKey");
+ for (AuctionItem auctionItem : Core.getInstance().auctionItems) {
+ if (auctionItem.getKey().equalsIgnoreCase(key)) item = auctionItem;
+ }
+
+ item.setTime(0);
+ Core.getInstance().getData().getConfig().set("expired." + item.getOwner() + "." + item.getKey() + ".item", item.getItem());
+ Core.getInstance().getData().getConfig().set("expired." + item.getOwner() + "." + item.getKey() + ".display", AuctionAPI.getInstance().expiredAuctionItem(item));
+ Core.getInstance().getData().saveConfig();
+ Core.getInstance().auctionItems.remove(item);
+ p.closeInventory();
+ p.openInventory(new ListingsGUI(p).getInventory());
+ }
+ }
+
+ if (slot == 45) {
+ p.closeInventory();
+ p.openInventory(new AuctionGUI(p).getInventory());
+ }
+ }
+
+ @Override
+ public void close(InventoryCloseEvent e) {
+
+ }
+
+ @Override
+ public Inventory getInventory() {
+ Inventory inventory = Bukkit.createInventory(this, 54, Core.getInstance().getConfig().getString("gui.active.title"));
+ inventory.setItem(45, AuctionAPI.getInstance().createConfigItem("gui.active.items.return", 0, 0));
+ inventory.setItem(48, AuctionAPI.getInstance().createConfigItem("gui.active.items.previouspage", 0, 0));
+ inventory.setItem(50, AuctionAPI.getInstance().createConfigItem("gui.active.items.nextpage", 0, 0));
+ inventory.setItem(53, AuctionAPI.getInstance().createConfigItem("gui.active.items.tutorial", 0, 0));
+
+ if (chunks.size() != 0)
+ chunks.get(getPage() - 1).forEach(item -> inventory.setItem(inventory.firstEmpty(), item.listingStack()));
+
+ return inventory;
+ }
+
+ public ListingsGUI setPage(int page) {
+ if (page <= 0)
+ this.page = 1;
+ else
+ this.page = page;
+ return this;
+ }
+
+ public int getPage() {
+ return page;
+ }
}
diff --git a/src/main/java/com/shadebyte/auctionhouse/util/ConfigWrapper.java b/src/main/java/com/shadebyte/auctionhouse/util/storage/ConfigWrapper.java
similarity index 97%
rename from src/main/java/com/shadebyte/auctionhouse/util/ConfigWrapper.java
rename to src/main/java/com/shadebyte/auctionhouse/util/storage/ConfigWrapper.java
index b962c72..3c0fc9b 100644
--- a/src/main/java/com/shadebyte/auctionhouse/util/ConfigWrapper.java
+++ b/src/main/java/com/shadebyte/auctionhouse/util/storage/ConfigWrapper.java
@@ -1,4 +1,4 @@
-package com.shadebyte.auctionhouse.util;
+package com.shadebyte.auctionhouse.util.storage;
/**
* The current file has been created by Kiran Hart
diff --git a/src/main/java/com/shadebyte/auctionhouse/util/storage/MySQL.java b/src/main/java/com/shadebyte/auctionhouse/util/storage/MySQL.java
new file mode 100644
index 0000000..552f465
--- /dev/null
+++ b/src/main/java/com/shadebyte/auctionhouse/util/storage/MySQL.java
@@ -0,0 +1,45 @@
+package com.shadebyte.auctionhouse.util.storage;
+
+import com.shadebyte.auctionhouse.Core;
+import com.shadebyte.auctionhouse.api.AuctionAPI;
+import com.shadebyte.auctionhouse.auction.Transaction;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+
+import java.sql.PreparedStatement;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: 7/23/2018
+ * Time Created: 9:49 PM
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
+ */
+public class MySQL {
+
+ public void logTransaction(Transaction transaction) {
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(Core.getInstance(), () -> {
+ try {
+ PreparedStatement insert = Core.getInstance().getConnection().prepareStatement("INSERT INTO transactions (buyer, seller, auctiontype, startprice, buynowprice, increment, item, displayname, lore, enchantments, auctionid, timesold, finalprice) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
+ insert.setString(1, transaction.getBuyer());
+ insert.setString(2, transaction.getAuctionItem().getOwner());
+ insert.setString(3, transaction.getTransactionType().getTransactionType());
+ insert.setInt(4, transaction.getAuctionItem().getStartPrice());
+ insert.setInt(5, transaction.getAuctionItem().getBuyNowPrice());
+ insert.setInt(6, transaction.getAuctionItem().getBidIncrement());
+ insert.setString(7, transaction.getAuctionItem().getItem().getTypeId() + "-" + transaction.getAuctionItem().getItem().getDurability());
+
+ insert.setString(8, AuctionAPI.getInstance().getSQLDisplayName(transaction.getAuctionItem().getItem()));
+ insert.setString(9, AuctionAPI.getInstance().getSQLLore(transaction.getAuctionItem().getItem()));
+ insert.setString(10, AuctionAPI.getInstance().getSQLEnchantments(transaction.getAuctionItem().getItem()));
+
+ insert.setString(11, transaction.getAuctionItem().getKey());
+ insert.setString(12, AuctionAPI.getInstance().getDate(System.currentTimeMillis()));
+ insert.setInt(13, (transaction.getTransactionType() == Transaction.TransactionType.BOUGHT) ? transaction.getAuctionItem().getBuyNowPrice() : transaction.getAuctionItem().getCurrentPrice());
+ insert.executeUpdate();
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&aRecorded transaction id: &b" + transaction.getAuctionItem().getKey() + "&a to database."));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ });
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 671db61..a13fb6e 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -5,12 +5,12 @@
lang: "en_US"
settings:
- default-auction-time: 3600 # 60 Minutes by default
+ default-auction-time: 15 # 15 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-price: 1
+ min-auction-start: 1
min-auction-increment: 1
owner-can-purchase-own: false
owner-can-bid-own: false
@@ -18,20 +18,103 @@ settings:
increase-on-bid: true
increase-amount: 10 #10 Seconds by default
+#MySql stuff for databases if you want
+database:
+ enabled: true
+ host: 162.241.217.18
+ port: 3306
+ database: "kiranhar_auctionhouse"
+ username: "kiranhar_admin"
+ password: "TweetyHart1."
+
+discord:
+ enabled: true
+ webhook: "https://discordapp.com/api/webhooks/470085392901734410/_ls7Ps5GzlKqBJlHLaZt6GZgVTKkuwuIuWK1JU5j_pt-DwWhSYAITlI17ePiIuNTmdua"
+ title: "Auction House"
+ description: "A new item has been listed!"
+ description-complete: "A transaction has been completed!"
+ username: "Auction House"
+ profilepicture: "https://vignette.wikia.nocookie.net/minecraftuniverse/images/2/2c/Gold_Chest_%28M2%29.png/revision/latest?cb=20130121082341"
+
+receipt:
+ give-on-transaction: true
+ item: "PAPER:0"
+ name: "&E&LReceipt &7(Right-Click)"
+ lore:
+ - "&7Purchase proof of the purchased item."
+ - ""
+ - "&bSeller&f: &E{seller}"
+ - "&bPrice&f: &a${price}"
+ - "&ePurchased on&f: &a{date} &fat &A{time}"
+
gui:
+ active:
+ title: "&7Your Current Listings"
+ items:
+ return:
+ item: "CHEST:0"
+ name: "&e&lReturn to Auction House"
+ lore:
+ - "&7Click here to return to the"
+ - "&7auction house main menu."
+ previouspage:
+ item: "PAPER:0"
+ name: "&e&l<- Previous Page"
+ lore:
+ - "&7Go back"
+ nextpage:
+ item: "PAPER:0"
+ name: "&e&lPrevious Page ->"
+ lore:
+ - "&7Next Page"
+ tutorial:
+ item: "BOOK:0"
+ name: "&e&lTutorial"
+ lore:
+ - "&7These are your current listings, all of"
+ - "&7the items you currently have listed on"
+ - "&7the auction house are displayed here."
+ - ""
+ - "&7You can cancel and view your listing's"
+ - "&7expire time here."
+ collection:
+ title: "&7Cancelled / Expired Listings"
+ items:
+ return:
+ item: "CHEST:0"
+ name: "&e&lReturn to Auction House"
+ lore:
+ - "&7Click here to return to the"
+ - "&7auction house main menu."
+ previouspage:
+ item: "PAPER:0"
+ name: "&e&l<- Previous Page"
+ lore:
+ - "&7Go back"
+ nextpage:
+ item: "PAPER:0"
+ name: "&e&lPrevious Page ->"
+ lore:
+ - "&7Next Page"
+ claimall:
+ item: "ENDER_CHEST:0"
+ name: "&e&lClaim All"
+ lore:
+ - "&7Click here to claim all"
+ - "&7your Collection Bin items."
+ tutorial:
+ item: "BOOK:0"
+ name: "&e&lTutorial"
+ lore:
+ - "&7This page houses all of your cancelled and"
+ - "&7expired items, when a listing is cancelled"
+ - "&7or expires you will be able to return that"
+ - "&7item back to you from this menu."
+ - ""
+ - "&7Just click on the item and if you have enough"
+ - "&7inventory space you will receive the item."
confirm:
title: "&e&lConfirm Purchase"
- items:
- no:
- item: "STAINED_GLASS_PANE:14"
- name: "&C&LNo"
- lore:
- - "&7Do not purchase this item."
- yes:
- item: "STAINED_GLASS_PANE:5"
- name: "&a&lYes"
- lore:
- - "&7Purchase for &a${price}"
auction:
title: "&7Auction House"
items:
diff --git a/src/main/resources/en_US.lang b/src/main/resources/en_US.lang
index 10594c0..c523ff2 100644
--- a/src/main/resources/en_US.lang
+++ b/src/main/resources/en_US.lang
@@ -10,6 +10,13 @@ notenoughmoney = "&CYou do not have enough money!"
cantbidonown = "&cYou cannot bid on your own item!"
cantbuyown = "&cYou cannot buy your own item!"
+price.max.start = "&cPlease start auction with a lower price."
+price.max.auction = "&cPlease start with a lower bid price."
+price.max.increment = "&cPlease decrease the bid increment"
+price.min.start = "&cPlease start auction with a higher price."
+price.min.auction = "&cPlease start with a higher bid price."
+price.min.increment = "&cPlease increase the bid increment"
+
auction.listed = "&eYou listed &6{itemname} &efor &a${price}"
auction.max = "&cYou cannot auction more items, please upgrade to do so."
auction.buy = "&eYou purchased &6{itemname} &Efor &A${price}"
diff --git a/src/test/java/com/shadebyte/server/ServerTest.java b/src/test/java/com/shadebyte/server/ServerTest.java
new file mode 100644
index 0000000..b47fc48
--- /dev/null
+++ b/src/test/java/com/shadebyte/server/ServerTest.java
@@ -0,0 +1,18 @@
+package com.shadebyte.server;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: 7/23/2018
+ * Time Created: 9:00 PM
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise.
+ */
+public class ServerTest {
+
+ public static void main(String[] args) {
+
+ System.out.println(new SimpleDateFormat("MMMM dd yyyy").format(new Date(System.currentTimeMillis())));
+ }
+}