mirror of
https://github.com/Flowsqy/ShopChest.git
synced 2024-11-14 23:15:10 +01:00
update shop value
This commit is contained in:
parent
1e0c4cdbb9
commit
582389672e
@ -2,7 +2,10 @@ package de.epiceric.shopchest.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@ -537,6 +540,7 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
AtomicReference<Double> buyPrice = new AtomicReference<>(0d);
|
||||
AtomicReference<Double> sellPrice = new AtomicReference<>(0d);
|
||||
Set<UUID> sellers = new HashSet<>();
|
||||
|
||||
plugin.getShopUtils().getShops().forEach(shop -> {
|
||||
if (!shop.hasItem()) {
|
||||
@ -545,13 +549,22 @@ class ShopCommandExecutor implements CommandExecutor {
|
||||
if (!Utils.isItemSimilar(shop.getProduct().getItemStack(), item)) {
|
||||
return;
|
||||
}
|
||||
if (shop.getShopType().equals(ShopType.ADMIN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sellers.add(shop.getVendor().getUniqueId());
|
||||
count.getAndIncrement();
|
||||
buyPrice.updateAndGet(v -> v + shop.getBuyPrice());
|
||||
sellPrice.updateAndGet(v -> v + shop.getSellPrice());
|
||||
});
|
||||
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.VALUE_OF_ITEM, new Replacement(Placeholder.AMOUNT, count.get()), new Replacement(Placeholder.BUY_PRICE, buyPrice.get()), new Replacement(Placeholder.SELL_PRICE, sellPrice.get())));
|
||||
if (count.get() == 0) {
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.VALUE_NO_SHOPS));
|
||||
return;
|
||||
}
|
||||
|
||||
p.sendMessage(LanguageUtils.getMessage(Message.VALUE_OF_ITEM, new Replacement(Placeholder.AMOUNT, sellers.size()), new Replacement(Placeholder.BUY_PRICE, buyPrice.get() / (double)count.get()), new Replacement(Placeholder.SELL_PRICE, sellPrice.get() / (double)count.get())));
|
||||
}
|
||||
|
||||
private boolean changeConfig(CommandSender sender, String[] args) {
|
||||
|
@ -2592,7 +2592,8 @@ public class LanguageUtils {
|
||||
messages.add(new LocalizedMessage(Message.CHANGED_CONFIG_SET, langConfig.getString("message.config.set", "&6Changed &a%PROPERTY% &6to &a%VALUE%&6.")));
|
||||
messages.add(new LocalizedMessage(Message.CHANGED_CONFIG_REMOVED, langConfig.getString("message.config.removed", "&6Removed &a%VALUE% &6from &a%PROPERTY%&6.")));
|
||||
messages.add(new LocalizedMessage(Message.CHANGED_CONFIG_ADDED, langConfig.getString("message.config.added", "&6Added &a%VALUE% &6to &a%PROPERTY%&6.")));
|
||||
messages.add(new LocalizedMessage(Message.VALUE_OF_ITEM, langConfig.getString("message.valueOfItem", "&6This item is sold in &a%COUNT% &6shops for an average price of &a%SELL-PRICE%&6, and bought for &a%BUY-PRICE%.")));
|
||||
messages.add(new LocalizedMessage(Message.VALUE_OF_ITEM, langConfig.getString("message.valueOfItem", "&6This item is sold by &a%COUNT% &6players for an average price of &a%SELL-PRICE%&6, and bought for &a%BUY-PRICE%.")));
|
||||
messages.add(new LocalizedMessage(Message.VALUE_NO_SHOPS, langConfig.getString("message.valueNoShops", "&cNo shops are currently selling this item.")));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,5 +97,6 @@ public enum Message {
|
||||
CHANGED_CONFIG_SET,
|
||||
CHANGED_CONFIG_REMOVED,
|
||||
CHANGED_CONFIG_ADDED,
|
||||
VALUE_OF_ITEM
|
||||
VALUE_OF_ITEM,
|
||||
VALUE_NO_SHOPS
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user