From b3d305283be6c13e880a57bef35c1f75588e98e6 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Sun, 2 Jun 2024 14:57:42 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=88=EF=B8=8F=20move=20mat=20categorizer?= =?UTF-8?q?=20and=20payment=20manager=20into=20model=20pkg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 22 seconds --- .../MaterialCategorizer.java | 2 +- .../manager}/PaymentsManager.java | 30 ++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) rename src/main/java/ca/tweetzy/auctionhouse/{helpers => model}/MaterialCategorizer.java (98%) rename src/main/java/ca/tweetzy/auctionhouse/{managers => model/manager}/PaymentsManager.java (68%) diff --git a/src/main/java/ca/tweetzy/auctionhouse/helpers/MaterialCategorizer.java b/src/main/java/ca/tweetzy/auctionhouse/model/MaterialCategorizer.java similarity index 98% rename from src/main/java/ca/tweetzy/auctionhouse/helpers/MaterialCategorizer.java rename to src/main/java/ca/tweetzy/auctionhouse/model/MaterialCategorizer.java index 045b508..5c0335c 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/helpers/MaterialCategorizer.java +++ b/src/main/java/ca/tweetzy/auctionhouse/model/MaterialCategorizer.java @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package ca.tweetzy.auctionhouse.helpers; +package ca.tweetzy.auctionhouse.model; import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory; import ca.tweetzy.core.compatibility.XMaterial; diff --git a/src/main/java/ca/tweetzy/auctionhouse/managers/PaymentsManager.java b/src/main/java/ca/tweetzy/auctionhouse/model/manager/PaymentsManager.java similarity index 68% rename from src/main/java/ca/tweetzy/auctionhouse/managers/PaymentsManager.java rename to src/main/java/ca/tweetzy/auctionhouse/model/manager/PaymentsManager.java index 313ac78..a8c8e1e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/managers/PaymentsManager.java +++ b/src/main/java/ca/tweetzy/auctionhouse/model/manager/PaymentsManager.java @@ -16,9 +16,10 @@ * along with this program. If not, see . */ -package ca.tweetzy.auctionhouse.managers; +package ca.tweetzy.auctionhouse.model.manager; import ca.tweetzy.auctionhouse.AuctionHouse; +import ca.tweetzy.auctionhouse.api.manager.KeyValueManager; import ca.tweetzy.auctionhouse.auction.AuctionPayment; import org.bukkit.entity.Player; @@ -33,33 +34,26 @@ import java.util.stream.Collectors; * Time Created: 3:34 p.m. * Usage of any code found within this class is prohibited unless given explicit permission otherwise */ -public class PaymentsManager { +public class PaymentsManager extends KeyValueManager { - private final ConcurrentHashMap payments = new ConcurrentHashMap<>(); + public PaymentsManager() { + super("Payments"); + } - public void addPayment(AuctionPayment payment) { + public void add(AuctionPayment payment) { if (payment == null) return; - this.payments.put(payment.getId(), payment); - } - - public void removePayment(UUID uuid) { - this.payments.remove(uuid); - } - - public ConcurrentHashMap getPayments() { - return this.payments; + add(payment.getId(), payment); } public List getPaymentsByPlayer(Player player) { - return this.payments.values().stream().filter(payment -> payment.getTo().equals(player.getUniqueId())).collect(Collectors.toList()); + return this.managerContent.values().stream().filter(payment -> payment.getTo().equals(player.getUniqueId())).collect(Collectors.toList()); } - public void loadPayments() { + @Override + public void load() { AuctionHouse.getInstance().getDataManager().getAuctionPayments((error, results) -> { if (error == null) { - for (AuctionPayment payment : results) { - addPayment(payment); - } + results.forEach(this::add); } }); }