修复了在购买不限量称号时可能产生-2的bug
All checks were successful
Java CI-CD with Maven / build (push) Successful in 8m36s

This commit is contained in:
zhangyuheng 2024-06-27 16:13:02 +08:00
parent c4d25b79cf
commit 706ea9a5a5
2 changed files with 7 additions and 3 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>MiniPlayerTitle</artifactId>
<version>4.2.1</version>
<version>4.2.2</version>
<packaging>jar</packaging>
<name>MiniPlayerTitle</name>

View File

@ -178,14 +178,18 @@ public class TitleShopSale {
Notification.error(player, "购买称号时出现错误,详情请查看控制台日志");
return;
}
titleShop.setAmount(titleShop.getAmount() - 1);
if (titleShop.getAmount() >= 1) {
titleShop.setAmount(titleShop.getAmount() - 1);
}
playerInfo.setCoin(playerInfo.getCoin() - titleShop.getPrice());
Notification.info(player, Component.text("成功购买称号: ").append(had.getTitle().getTitleColored()));
} else if (!had.isExpired()) {
Notification.warn(player, "你已拥有此称号,在过期前无法再次购买");
} else {
had.setExpireAt(titleShop.getDays() == -1 ? null : LocalDateTime.now().plusDays(titleShop.getDays()));
titleShop.setAmount(titleShop.getAmount() - 1);
if (titleShop.getAmount() >= 1) {
titleShop.setAmount(titleShop.getAmount() - 1);
}
playerInfo.setCoin(playerInfo.getCoin() - titleShop.getPrice());
Notification.info(player, Component.text("成功续续期称号: ").append(had.getTitle().getTitleColored()));
}