mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-22 05:25:11 +01:00
2.18.4 fixed stuff
This commit is contained in:
parent
d12b1ece28
commit
2623277ef4
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ca.tweetzy</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<version>2.18.3</version>
|
||||
<version>2.18.4</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -187,7 +187,6 @@ public class AuctionHouse extends TweetyPlugin {
|
||||
this.auctionItemManager.saveItems(Settings.DATABASE_USE.getBoolean(), false);
|
||||
this.transactionManager.saveTransactions(Settings.DATABASE_USE.getBoolean(), false);
|
||||
this.filterManager.saveFilterWhitelist(Settings.DATABASE_USE.getBoolean(), false);
|
||||
instance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,7 +23,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -47,7 +47,7 @@ public class CommandUpload extends AbstractCommand {
|
||||
AuctionHouse.getInstance().getData().save();
|
||||
|
||||
AuctionHouse.getInstance().getDataManager().saveItems(new ArrayList<>(AuctionHouse.getInstance().getAuctionItemManager().getAuctionItems().values()), true);
|
||||
AuctionHouse.getInstance().getDataManager().saveTransactions(AuctionHouse.getInstance().getTransactionManager().getTransactions(), true);
|
||||
AuctionHouse.getInstance().getDataManager().saveTransactions(new ArrayList<>(AuctionHouse.getInstance().getTransactionManager().getTransactions().values()), true);
|
||||
|
||||
AuctionHouse.getInstance().getLocale().newMessage(TextUtils.formatText("&aLoaded file items/transactions and saved them to the database.")).sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
|
@ -49,7 +49,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
statement.executeBatch();
|
||||
}));
|
||||
} else {
|
||||
this.sync(() -> this.databaseConnector.connect(connection -> {
|
||||
this.databaseConnector.connect(connection -> {
|
||||
String saveItems = "INSERT IGNORE INTO " + this.getTablePrefix() + "items SET data = ?";
|
||||
String truncate = "TRUNCATE TABLE " + this.getTablePrefix() + "items";
|
||||
connection.prepareStatement(truncate).executeUpdate();
|
||||
@ -63,11 +63,11 @@ public class DataManager extends DataManagerAbstract {
|
||||
}
|
||||
});
|
||||
statement.executeBatch();
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void saveFilterWhitelist(List<AuctionFilterItem> filterItems, boolean async){
|
||||
public void saveFilterWhitelist(List<AuctionFilterItem> filterItems, boolean async) {
|
||||
if (async) {
|
||||
this.async(() -> this.databaseConnector.connect(connection -> {
|
||||
String saveItems = "INSERT IGNORE INTO " + this.getTablePrefix() + "filter_whitelist SET data = ?";
|
||||
@ -88,7 +88,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
statement.executeBatch();
|
||||
}));
|
||||
} else {
|
||||
this.sync(() -> this.databaseConnector.connect(connection -> {
|
||||
this.databaseConnector.connect(connection -> {
|
||||
String saveItems = "INSERT IGNORE INTO " + this.getTablePrefix() + "filter_whitelist SET data = ?";
|
||||
String truncate = "TRUNCATE TABLE " + this.getTablePrefix() + "filter_whitelist";
|
||||
try (PreparedStatement statement = connection.prepareStatement(truncate)) {
|
||||
@ -105,7 +105,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
}
|
||||
});
|
||||
statement.executeBatch();
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
statement.executeBatch();
|
||||
}));
|
||||
} else {
|
||||
this.sync(() -> this.databaseConnector.connect(connection -> {
|
||||
this.databaseConnector.connect(connection -> {
|
||||
String saveItems = "INSERT IGNORE INTO " + this.getTablePrefix() + "transactions SET data = ?";
|
||||
String truncate = "TRUNCATE TABLE " + this.getTablePrefix() + "transactions";
|
||||
try (PreparedStatement statement = connection.prepareStatement(truncate)) {
|
||||
@ -147,7 +147,7 @@ public class DataManager extends DataManagerAbstract {
|
||||
}
|
||||
});
|
||||
statement.executeBatch();
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,8 +309,8 @@ public class GUIAuctionHouse extends Gui {
|
||||
drawFilterButton();
|
||||
|
||||
setButton(5, 6, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_TRANSACTIONS_LORE.getStringList(), new HashMap<String, Object>() {{
|
||||
put("%total_items_bought%", AuctionHouse.getInstance().getTransactionManager().getTransactions().stream().filter(transaction -> transaction.getBuyer().equals(auctionPlayer.getPlayer().getUniqueId())).count());
|
||||
put("%total_items_sold%", AuctionHouse.getInstance().getTransactionManager().getTransactions().stream().filter(transaction -> transaction.getSeller().equals(auctionPlayer.getPlayer().getUniqueId())).count());
|
||||
put("%total_items_bought%", AuctionHouse.getInstance().getTransactionManager().getTotalItemsBought(auctionPlayer.getPlayer().getUniqueId()));
|
||||
put("%total_items_sold%", AuctionHouse.getInstance().getTransactionManager().getTotalItemsSold(auctionPlayer.getPlayer().getUniqueId()));
|
||||
}}), e -> e.manager.showGUI(e.player, new GUITransactionList(this.auctionPlayer)));
|
||||
|
||||
setButton(5, 7, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_HOW_TO_SELL_LORE.getStringList(), null), null);
|
||||
|
@ -13,10 +13,7 @@ import ca.tweetzy.core.utils.TextUtils;
|
||||
import ca.tweetzy.core.utils.items.TItemBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -34,7 +31,7 @@ public class GUITransactionList extends Gui {
|
||||
|
||||
public GUITransactionList(AuctionPlayer auctionPlayer) {
|
||||
this.auctionPlayer = auctionPlayer;
|
||||
this.transactions = AuctionHouse.getInstance().getTransactionManager().getTransactions();
|
||||
this.transactions = new ArrayList<>(AuctionHouse.getInstance().getTransactionManager().getTransactions().values());
|
||||
this.showOwnOnly = true;
|
||||
setTitle(TextUtils.formatText(Settings.GUI_TRANSACTIONS_TITLE.getString()));
|
||||
setRows(6);
|
||||
|
@ -7,7 +7,10 @@ import ca.tweetzy.core.utils.TextUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -5,7 +5,8 @@ import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,11 @@ import ca.tweetzy.core.utils.TextUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -18,24 +22,32 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class TransactionManager {
|
||||
|
||||
private final ArrayList<Transaction> transactions = new ArrayList<>();
|
||||
private final ConcurrentHashMap<UUID, Transaction> transactions = new ConcurrentHashMap<>();
|
||||
private final HashMap<Player, UUID> prePurchaseHolding = new HashMap<>();
|
||||
|
||||
public void addTransaction(Transaction transaction) {
|
||||
if (transaction == null) return;
|
||||
this.transactions.add(transaction);
|
||||
this.transactions.put(transaction.getId(), transaction);
|
||||
}
|
||||
|
||||
public void removeTransaction(UUID uuid) {
|
||||
this.transactions.removeIf(item -> item.getId().equals(uuid));
|
||||
this.transactions.remove(uuid);
|
||||
}
|
||||
|
||||
public Transaction getTransaction(UUID uuid) {
|
||||
return this.transactions.stream().filter(item -> item.getId().equals(uuid)).findFirst().orElse(null);
|
||||
return this.transactions.getOrDefault(uuid, null);
|
||||
}
|
||||
|
||||
public List<Transaction> getTransactions() {
|
||||
return Collections.unmodifiableList(this.transactions);
|
||||
public ConcurrentHashMap<UUID, Transaction> getTransactions() {
|
||||
return this.transactions;
|
||||
}
|
||||
|
||||
public int getTotalItemsBought(UUID buyer) {
|
||||
return (int) this.transactions.entrySet().stream().filter(set -> set.getValue().getBuyer().equals(buyer)).count();
|
||||
}
|
||||
|
||||
public int getTotalItemsSold(UUID seller) {
|
||||
return (int) this.transactions.entrySet().stream().filter(set -> set.getValue().getSeller().equals(seller)).count();
|
||||
}
|
||||
|
||||
public void addPrePurchase(Player player, UUID uuid) {
|
||||
@ -69,9 +81,9 @@ public class TransactionManager {
|
||||
|
||||
public void saveTransactions(boolean useDatabase, boolean async) {
|
||||
if (useDatabase) {
|
||||
AuctionHouse.getInstance().getDataManager().saveTransactions(getTransactions(), async);
|
||||
AuctionHouse.getInstance().getDataManager().saveTransactions(new ArrayList<>(getTransactions().values()), async);
|
||||
} else {
|
||||
AuctionHouse.getInstance().getData().set("transactions", this.transactions.stream().map(AuctionAPI.getInstance()::convertToBase64).collect(Collectors.toList()));
|
||||
AuctionHouse.getInstance().getData().set("transactions", this.transactions.values().stream().map(AuctionAPI.getInstance()::convertToBase64).collect(Collectors.toList()));
|
||||
AuctionHouse.getInstance().getData().save();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ main: ca.tweetzy.auctionhouse.AuctionHouse
|
||||
description: Auction House is a premium auction solution for your server.
|
||||
website: https://tweetzy.ca/
|
||||
authors: [Kiran Hart]
|
||||
depend: [Vault]
|
||||
softdepend: [Vault, PlayerPoints]
|
||||
|
||||
commands:
|
||||
auctionhouse:
|
||||
|
Loading…
Reference in New Issue
Block a user