mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-01-08 12:57:35 +01:00
1.0.8, Added auto save, buyers can no longer bid on an item if they don't have enough money (bid increment + current price). debugger is enabled by default in config, and new option to disable hardware info reports
This commit is contained in:
parent
f160d29d92
commit
c5d4210e1c
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.shadebyte</groupId>
|
<groupId>com.shadebyte</groupId>
|
||||||
<artifactId>auctionhouse</artifactId>
|
<artifactId>auctionhouse</artifactId>
|
||||||
<version>1.0.7</version>
|
<version>1.0.8</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>AuctionHouse</name>
|
<name>AuctionHouse</name>
|
||||||
|
@ -109,17 +109,20 @@ public final class Core extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (getConfig().getBoolean("send-report-data")) {
|
||||||
MassiveStats stats = new MassiveStats(this);
|
try {
|
||||||
stats.setListenerDisabled(false);
|
MassiveStats stats = new MassiveStats(this);
|
||||||
} catch (Exception e) {
|
stats.setListenerDisabled(false);
|
||||||
Debugger.report(e);
|
} catch (Exception e) {
|
||||||
|
Debugger.report(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAuctions();
|
loadAuctions();
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bFound a total of &6" + Transaction.getTotalTransactions() + " &brecorded transactions"));
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bFound a total of &6" + Transaction.getTotalTransactions() + " &brecorded transactions"));
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bAuction House finished loading, took " + (System.currentTimeMillis() - startTime) + " ms"));
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&bAuction House finished loading, took " + (System.currentTimeMillis() - startTime) + " ms"));
|
||||||
tickAuctions();
|
tickAuctions();
|
||||||
|
Bukkit.getServer().getScheduler().runTaskTimerAsynchronously(this, () -> saveAllAuctions(), 0, 20 * getConfig().getInt("auto-save-increment"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -133,6 +136,45 @@ public final class Core extends JavaPlugin {
|
|||||||
hikari.close();
|
hikari.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveAllAuctions() {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&b============================"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&aGETTING READY TO PERFORM SAVE"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&b============================"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', " "));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', " "));
|
||||||
|
long autoSaveStart = System.currentTimeMillis();
|
||||||
|
clearAuctionDataFolder();
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e---------------------------"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cFinished clearing data.yml"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e---------------------------"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', " "));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', " "));
|
||||||
|
saveAuctions();
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e-------------------------------"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cFinished saving active auctions"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e-------------------------------"));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', " "));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', " "));
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&eAuction Saving took: " + (System.currentTimeMillis() - autoSaveStart) + "ms"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearAuctionDataFolder() {
|
||||||
|
try {
|
||||||
|
ConfigurationSection section = data.getConfig().getConfigurationSection("active");
|
||||||
|
if (section.getKeys(false).size() != 0) {
|
||||||
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(this, () -> {
|
||||||
|
for (String node : section.getKeys(false)) {
|
||||||
|
int xNode = Integer.parseInt(node);
|
||||||
|
data.getConfig().set("active." + xNode, null);
|
||||||
|
}
|
||||||
|
data.saveConfig();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Debugger.report(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadAuctions() {
|
private void loadAuctions() {
|
||||||
try {
|
try {
|
||||||
ConfigurationSection section = data.getConfig().getConfigurationSection("active");
|
ConfigurationSection section = data.getConfig().getConfigurationSection("active");
|
||||||
@ -193,10 +235,13 @@ public final class Core extends JavaPlugin {
|
|||||||
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())));
|
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())));
|
||||||
getEconomy().withdrawPlayer(highestBidder, auctionItem.getCurrentPrice());
|
getEconomy().withdrawPlayer(highestBidder, auctionItem.getCurrentPrice());
|
||||||
getEconomy().depositPlayer(Bukkit.getOfflinePlayer(UUID.fromString(auctionItem.getOwner())), auctionItem.getCurrentPrice());
|
getEconomy().depositPlayer(Bukkit.getOfflinePlayer(UUID.fromString(auctionItem.getOwner())), auctionItem.getCurrentPrice());
|
||||||
if (AuctionAPI.getInstance().availableSlots(highestBidder.getInventory()) < 1)
|
|
||||||
highestBidder.getWorld().dropItemNaturally(highestBidder.getLocation(), auctionItem.getItem());
|
if (AuctionAPI.getInstance().availableSlots(highestBidder.getInventory()) == 0) {
|
||||||
else
|
data.getConfig().set("expired." + auctionItem.getHighestBidder() + "." + auctionItem.getKey() + ".item", auctionItem.getItem());
|
||||||
|
data.getConfig().set("expired." + auctionItem.getHighestBidder() + "." + auctionItem.getKey() + ".display", AuctionAPI.getInstance().expiredAuctionItem(auctionItem));
|
||||||
|
} else
|
||||||
highestBidder.getInventory().addItem(auctionItem.getItem());
|
highestBidder.getInventory().addItem(auctionItem.getItem());
|
||||||
|
|
||||||
Transaction transaction = new Transaction(Transaction.TransactionType.AUCTION_WON, auctionItem, highestBidder.getUniqueId().toString(), System.currentTimeMillis());
|
Transaction transaction = new Transaction(Transaction.TransactionType.AUCTION_WON, auctionItem, highestBidder.getUniqueId().toString(), System.currentTimeMillis());
|
||||||
transaction.saveTransaction();
|
transaction.saveTransaction();
|
||||||
getServer().getPluginManager().callEvent(new TransactionCompleteEvent(transaction));
|
getServer().getPluginManager().callEvent(new TransactionCompleteEvent(transaction));
|
||||||
|
@ -91,7 +91,7 @@ public class AuctionGUI implements AGUI {
|
|||||||
if (auctionItem.getKey().equalsIgnoreCase(key)) item = auctionItem;
|
if (auctionItem.getKey().equalsIgnoreCase(key)) item = auctionItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core.getEconomy().getBalance(p) < item.getBidIncrement()) {
|
if (Core.getEconomy().getBalance(p) < item.getBidIncrement() + item.getCurrentPrice()) {
|
||||||
e.getClickedInventory().setItem(slot, AuctionAPI.getInstance().createConfigItem("gui.auction.items.not-enough-money", 0, 0));
|
e.getClickedInventory().setItem(slot, AuctionAPI.getInstance().createConfigItem("gui.auction.items.not-enough-money", 0, 0));
|
||||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(Core.getInstance(), () -> {
|
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(Core.getInstance(), () -> {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
|
@ -42,7 +42,13 @@ public class ConfirmationGUI implements AGUI {
|
|||||||
} else {
|
} else {
|
||||||
Core.getEconomy().withdrawPlayer(p, auctionItem.getBuyNowPrice());
|
Core.getEconomy().withdrawPlayer(p, auctionItem.getBuyNowPrice());
|
||||||
Core.getEconomy().depositPlayer(Bukkit.getOfflinePlayer(UUID.fromString(auctionItem.getOwner())), auctionItem.getBuyNowPrice());
|
Core.getEconomy().depositPlayer(Bukkit.getOfflinePlayer(UUID.fromString(auctionItem.getOwner())), auctionItem.getBuyNowPrice());
|
||||||
p.getInventory().addItem(auctionItem.getItem());
|
|
||||||
|
if (AuctionAPI.getInstance().availableSlots(p.getInventory()) == 0) {
|
||||||
|
Core.getInstance().getData().getConfig().set("expired." + p.getUniqueId().toString() + "." + auctionItem.getKey() + ".item", auctionItem.getItem());
|
||||||
|
Core.getInstance().getData().getConfig().set("expired." + p.getUniqueId().toString() + "." + auctionItem.getKey() + ".display", AuctionAPI.getInstance().expiredAuctionItem(auctionItem));
|
||||||
|
} else
|
||||||
|
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())));
|
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()));
|
Player owner = Bukkit.getPlayer(UUID.fromString(auctionItem.getOwner()));
|
||||||
|
|
||||||
@ -60,6 +66,9 @@ public class ConfirmationGUI implements AGUI {
|
|||||||
Core.getInstance().getServer().getPluginManager().callEvent(completeEvent);
|
Core.getInstance().getServer().getPluginManager().callEvent(completeEvent);
|
||||||
p.openInventory(new AuctionGUI(p).getInventory());
|
p.openInventory(new AuctionGUI(p).getInventory());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(new AuctionGUI(p).getInventory());
|
||||||
}
|
}
|
||||||
} else if (clicked.isSimilar(AuctionAPI.getInstance().fill("&c&lNo", 14))) {
|
} else if (clicked.isSimilar(AuctionAPI.getInstance().fill("&c&lNo", 14))) {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
#Lang name formats: https://www.science.co.il/language/Locale-codes.php
|
#Lang name formats: https://www.science.co.il/language/Locale-codes.php
|
||||||
lang: "en_US"
|
lang: "en_US"
|
||||||
debugger: true
|
debugger: true
|
||||||
|
auto-save-increment: 600 #Auto save active auctions every 10 minutes
|
||||||
|
send-report-data: true #This will send hardware information to MassiveStats
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
default-auction-time: 150 # 15 Minutes by default
|
default-auction-time: 900 # 15 Minutes by default
|
||||||
max-auction-price: 2000000000
|
max-auction-price: 2000000000
|
||||||
max-auction-start: 2000000000
|
max-auction-start: 2000000000
|
||||||
max-auction-increment: 2000000000
|
max-auction-increment: 2000000000
|
||||||
|
Loading…
Reference in New Issue
Block a user