mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-02-08 18:02:10 +01:00
✈️ move mat categorizer and payment manager into model pkg
Took 22 seconds
This commit is contained in:
parent
47e3a8d966
commit
b3d305283b
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ca.tweetzy.auctionhouse.helpers;
|
package ca.tweetzy.auctionhouse.model;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory;
|
import ca.tweetzy.auctionhouse.auction.enums.AuctionItemCategory;
|
||||||
import ca.tweetzy.core.compatibility.XMaterial;
|
import ca.tweetzy.core.compatibility.XMaterial;
|
@ -16,9 +16,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package ca.tweetzy.auctionhouse.managers;
|
package ca.tweetzy.auctionhouse.model.manager;
|
||||||
|
|
||||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||||
|
import ca.tweetzy.auctionhouse.api.manager.KeyValueManager;
|
||||||
import ca.tweetzy.auctionhouse.auction.AuctionPayment;
|
import ca.tweetzy.auctionhouse.auction.AuctionPayment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -33,33 +34,26 @@ import java.util.stream.Collectors;
|
|||||||
* Time Created: 3:34 p.m.
|
* Time Created: 3:34 p.m.
|
||||||
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
|
||||||
*/
|
*/
|
||||||
public class PaymentsManager {
|
public class PaymentsManager extends KeyValueManager<UUID, AuctionPayment> {
|
||||||
|
|
||||||
private final ConcurrentHashMap<UUID, AuctionPayment> payments = new ConcurrentHashMap<>();
|
public PaymentsManager() {
|
||||||
|
super("Payments");
|
||||||
|
}
|
||||||
|
|
||||||
public void addPayment(AuctionPayment payment) {
|
public void add(AuctionPayment payment) {
|
||||||
if (payment == null) return;
|
if (payment == null) return;
|
||||||
this.payments.put(payment.getId(), payment);
|
add(payment.getId(), payment);
|
||||||
}
|
|
||||||
|
|
||||||
public void removePayment(UUID uuid) {
|
|
||||||
this.payments.remove(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConcurrentHashMap<UUID, AuctionPayment> getPayments() {
|
|
||||||
return this.payments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AuctionPayment> getPaymentsByPlayer(Player player) {
|
public List<AuctionPayment> 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) -> {
|
AuctionHouse.getInstance().getDataManager().getAuctionPayments((error, results) -> {
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
for (AuctionPayment payment : results) {
|
results.forEach(this::add);
|
||||||
addPayment(payment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user