Skip to content

Commit

Permalink
Merge pull request #10 from abb3v/hp-withdraw-fix
Browse files Browse the repository at this point in the history
[Bug Fix] Remove Hardcoded Withdraw Value
  • Loading branch information
KartoffelChipss authored Jun 14, 2024
2 parents 2410258 + 71426b8 commit 1802231
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return false;
}

if (playerdata.getMaxhp() - ((double) withdrawHearts * 2) <= 0.0) {
double resultingHealth = playerdata.getMaxhp() - ((double) withdrawHearts * 2);
double minHealth = LifeStealZ.getInstance().getConfig().getDouble("minHearts", 2.0) * 2; // Default to 2.0 if not set

if (resultingHealth < minHealth) {
if (confirmOption == null || !confirmOption.equals("confirm")) {
sender.sendMessage(MessageUtils.getAndFormatMsg(false, "messages.noWithdraw", "&cYou would be eliminated if you withdraw a heart!"));
if (withdrawtoDeath) sender.sendMessage(MessageUtils.getAndFormatMsg(false, "messages.withdrawConfirmmsg", "&8&oUse <underlined><click:SUGGEST_COMMAND:/withdrawheart %amount% confirm>/withdrawheart %amount% confirm</click></underlined> if you really want to withdraw a heart", new Replaceable("%amount%", withdrawHearts + "")));
Expand Down Expand Up @@ -101,6 +104,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return false;
}


playerdata.setMaxhp(playerdata.getMaxhp() - (double) withdrawHearts * 2);
LifeStealZ.getInstance().getPlayerDataStorage().save(playerdata);
LifeStealZ.setMaxHealth(player, playerdata.getMaxhp());
Expand Down

0 comments on commit 1802231

Please sign in to comment.