Skip to content

Commit

Permalink
修复物品购买bug
Browse files Browse the repository at this point in the history
Tining123 committed Jun 24, 2023
1 parent 8268dfd commit b4ee153
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -255,7 +255,7 @@ public static String getHelp() {
LangUtil.get("/mt pay [玩家] [金额]") + "\n" +
LangUtil.get("/mt sell 出售手里的物品\n") +
LangUtil.get("/mt sell all 出售背包里当前所有与手中相同的物品\n") +
LangUtil.get("/mt price 查询物品当前价格") +
LangUtil.get("/mt price 查询物品当前价格\n") +
LangUtil.get("/mt shop 打开物品商店");
return help;
}
Original file line number Diff line number Diff line change
@@ -300,7 +300,7 @@ public static void reloadShop() {
PRICE_TABLE.put(shopItem.getName(),shopItem.getInfo(), shopItem);
}
}
log.info("【DemonMarket】Shop price list loaded");
// log.info("【DemonMarket】Shop price list loaded");
}

/**
18 changes: 13 additions & 5 deletions src/main/java/com/tining/demonmarket/gui/ShopConfirmGui.java
Original file line number Diff line number Diff line change
@@ -193,13 +193,21 @@ public static void makeDecesion(Player player, ShopItem shopItem, int amount, in
double totalPrice = amount * shopItem.getPrice();
// 检测余额
if (Vault.checkCurrency(player.getUniqueId()) < totalPrice) {
player.sendMessage(ChatColor.YELLOW + LangUtil.get("你没有足够的余额") + totalPrice);

player.sendMessage(ChatColor.YELLOW + LangUtil.get("你没有足够的余额") + String.format("%.2f", totalPrice));
return;
}
// 扣费
Vault.subtractCurrency(player.getUniqueId(), totalPrice);
// 发送物品
BukkitUtil.returnItem(player, shopItem.getItemStack().clone());
// 发货
for(int i = 0 ; i < amount;i++){
if (Vault.checkCurrency(player.getUniqueId()) < shopItem.getPrice()) {
player.sendMessage(ChatColor.YELLOW + LangUtil.get("你没有足够的余额") + String.format("%.2f", shopItem.getPrice()));
return;
}
// 扣费
Vault.subtractCurrency(player.getUniqueId(), shopItem.getPrice());
// 发送物品
BukkitUtil.returnItem(player, shopItem.getItemStack().clone());
}
player.sendMessage(ChatColor.YELLOW + LangUtil.get("交易成功,花费:") + totalPrice);
}
return;

0 comments on commit b4ee153

Please sign in to comment.