Skip to content

Commit

Permalink
fix: fixed EtienneDx#35 and /re list command, bumped version to 1.4.0…
Browse files Browse the repository at this point in the history
…-pre2
  • Loading branch information
EtienneDx committed Mar 4, 2022
1 parent 2e92305 commit ef8b079
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* Fixed issue preventing to buy claims due to currencies using $ character
* Fixed error with `/re list`
* Fixed error regarding renewrent
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>Me.EtienneDx</groupId>
<artifactId>real-estate</artifactId>
<version>1.4.0-pre1</version>
<version>1.4.0-pre2</version>
<name>RealEstate</name>
<description>A spigot plugin for selling, renting and leasing GriefPrevention claims</description>
<build>
Expand Down
10 changes: 4 additions & 6 deletions src/me/EtienneDx/RealEstate/Messages.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.";
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/me/EtienneDx/RealEstate/Transactions/ClaimLease.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() + ", " +
Expand Down
5 changes: 3 additions & 2 deletions src/me/EtienneDx/RealEstate/Transactions/ClaimRent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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() + ", " +
Expand Down
2 changes: 1 addition & 1 deletion src/me/EtienneDx/RealEstate/Transactions/ClaimSell.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ef8b079

Please sign in to comment.