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:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user