From 5419f67694a7a0bd61d06cefa5763c84fa4693e0 Mon Sep 17 00:00:00 2001 From: svgaming234 <100072489+svgaming234@users.noreply.github.com> Date: Sun, 28 Jul 2024 22:48:44 +0200 Subject: [PATCH 1/2] fix readme.md typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e76be6..725f1a0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # JVillage -An alterative for Towny in Beta 1.7.3 +An alternative for Towny in Beta 1.7.3 From ee1fd5edd5f26cb865eb222bfdb2ef7bab1226aa Mon Sep 17 00:00:00 2001 From: SvGaming Date: Sun, 25 Aug 2024 21:41:02 +0200 Subject: [PATCH 2/2] add refund for village claim cost (with help of zavdav) --- .../beta/commands/village/JDeleteCommand.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/johnymuffin/jvillage/beta/commands/village/JDeleteCommand.java b/src/main/java/com/johnymuffin/jvillage/beta/commands/village/JDeleteCommand.java index b08adf3..b58c5d1 100644 --- a/src/main/java/com/johnymuffin/jvillage/beta/commands/village/JDeleteCommand.java +++ b/src/main/java/com/johnymuffin/jvillage/beta/commands/village/JDeleteCommand.java @@ -4,7 +4,10 @@ import com.johnymuffin.beta.fundamentals.api.FundamentalsAPI; import com.johnymuffin.jvillage.beta.JVillage; import com.johnymuffin.jvillage.beta.commands.JVBaseCommand; +import com.johnymuffin.jvillage.beta.models.VCords; import com.johnymuffin.jvillage.beta.models.Village; +import com.johnymuffin.jvillage.beta.models.chunk.ChunkClaimSettings; +import com.johnymuffin.jvillage.beta.models.chunk.VClaim; import com.johnymuffin.jvillage.beta.player.VPlayer; import org.bukkit.Bukkit; import org.bukkit.command.Command; @@ -14,6 +17,8 @@ import java.util.logging.Level; +import static com.johnymuffin.jvillage.beta.JVUtility.cordsInChunk; + public class JDeleteCommand extends JVBaseCommand implements CommandExecutor { public JDeleteCommand(JVillage plugin) { @@ -58,17 +63,28 @@ public boolean onCommand(CommandSender commandSender, Command command, String s, } // Refund the player the balance - double townBalance = village.getBalance(); + double refundAmount = village.getBalance(); + + // Refund the player the cost of the claims + VCords spawnCords = village.getTownSpawn(); + + for (VClaim vClaim : plugin.getVillageClaimsArray(village)) { + ChunkClaimSettings chunkClaimSettings = village.getChunkClaimSettings(vClaim); + + if (!cordsInChunk(spawnCords, vClaim)) { + refundAmount += chunkClaimSettings.getPrice(); + } + } - if (townBalance > 0 && plugin.isFundamentalsEnabled()) { - EconomyAPI.EconomyResult result = FundamentalsAPI.getEconomy().additionBalance(player.getUniqueId(), townBalance); + if (refundAmount > 0 && plugin.isFundamentalsEnabled()) { + EconomyAPI.EconomyResult result = FundamentalsAPI.getEconomy().additionBalance(player.getUniqueId(), refundAmount); String message; switch (result) { case successful: - this.plugin.logger(Level.INFO, "Successfully refunded $" + townBalance + " to " + player.getName() + " for deleting village " + village.getTownName()); + this.plugin.logger(Level.INFO, "Successfully refunded $" + refundAmount + " to " + player.getName() + " for deleting village " + village.getTownName()); break; default: - this.plugin.logger(Level.WARNING, "Failed to refund $" + townBalance + " to " + player.getName() + " for deleting village " + village.getTownName()); + this.plugin.logger(Level.WARNING, "Failed to refund $" + refundAmount + " to " + player.getName() + " for deleting village " + village.getTownName()); message = language.getMessage("generic_error"); commandSender.sendMessage(message); return true;