mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-21 11:45:11 +01:00
add player name to data.yml
avoids having to do offline lookups using the uuid
This commit is contained in:
parent
a9b885d3e6
commit
9f98b87aba
@ -269,6 +269,7 @@ public class Methods {
|
||||
}
|
||||
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", winner);
|
||||
data.set("OutOfTime/Cancelled." + num + ".Name", data.getString("Items." + i + ".TopBidderName", "None"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", fullExpireTime.getTimeInMillis());
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Item", data.getString("Items." + i + ".Item"));
|
||||
@ -284,6 +285,7 @@ public class Methods {
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Name", data.getString("Items." + i + ".Name", "None"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", fullExpireTime.getTimeInMillis());
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Item", data.getString("Items." + i + ".Item"));
|
||||
|
@ -24,6 +24,8 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -306,6 +308,7 @@ public class AuctionsMenu extends Holder {
|
||||
this.server.getPluginManager().callEvent(auctionCancelledEvent);
|
||||
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", section.getString("Seller"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Name", section.getString("Name"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", section.getLong("Full-Time"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", section.getInt("StoreID"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Item", auction.getString("Item"));
|
||||
@ -450,7 +453,7 @@ public class AuctionsMenu extends Holder {
|
||||
|
||||
final String priceFormat = String.format(Locale.ENGLISH, "%,d", price);
|
||||
|
||||
final OfflinePlayer player = Methods.getOfflinePlayer(seller);
|
||||
final String player = auction.getString("Name", "None");
|
||||
|
||||
final String time = Methods.convertToTime(auction.getLong("Time-Till-Expire"));
|
||||
|
||||
@ -459,20 +462,14 @@ public class AuctionsMenu extends Holder {
|
||||
lore.add(" ");
|
||||
|
||||
if (this.shopType != null && this.shopType == ShopType.BID && auction.getBoolean("Biddable") || auction.getBoolean("Biddable")) {
|
||||
final String bidder = auction.getString("TopBidder", "None");
|
||||
|
||||
final OfflinePlayer top_bidder = bidder.equalsIgnoreCase("None") ? null : Methods.getOfflinePlayer(bidder);
|
||||
final String top_bidder = auction.getString("TopBidderName", "None");
|
||||
|
||||
for (final String line : this.config.getStringList("Settings.GUISettings.Bidding")) {
|
||||
String newLine = line.replace("%TopBid%", priceFormat).replace("%topbid%", priceFormat);
|
||||
|
||||
final String targetName = player.getName() == null ? "N/A" : player.getName();
|
||||
newLine = line.replace("%Seller%", player).replace("%seller%", player);
|
||||
|
||||
newLine = line.replace("%Seller%", targetName).replace("%seller%", targetName);
|
||||
|
||||
final String bidderName = top_bidder == null ? "N/A" : top_bidder.getName() == null ? "N/A" : top_bidder.getName();
|
||||
|
||||
newLine = line.replace("%TopBidder%", bidderName).replace("%topbid%", bidderName);
|
||||
newLine = line.replace("%TopBidder%", top_bidder).replace("%topbid%", top_bidder);
|
||||
|
||||
lore.add(newLine.replace("%Time%", time).replace("%time%", time));
|
||||
}
|
||||
@ -480,9 +477,7 @@ public class AuctionsMenu extends Holder {
|
||||
for (final String line : this.config.getStringList("Settings.GUISettings.SellingItemLore")) {
|
||||
String newLine = line.replace("%TopBid%", priceFormat).replace("%topbid%", priceFormat);
|
||||
|
||||
final String targetName = player.getName() == null ? "N/A" : player.getName();
|
||||
|
||||
newLine = line.replace("%Seller%", targetName).replace("%seller%", targetName);
|
||||
newLine = line.replace("%Seller%", player).replace("%seller%", player);
|
||||
|
||||
lore.add(newLine.replace("%Time%", time).replace("%time%", time).replace("%price%", priceFormat).replace("%Price%", priceFormat));
|
||||
}
|
||||
|
@ -150,6 +150,7 @@ public class BidMenu extends Holder {
|
||||
|
||||
data.set("Items." + id + ".Price", bid);
|
||||
data.set("Items." + id + ".TopBidder", player.getUniqueId().toString());
|
||||
data.set("Items." + id + ".TopBidderName", player.getName());
|
||||
|
||||
final Map<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("%Bid%", String.valueOf(bid));
|
||||
@ -240,27 +241,14 @@ public class BidMenu extends Holder {
|
||||
String price = Methods.getPrice(id, false);
|
||||
String time = Methods.convertToTime(data.getLong("Items." + id + ".Time-Till-Expire"));
|
||||
|
||||
OfflinePlayer target = null;
|
||||
|
||||
String seller = data.getString("Items." + id + ".Seller");
|
||||
|
||||
if (seller != null) {
|
||||
target = Methods.getOfflinePlayer(seller);
|
||||
}
|
||||
|
||||
OfflinePlayer bidder = null;
|
||||
|
||||
String bid = data.getString("Items." + id + ".TopBidder");
|
||||
|
||||
if (bid != null && !bid.equals("None")) {
|
||||
bidder = Methods.getOfflinePlayer(bid);
|
||||
}
|
||||
String seller = data.getString("Items." + id + ".Name", "None");
|
||||
String bidder = data.getString("Items." + id + ".TopBidderName", "None");
|
||||
|
||||
for (String l : config.getStringList("Settings.GUISettings.Bidding")) {
|
||||
lore.add(l.replace("%TopBid%", price)
|
||||
.replace("%topbid%", price)
|
||||
.replace("%Seller%", target != null ? target.getName() : "N/A").replace("%seller%", target != null ? target.getName() : "N/A")
|
||||
.replace("%TopBidder%", bidder != null ? bidder.getName() : "N/A").replace("%topbidder%", bidder != null ? bidder.getName() : "N/A")
|
||||
.replace("%Seller%", seller).replace("%seller%", seller)
|
||||
.replace("%TopBidder%", bidder).replace("%topbidder%", bidder)
|
||||
.replace("%Time%", time)
|
||||
.replace("%time%", time));
|
||||
}
|
||||
|
@ -63,7 +63,6 @@ public class BuyingMenu extends Holder {
|
||||
"Cancel"
|
||||
));
|
||||
|
||||
|
||||
for (final String key : this.options) {
|
||||
if (!this.config.contains("Settings.GUISettings.OtherSettings." + key)) {
|
||||
continue;
|
||||
@ -118,18 +117,12 @@ public class BuyingMenu extends Holder {
|
||||
String price = Methods.getPrice(this.id, false);
|
||||
String time = Methods.convertToTime(this.data.getLong("Items." + this.id + ".Time-Till-Expire"));
|
||||
|
||||
OfflinePlayer target = null;
|
||||
|
||||
String id = this.data.getString("Items." + this.id + ".Seller");
|
||||
|
||||
if (id != null) {
|
||||
target = Methods.getOfflinePlayer(id);
|
||||
}
|
||||
String id = this.data.getString("Items." + this.id + ".Name", "None");
|
||||
|
||||
for (String l : config.getStringList("Settings.GUISettings.SellingItemLore")) {
|
||||
lore.add(l.replace("%Price%", price).replace("%price%", price)
|
||||
.replace("%Seller%", target != null ? target.getName() : "N/A")
|
||||
.replace("%seller%", target != null ? target.getName() : "N/A")
|
||||
.replace("%Seller%", id)
|
||||
.replace("%seller%", id)
|
||||
.replace("%Time%", time)
|
||||
.replace("%time%", time));
|
||||
}
|
||||
|
@ -327,13 +327,12 @@ public class AuctionCommand implements CommandExecutor {
|
||||
return true;
|
||||
}*/
|
||||
|
||||
String seller = player.getUniqueId().toString();
|
||||
|
||||
int num = 1;
|
||||
|
||||
for (; data.contains("Items." + num); num++) ;
|
||||
data.set("Items." + num + ".Price", price);
|
||||
data.set("Items." + num + ".Seller", seller);
|
||||
data.set("Items." + num + ".Seller", player.getUniqueId().toString());
|
||||
data.set("Items." + num + ".Name", player.getName());
|
||||
|
||||
if (args[0].equalsIgnoreCase("bid")) {
|
||||
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Bid-Time", "2m 30s")));
|
||||
@ -363,6 +362,7 @@ public class AuctionCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
data.set("Items." + num + ".TopBidder", "None");
|
||||
data.set("Items." + num + ".TopBidderName", "None");
|
||||
|
||||
ItemStack stack = item.clone();
|
||||
stack.setAmount(amount);
|
||||
|
Loading…
Reference in New Issue
Block a user