From ef8b0797d798d3508a91e296b182de366efc449f Mon Sep 17 00:00:00 2001 From: Etienne Dx Date: Fri, 4 Mar 2022 22:18:34 +0100 Subject: [PATCH] fix: fixed #35 and /re list command, bumped version to 1.4.0-pre2 --- CHANGELOG.md | 4 +++- pom.xml | 2 +- src/me/EtienneDx/RealEstate/Messages.java | 10 ++++------ .../EtienneDx/RealEstate/Transactions/ClaimLease.java | 2 +- .../EtienneDx/RealEstate/Transactions/ClaimRent.java | 5 +++-- .../EtienneDx/RealEstate/Transactions/ClaimSell.java | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c24f545..2968883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,4 +17,6 @@ ### Fixed * Sign header color formatting being lost on server restart -* Fixed issue preventing to buy claims due to currencies using $ character \ No newline at end of file +* Fixed issue preventing to buy claims due to currencies using $ character +* Fixed error with `/re list` +* Fixed error regarding renewrent \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4ced1b0..21b839d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 Me.EtienneDx real-estate - 1.4.0-pre1 + 1.4.0-pre2 RealEstate A spigot plugin for selling, renting and leasing GriefPrevention claims diff --git a/src/me/EtienneDx/RealEstate/Messages.java b/src/me/EtienneDx/RealEstate/Messages.java index bc78635..d75dcc9 100644 --- a/src/me/EtienneDx/RealEstate/Messages.java +++ b/src/me/EtienneDx/RealEstate/Messages.java @@ -1,7 +1,6 @@ package me.EtienneDx.RealEstate; import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.bukkit.command.CommandSender; import org.bukkit.plugin.PluginDescriptionFile; @@ -353,10 +352,10 @@ public class Messages extends AnnotationConfig public String msgInfoClaimInfoRentHeader = "$9-----= $f[$6RealEstate Rent Info$f]$9 =-----"; @ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralNoBuyer", comment = "0: claim type, 1: formatted price, 2: duration") - public String msgInfoClaimInfoGeneralRentNoBuyer = "$bThis {0} is for rent for $a{1}$b per $a{2}."; + public String msgInfoClaimInfoGeneralRentNoBuyer = "$bThis {0} is for rent for $a{1}$b per $a{2}$b."; @ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralBuyer", comment = "0: claim type, 1: buyer name, 2: formatted price, 3: time left in current period, 4: duration of a period") - public String msgInfoClaimInfoGeneralRentBuyer = "$bThis {0} is currently rented by $a{1}$b for $a{2}$b. The {0} is rented until $a{3}$b. The rent period is $a{4}"; + public String msgInfoClaimInfoGeneralRentBuyer = "$bThis {0} is currently rented by $a{1}$b for $a{2}$b. The {0} is rented for another $a{3}$b. The rent period is $a{4}"; @ConfigField(name="RealEstate.Info.Claim.Info.Rent.MaxPeriod", comment = "0: max periods") public String msgInfoClaimInfoRentMaxPeriod = "$bIt can be rented for a maximum of $a{0}$b periods."; @@ -449,11 +448,10 @@ public static String getMessage(String msgTemplate, boolean withPrefix, String.. } msgTemplate = msgTemplate.replace('$', ChatColor.COLOR_CHAR); - + for (int i = 0; i < args.length; i++) { String param = args[i]; - Matcher matcher = Pattern.compile("\\{" + i + "\\}").matcher(msgTemplate); - msgTemplate = matcher.replaceAll(Matcher.quoteReplacement(param)); + msgTemplate = msgTemplate.replaceAll("\\{" + i + "\\}", Matcher.quoteReplacement(param)); } return msgTemplate; diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java index fe60218..ea98af4 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java @@ -479,7 +479,7 @@ public void preview(Player player) @Override public void msgInfo(CommandSender cs) { - Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId); + Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); String location = "[" + claim.getLesserBoundaryCorner().getWorld().getName() + ", " + "X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " + "Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " + diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java index 91a2bf1..1627bda 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java @@ -192,7 +192,7 @@ private void payRent() String location = "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]"; - if((autoRenew || periodCount < maxPeriod) && Utils.makePayment(owner, this.buyer, price, false, false)) + if((autoRenew || periodCount + 1 < maxPeriod) && Utils.makePayment(owner, this.buyer, price, false, false)) { periodCount = (periodCount + 1) % maxPeriod; startDate = LocalDateTime.now(); @@ -335,6 +335,7 @@ public void interact(Player player) buyer = player.getUniqueId(); startDate = LocalDateTime.now(); autoRenew = false; + periodCount = 0; claim.setPermission(buyer.toString(), buildTrust ? ClaimPermission.Build : ClaimPermission.Inventory); claim.setPermission(player.getUniqueId().toString(), ClaimPermission.Manage); claim.managers.add(player.getUniqueId().toString()); @@ -477,7 +478,7 @@ public void preview(Player player) @Override public void msgInfo(CommandSender cs) { - Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId); + Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); String location = "[" + claim.getLesserBoundaryCorner().getWorld().getName() + ", " + "X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " + "Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " + diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java index c948d25..72d21a8 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java @@ -223,7 +223,7 @@ public void setOwner(UUID newOwner) @Override public void msgInfo(CommandSender cs) { - Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId); + Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null); if(claim == null) { tryCancelTransaction(null, true); return;