mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-25 05:55:13 +01:00
🔨 fix bundle %item_name% variable not being replaced
Took 30 minutes
This commit is contained in:
parent
b8238bbd4d
commit
c58a025375
@ -221,7 +221,6 @@ public class AuctionAPI {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
config.set("i", itemStack);
|
||||
return config.saveToString();
|
||||
// return DatatypeConverter.printBase64Binary(config.saveToString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public static ItemStack decodeItem(String string) {
|
||||
@ -581,7 +580,7 @@ public class AuctionAPI {
|
||||
Objects.requireNonNull(items, "Cannot create a bundled item with no items");
|
||||
ItemStack item = QuickItem
|
||||
.of(Settings.ITEM_BUNDLE_ITEM.getString())
|
||||
.name(Settings.ITEM_BUNDLE_NAME.getString())
|
||||
.name(Replacer.replaceVariables(Settings.ITEM_BUNDLE_NAME.getString(),"item_name", getItemName(baseItem)))
|
||||
.lore(Replacer.replaceVariables(Settings.ITEM_BUNDLE_LORE.getStringList(), "item_name", getItemName(baseItem)))
|
||||
.make();
|
||||
|
||||
|
@ -31,6 +31,7 @@ import ca.tweetzy.auctionhouse.transaction.TransactionViewFilter;
|
||||
import ca.tweetzy.flight.database.*;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -261,7 +262,10 @@ public class DataManager extends DataManagerAbstract {
|
||||
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "transactions")) {
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
transactions.add(extractTransaction(resultSet));
|
||||
|
||||
final Transaction transaction = extractTransaction(resultSet);
|
||||
if (transaction != null)
|
||||
transactions.add(transaction);
|
||||
}
|
||||
|
||||
callback.accept(null, transactions);
|
||||
@ -291,7 +295,10 @@ public class DataManager extends DataManagerAbstract {
|
||||
if (callback != null) {
|
||||
ResultSet res = fetch.executeQuery();
|
||||
res.next();
|
||||
callback.accept(null, extractTransaction(res));
|
||||
|
||||
final Transaction inserted = extractTransaction(res);
|
||||
|
||||
callback.accept(null, inserted);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -539,10 +546,22 @@ public class DataManager extends DataManagerAbstract {
|
||||
|
||||
public void insertAuctionPlayer(AuctionPlayer auctionPlayer, Callback<AuctionPlayer> callback) {
|
||||
this.runAsync(() -> this.databaseConnector.connect(connection -> {
|
||||
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + getTablePrefix() + "player (uuid, filter_sale_type, filter_item_category, filter_sort_type, last_listed_item) VALUES (?, ?, ?, ?, ?)")) {
|
||||
PreparedStatement fetch = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "player WHERE uuid = ?");
|
||||
try (PreparedStatement statement = connection.prepareStatement(
|
||||
"INSERT INTO " + getTablePrefix() + "player (uuid, filter_sale_type, filter_item_category, filter_sort_type, last_listed_item) VALUES (?,?,?,?,?)"
|
||||
)) {
|
||||
PreparedStatement fetch = connection.prepareStatement(
|
||||
"SELECT * FROM " + this.getTablePrefix() + "player WHERE uuid =?"
|
||||
);
|
||||
|
||||
// Set parameters for the fetch query
|
||||
fetch.setString(1, auctionPlayer.getUuid().toString());
|
||||
|
||||
// Execute the fetch query
|
||||
ResultSet res = fetch.executeQuery();
|
||||
|
||||
// Check if the UUID already exists
|
||||
if (!res.next()) {
|
||||
// UUID does not exist, proceed with insertion
|
||||
statement.setString(1, auctionPlayer.getPlayer().getUniqueId().toString());
|
||||
statement.setString(2, auctionPlayer.getSelectedSaleType().name());
|
||||
statement.setString(3, auctionPlayer.getSelectedFilter().name());
|
||||
@ -550,10 +569,14 @@ public class DataManager extends DataManagerAbstract {
|
||||
statement.setLong(5, auctionPlayer.getLastListedItem());
|
||||
statement.executeUpdate();
|
||||
|
||||
// After successful insertion, call the callback with the newly inserted player
|
||||
if (callback != null) {
|
||||
ResultSet res = fetch.executeQuery();
|
||||
res.next();
|
||||
callback.accept(null, extractAuctionPlayer(res));
|
||||
AuctionPlayer insertedPlayer = extractAuctionPlayer(res);
|
||||
callback.accept(null, insertedPlayer);
|
||||
}
|
||||
} else {
|
||||
// UUID already exists, handle accordingly (e.g., log, notify)
|
||||
System.out.println("UUID already exists, skipping insertion.");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -31,6 +31,7 @@ import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.hooks.EconomyManager;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.flight.utils.Common;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -90,7 +90,7 @@ public final class DiscordMessageCreator {
|
||||
DiscordWebhook.EmbedObject embed = generateBaseEmbed();
|
||||
|
||||
embed.addField(Settings.DISCORD_MSG_FIELD_SELLER_NAME.getString(), Settings.DISCORD_MSG_FIELD_SELLER_VALUE.getString().replace("%seller%", this.listing.isServerItem() ? AuctionCreator.SERVER_LISTING_NAME : this.seller.getName()), Settings.DISCORD_MSG_FIELD_SELLER_INLINE.getBoolean());
|
||||
embed.addField(Settings.DISCORD_MSG_FIELD_ITEM_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_VALUE.getString().replace("%item_name%", "x" + this.listing.getItem().getAmount() + " " + ChatColor.stripColor(Settings.FORCE_MATERIAL_NAMES_FOR_DISCORD.getBoolean() ? ChatUtil.capitalize(this.listing.getItem().getType()) : ItemUtil.getItemName(this.listing.getItem()))), Settings.DISCORD_MSG_FIELD_SELLER_INLINE.getBoolean());
|
||||
embed.addField(Settings.DISCORD_MSG_FIELD_ITEM_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_VALUE.getString().replace("%item_name%", "x" + this.listing.getItem().getAmount() + " " + ChatColor.stripColor(Settings.FORCE_MATERIAL_NAMES_FOR_DISCORD.getBoolean() ? ChatUtil.capitalize(this.listing.getItem().getType()) : ItemUtil.getItemName(this.listing.getItem()))), Settings.DISCORD_MSG_FIELD_ITEM_INLINE.getBoolean());
|
||||
|
||||
switch (this.messageType) {
|
||||
case NEW_AUCTION_LISTING:
|
||||
|
Loading…
Reference in New Issue
Block a user