9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-27 19:09:18 +00:00

new placeholder {sold-item-amount}

This commit is contained in:
XiaoMoMi
2023-12-13 21:58:57 +08:00
parent 9f5c74cfef
commit 08bb99ec68
3 changed files with 18 additions and 1 deletions

View File

@@ -55,7 +55,6 @@ import net.momirealms.customfishing.version.VersionManagerImpl;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

View File

@@ -268,4 +268,20 @@ public class MarketGUI {
public EarningData getEarningData() {
return earningData;
}
public int getSoldAmount() {
int amount = 0;
MarketGUIElement itemElement = getElement(manager.getItemSlot());
if (itemElement == null) {
return amount;
}
for (int slot : itemElement.getSlots()) {
ItemStack itemStack = inventory.getItem(slot);
double money = manager.getItemPrice(itemStack);
if (money > 0 && itemStack != null) {
amount += itemStack.getAmount();
}
}
return amount;
}
}

View File

@@ -291,10 +291,12 @@ public class MarketManagerImpl implements MarketManager, Listener {
if (element.getSymbol() == functionSlot) {
double worth = gui.getTotalWorth();
int amount = gui.getSoldAmount();
double earningLimit = getEarningLimit(player);
Condition condition = new Condition(player, new HashMap<>(Map.of(
"{money}", String.format("%.2f", worth)
,"{rest}", String.format("%.2f", (earningLimit - data.earnings))
,"{sold-item-amount}", String.valueOf(amount)
)));
if (worth > 0) {
if (earningLimit != -1 && (earningLimit - data.earnings) < worth) {