Skip to content

Commit

Permalink
修复市场bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Tining123 committed Jul 12, 2023
1 parent 2b69d1c commit 4d4a4e1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.Tining</groupId>
<artifactId>DemonMarket</artifactId>
<version>1.6.0</version>
<version>1.6.1</version>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,9 @@ public static void makeDecision(Player player, MarketItem marketItem, int slot,
if(player.getName().equals(marketItem.getOwnerName())){
totalPrice = 0;
}
// 检测余额
if (Vault.checkCurrency(player.getUniqueId()) < totalPrice) {

player.sendMessage(ChatColor.YELLOW + LangUtil.get("你没有足够的余额") + String.format("%.2f", totalPrice));
return;
}

// 扣费
Vault.subtractCurrency(player.getUniqueId(), marketItem.getPrice());
Vault.subtractCurrency(player.getUniqueId(), totalPrice);
// 发送物品
BukkitUtil.returnItem(player, marketItem.getItemStack().clone());
player.sendMessage(ChatColor.YELLOW + LangUtil.get("交易成功,花费:") + String.format("%.2f", totalPrice));
Expand Down
28 changes: 16 additions & 12 deletions src/main/java/com/tining/demonmarket/gui/MarketConfirmGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,31 +167,35 @@ public static void makeDecision(Player player, MarketItem marketItem, int slot,
}

// 扣费
Vault.subtractCurrency(player.getUniqueId(), marketItem.getPrice());
Vault.subtractCurrency(player.getUniqueId(), totalPrice);
// 给卖家转账
OfflinePlayer reciever = Bukkit.getOfflinePlayer(marketItem.getOwnerName());
double recieve = marketItem.getPrice();
double recieve = totalPrice;
double preTotalPrice = 0;
if(!ConfigReader.getDisableMarketDemonMarket()){
double totalValue = recieve;
int time = (int)(totalValue / ConfigReader.getPayUnit());
double res = totalValue % ConfigReader.getPayUnit();

double price = MarketEconomy.getSellingPrice(ConfigReader.getPayUnit(), time, Vault.checkCurrency(reciever.getUniqueId()));
totalPrice += price;
preTotalPrice += price;

price = MarketEconomy.getSellingPrice(res, 1, Vault.checkCurrency(reciever.getUniqueId()));
totalPrice += price;
preTotalPrice += price;

recieve = totalPrice;
recieve = preTotalPrice;
}
Vault.addVaultCurrency(reciever, recieve);
// 给收款人发消息
try{
Player onlineReceiver = Bukkit.getPlayer(marketItem.getOwnerName());
onlineReceiver.sendMessage(ChatColor.YELLOW +
String.format(LangUtil.get("物品%s出售成功,从%s收到%s"),
marketItem.getName(), player.getName(), MarketEconomy.formatMoney(recieve)));
}catch (Exception ignore){}
// 给收款人发消息,但是如果物归原主就不进行利益送达
if(!player.getName().equals(marketItem.getOwnerName())){
try{
Player onlineReceiver = Bukkit.getPlayer(marketItem.getOwnerName());
onlineReceiver.sendMessage(ChatColor.YELLOW +
String.format(LangUtil.get("物品%s出售成功,从%s收到%s"),
marketItem.getName(), player.getName(), MarketEconomy.formatMoney(recieve)));
}catch (Exception ignore){}
}




Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: DemonMarket
main: com.tining.demonmarket.Main
version: 1.6.0
version: 1.6.1
api-version: 1.13
# YAML 中的注释,一行有效
# 以上是插件基本信息,以下是命令注册
Expand Down

0 comments on commit 4d4a4e1

Please sign in to comment.