fix: fixed #42 and removeed a duplicated message
This commit is contained in:
parent
757de574be
commit
2e92305aec
@ -16,4 +16,5 @@
|
||||
* Removed requirement for custom GP jar file
|
||||
|
||||
### Fixed
|
||||
* Sign header color formatting being lost on server restart
|
||||
* Sign header color formatting being lost on server restart
|
||||
* Fixed issue preventing to buy claims due to currencies using $ character
|
||||
@ -1,5 +1,8 @@
|
||||
package me.EtienneDx.RealEstate;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
@ -122,7 +125,7 @@ public class Messages extends AnnotationConfig
|
||||
public String msgErrorNonIntegerPrice = "$cThe price must be an integer!";
|
||||
|
||||
@ConfigField(name="RealEstate.Errors.InvalidDuration", comment = "0: duration, 1: example of duration format, 2: example, 3: example")
|
||||
public String msgErrorInvalidDuration = "$c{0} is not a valid duration! Durations must be in the format {1} or {2} or {3}!";
|
||||
public String msgErrorInvalidDuration = "$c{0} is not a valid duration! Durations must be in the format $a{1}$c or $a{2}$c or $a{3}$c!";
|
||||
|
||||
@ConfigField(name="RealEstate.Errors.NoMoneySelf")
|
||||
public String msgErrorNoMoneySelf = "$cYou don't have enough money to make this transaction!";
|
||||
@ -444,12 +447,16 @@ public class Messages extends AnnotationConfig
|
||||
if (withPrefix) {
|
||||
msgTemplate = RealEstate.instance.config.chatPrefix + msgTemplate;
|
||||
}
|
||||
|
||||
msgTemplate = msgTemplate.replace('$', ChatColor.COLOR_CHAR);
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String param = args[i];
|
||||
msgTemplate = msgTemplate.replaceAll("\\{" + i + "\\}", param);
|
||||
Matcher matcher = Pattern.compile("\\{" + i + "\\}").matcher(msgTemplate);
|
||||
msgTemplate = matcher.replaceAll(Matcher.quoteReplacement(param));
|
||||
}
|
||||
|
||||
return msgTemplate.replace('$', ChatColor.COLOR_CHAR);
|
||||
return msgTemplate;
|
||||
}
|
||||
//sends a color-coded message to a player
|
||||
public static void sendMessage(CommandSender player, String msgTemplate, String... args) {
|
||||
|
||||
@ -203,9 +203,9 @@ public class REListener implements Listener
|
||||
if(duration == 0)
|
||||
{
|
||||
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidDuration, event.getLine(2),
|
||||
ChatColor.GREEN + "10 weeks",
|
||||
ChatColor.GREEN + "3 days",
|
||||
ChatColor.GREEN + "1 week 3 days");
|
||||
"10 weeks",
|
||||
"3 days",
|
||||
"1 week 3 days");
|
||||
event.setCancelled(true);
|
||||
event.getBlock().breakNaturally();
|
||||
return;
|
||||
@ -334,9 +334,9 @@ public class REListener implements Listener
|
||||
if(frequency == 0)
|
||||
{
|
||||
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidDuration, event.getLine(3),
|
||||
ChatColor.GREEN + "10 weeks",
|
||||
ChatColor.GREEN + "3 days",
|
||||
ChatColor.GREEN + "1 week 3 days");
|
||||
"10 weeks",
|
||||
"3 days",
|
||||
"1 week 3 days");
|
||||
event.setCancelled(true);
|
||||
event.getBlock().breakNaturally();
|
||||
return;
|
||||
|
||||
@ -441,12 +441,6 @@ public class ClaimRent extends BoughtTransaction
|
||||
RealEstate.econ.format(price),
|
||||
Utils.getTime(daysLeft, timeRemaining, true),
|
||||
Utils.getTime(duration, null, true)) + "\n";
|
||||
msg += ChatColor.AQUA + "This " + claimType + " is currently rented by " +
|
||||
ChatColor.GREEN + Bukkit.getOfflinePlayer(buyer).getName() + ChatColor.AQUA + " for " +
|
||||
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + " for " +
|
||||
(maxPeriod - periodCount > 1 ? "" + ChatColor.GREEN + (maxPeriod - periodCount) + ChatColor.AQUA + " periods of " +
|
||||
ChatColor.GREEN + Utils.getTime(duration, null, false) + ChatColor.AQUA + ". The current period will end in " : "another ") +
|
||||
ChatColor.GREEN + Utils.getTime(daysLeft, timeRemaining, true) + "\n";
|
||||
|
||||
if(maxPeriod > 1 && maxPeriod - periodCount > 0)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user