feat: Moved most messages to Messages.java config file

This commit is contained in:
Etienne Dx 2022-01-14 18:38:17 +01:00
parent df6b5bede0
commit 7e7ca3b398
6 changed files with 430 additions and 198 deletions

View File

@ -6,6 +6,7 @@
* Readme and changelog files
* Error messages to *messages.yml*
* List messages to *messages.yml*
* Info messages to *messages.yml*
* Support of [GriefPrevention v16.18-RC1](https://github.com/TechFortress/GriefPrevention/releases/tag/16.18-RC1)
### Modified

View File

@ -12,6 +12,18 @@ public class Messages extends AnnotationConfig
{
public PluginDescriptionFile pdf;
@ConfigField(name="RealEstate.Keywords.Enabled", comment = "Keywords used within other messages")
public String keywordEnabled = "enabled";
@ConfigField(name="RealEstate.Keywords.Disabled")
public String keywordDisabled = "disabled";
@ConfigField(name="RealEstate.Keywords.Claim")
public String keywordClaim = "claim";
@ConfigField(name="RealEstate.Keywords.Subclaim")
public String keywordSubclaim = "subclaim";
@ConfigField(name="RealEstate.NoTransactionFound")
public String msgNoTransactionFound = "$cNo transaction found at your location!";
@ -53,12 +65,6 @@ public class Messages extends AnnotationConfig
@ConfigField(name="RealEstate.Errors.InvalidOption")
public String msgErrorInvalidOption = "$cInvalid option provided!";
@ConfigField(name="RealEstate.List.Header", comment = "0: RE Offers|Sell Offers|Rent Offers|Lease Offers; 1: Page number; 2: Page count")
public String msgListTransactionsHeader = "$1----= $f[ $6{0} page $2 {1} $6/ $2{2} $f] $1=----";
@ConfigField(name="RealEstate.List.NextPage", comment="0: all|sell|rent|lease; 1: next page number")
public String msgListNextPage = "$6To see the next page, type $a/re list {0} {1}";
@ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantEdit")
public String msgErrorClaimInTransactionCantEdit = "$cThis claim is currently involved in a transaction, you can't edit it!";
@ -74,6 +80,220 @@ public class Messages extends AnnotationConfig
@ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantManage")
public String msgErrorClaimInTransactionCantManage = "$cThis claim is currently involved in a transaction, you can't manage it!";
@ConfigField(name="RealEstate.Errors.Command.Usage", comment = "0: command usage")
public String msgErrorCommandUsage = "$cUsage: {0}";
@ConfigField(name="RealEstate.Errors.BuyerOnly")
public String msgErrorBuyerOnly = "$cOnly the buyer can perform this command!";
@ConfigField(name="RealEstate.Errors.InvalidNumber", comment = "0: number")
public String msgErrorInvalidNumber = "$c{0} is not a valid number!";
@ConfigField(name="RealEstate.Errors.NegativeNumber", comment = "0: number")
public String msgErrorNegativeNumber = "$c{0} is a negative number!";
@ConfigField(name="RealEstate.Errors.NegativePrice", comment = "0: price")
public String msgErrorNegativePrice = "$cThe price must be greater than zero!";
@ConfigField(name="RealEstate.Errors.NonIntegerPrice", comment = "0: price")
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}!";
@ConfigField(name="RealEstate.Errors.AutoRenew.Disabled")
public String msgErrorAutoRenewDisabled = "$cAutomatic renew is disabled!";
@ConfigField(name="RealEstate.Errors.ExitOffer.AlreadyExists")
public String msgErrorExitOfferAlreadyExists = "$cThere is already an exit proposition for this transaction!";
@ConfigField(name="RealEstate.Errors.ExitOffer.NoBuyer")
public String msgErrorExitOfferNoBuyer = "$cNo one is engaged by this transaction yet!";
@ConfigField(name="RealEstate.Errors.ExitOffer.None")
public String msgErrorExitOfferNone = "$cThere is currently no exit offer for this claim!";
@ConfigField(name="RealEstate.Errors.ExitOffer.CantAcceptSelf")
public String msgErrorExitOfferCantAcceptSelf = "$cYou can't accept your own exit offer!";
@ConfigField(name="RealEstate.Errors.ExitOffer.CantRefuseSelf")
public String msgErrorExitOfferCantRefuseSelf = "$cYou can't refuse your own exit offer!";
@ConfigField(name="RealEstate.Errors.ExitOffer.CantCancelOther")
public String msgErrorExitOfferCantCancelOther = "$cOnly the player who created this exit proposition may cancel it!";
@ConfigField(name="RealEstate.Errors.Sign.NotInClaim")
public String msgErrorSignNotInClaim = "$cThe sign you placed is not inside a claim!";
@ConfigField(name="RealEstate.Errors.Sign.OngoingTransaction")
public String msgErrorSignOngoingTransaction = "$cThis claim already has an ongoing transaction!";
@ConfigField(name="RealEstate.Errors.Sign.ParentOngoingTransaction")
public String msgErrorSignParentOngoingTransaction = "$cThis claim's parent already has an ongoing transaction!";
@ConfigField(name="RealEstate.Errors.Sign.SubclaimOngoingTransaction")
public String msgErrorSignSubclaimOngoingTransaction = "$cThis claim has subclaims with ongoing transactions!";
@ConfigField(name="RealEstate.Errors.Sign.SellingDisabled")
public String msgErrorSignSellingDisabled = "$cSelling is disabled!";
@ConfigField(name="RealEstate.Errors.Sign.LeasingDisabled")
public String msgErrorSignLeasingDisabled = "$cLeasing is disabled!";
@ConfigField(name="RealEstate.Errors.Sign.RentingDisabled")
public String msgErrorSignRentingDisabled = "$cRenting is disabled!";
@ConfigField(name="RealEstate.Errors.Sign.NoSellPermission", comment = "0: claim type")
public String msgErrorSignNoSellPermission = "$cYou don't have permission to sell this {0}!";
@ConfigField(name="RealEstate.Errors.Sign.NoLeasePermission", comment = "0: claim type")
public String msgErrorSignNoLeasePermission = "$cYou don't have permission to lease this {0}!";
@ConfigField(name="RealEstate.Errors.Sign.NoRentPermission", comment = "0: claim type")
public String msgErrorSignNoRentPermission = "$cYou don't have permission to rent this {0}!";
@ConfigField(name="RealEstate.Errors.Sign.NoAdminSellPermission", comment = "0: claim type")
public String msgErrorSignNoAdminSellPermission = "$cYou don't have permission to sell this admin {0}!";
@ConfigField(name="RealEstate.Errors.Sign.NoAdminLeasePermission", comment = "0: claim type")
public String msgErrorSignNoAdminLeasePermission = "$cYou don't have permission to lease this admin {0}!";
@ConfigField(name="RealEstate.Errors.Sign.NoAdminRentPermission", comment = "0: claim type")
public String msgErrorSignNoAdminRentPermission = "$cYou don't have permission to rent this admin {0}!";
@ConfigField(name="RealEstate.Errors.Sign.NotOwner", comment = "0: claim type")
public String msgErrorSignNotOwner = "$cYou can only sell/rent/lease {0} you own!";
@ConfigField(name="RealEstate.Errors.Sign.NotAuthor")
public String msgErrorSignNotAuthor = "$cOnly the author of the sell/rent/lease sign is allowed to destroy it!";
@ConfigField(name="RealEstate.Errors.Sign.NotAdmin")
public String msgErrorSignNotAdmin = "$cOnly an admin is allowed to destroy this sign!";
@ConfigField(name="RealEstate.Errors.Sign.NoTransaction")
public String msgErrorSignNoTransaction = "$cThis claim is no longer for rent, sell or lease, sorry...";
@ConfigField(name="RealEstate.Errors.Claim.DoesNotExist")
public String msgErrorClaimDoesNotExist = "$cThis claim does not exist!";
@ConfigField(name="RealEstate.Errors.Claim.AlreadyOwner", comment = "0: claim type")
public String msgErrorClaimAlreadyOwner = "$cYou are already the owner of this {0}!";
@ConfigField(name="RealEstate.Errors.Claim.NotSoldByOwner", comment = "0: claim type")
public String msgErrorClaimNotSoldByOwner = "$cThis {0} is not sold by its owner!";
@ConfigField(name="RealEstate.Errors.Claim.NotLeasedByOwner", comment = "0: claim type")
public String msgErrorClaimNotLeasedByOwner = "$cThis {0} is not leased by its owner!";
@ConfigField(name="RealEstate.Errors.Claim.NotRentedByOwner", comment = "0: claim type")
public String msgErrorClaimNotRentedByOwner = "$cThis {0} is not rented by its owner!";
@ConfigField(name="RealEstate.Errors.Claim.NoBuyPermission", comment = "0: claim type")
public String msgErrorClaimNoBuyPermission = "$cYou don't have permission to buy this {0}!";
@ConfigField(name="RealEstate.Errors.Claim.NoLeasePermission", comment = "0: claim type")
public String msgErrorClaimNoLeasePermission = "$cYou don't have permission to lease this {0}!";
@ConfigField(name="RealEstate.Errors.Claim.NoRentPermission", comment = "0: claim type")
public String msgErrorClaimNoRentPermission = "$cYou don't have permission to rent this {0}!";
@ConfigField(name="RealEstate.Errors.Claim.AlreadyLeased", comment = "0: claim type")
public String msgErrorClaimAlreadyLeased = "$cThis {0} is already leased!";
@ConfigField(name="RealEstate.Errors.Claim.AlreadyRented", comment = "0: claim type")
public String msgErrorClaimAlreadyRented = "$cThis {0} is already rented!";
@ConfigField(name="RealEstate.Errors.Claim.NoInfoPermission")
public String msgErrorClaimNoInfoPermission = "$cYou don't have permission to view this real estate informations!";
@ConfigField(name="RealEstate.Info.ExitOffer.None")
public String msgInfoExitOfferNone = "$bThere is currently no exit offer for this claim!";
@ConfigField(name="RealEstate.Info.ExitOffer.MadeByStatus", comment = "0: formatted price")
public String msgInfoExitOfferMadeByStatus = "$bYou offered to exit the contract for $a{0}, but your offer hasn't been accepted or denied yet...";
@ConfigField(name="RealEstate.Info.ExitOffer.MadeToStatus", comment = "0: player who made the offer; 1: formatted price")
public String msgInfoExitOfferMadeToStatus = "$a{0} $boffered to exit the contract for $a{1}";
@ConfigField(name="RealEstate.Info.ExitOffer.Cancel", comment = "0: cancel command")
public String msgInfoExitOfferCancel = "$bTo cancel your offer, use $d{0}";
@ConfigField(name="RealEstate.Info.ExitOffer.Accept", comment = "0: accept command")
public String msgInfoExitOfferAccept = "$bTo accept this offer, use $d{0}";
@ConfigField(name="RealEstate.Info.ExitOffer.Reject", comment = "0: reject command")
public String msgInfoExitOfferReject = "$bTo reject this offer, use $d{0}";
@ConfigField(name="RealEstate.Info.ExitOffer.CreatedBySelf", comment = "0: formatted price")
public String msgInfoExitOfferCreatedBySelf = "$bThe offer has been successfully created for $a{0}";
@ConfigField(name="RealEstate.Info.ExitOffer.CreatedByOther", comment = "0: player name, 1: claim type, 2: formatted price, 3: claim location")
public String msgInfoExitOfferCreatedByOther = "$a{0} $bhas created an offer to exit the transaction for the {1} at $a{3} $bfor $a{2}";
@ConfigField(name="RealEstate.Info.ExitOffer.AcceptedBySelf", comment = "0: claim type, 1:formatted price")
public String msgInfoExitOfferAcceptedBySelf = "$bThe {0} is no longer rented or leased, you have been charged $a{1}";
@ConfigField(name="RealEstate.Info.ExitOffer.AcceptedByOther", comment = "0: player name, 1: claim type, 2: formatted price, 3: claim location")
public String msgInfoExitOfferAcceptedByOther = "$a{0} $bhas accepted the offer to exit the transaction for the {1} at $a{3} $bfor $a{2}. It is no longer leased or rented.";
@ConfigField(name="RealEstate.Info.ExitOffer.RejectedBySelf")
public String msgInfoExitOfferRejectedBySelf = "$bThe exit offer has been refused.";
@ConfigField(name="RealEstate.Info.ExitOffer.RejectedByOther", comment = "0: player name, 1: claim type, 2: claim location")
public String msgInfoExitOfferRejectedByOther = "$a{0} $bhas refused the offer to exit the transaction for the {1} at $a{2}";
@ConfigField(name="RealEstate.Info.ExitOffer.CancelledBySelf")
public String msgInfoExitOfferCancelledBySelf = "$bThe exit offer has been cancelled.";
@ConfigField(name="RealEstate.Info.ExitOffer.CancelledByOther", comment = "0: player name, 1: claim type, 2: claim location")
public String msgInfoExitOfferCancelledByOther = "$a{0} $bhas cancelled the offer to exit the transaction for the {1} at $a{2}";
@ConfigField(name="RealEstate.Info.Claim.OwnerSold", comment = "0: buyer name, 1: claim type, 2: formatted price, 3: claim location")
public String msgInfoClaimOwnerSold = "$a{0} $bhas bought the {1} at $a{3} $bfor $a{2}";
@ConfigField(name="RealEstate.Info.Claim.OwnerLeaseStarted", comment = "0: buyer name, 1: claim type, 2: formatted price, 3: claim location, 4: payments left")
public String msgInfoClaimOwnerLeaseStarted = "$a{0} $bhas leased the {1} at $a{3} $bfor $a{2} with $a{4} $bpayments left";
@ConfigField(name="RealEstate.Info.Claim.OwnerRented", comment = "0: buyer name, 1: claim type, 2: formatted price, 3: claim location")
public String msgInfoClaimOwnerRented = "$a{0} $bhas rented the {1} at $a{3} $bfor $a{2}";
@ConfigField(name="RealEstate.Info.Claim.BuyerBought", comment = "1: claim type, 2: formatted price")
public String msgInfoClaimBuyerSold = "$bYou have bought the {1} for $a{2}";
@ConfigField(name="RealEstate.Info.Claim.BuyerLeaseStarted", comment = "1: claim type, 2: formatted price, 3: payments left")
public String msgInfoClaimBuyerLeaseStarted = "$bYou have leased the {1} for $a{2} with $a{3} $bpayments left";
@ConfigField(name="RealEstate.Info.Claim.BuyerRented", comment = "1: claim type, 2: formatted price")
public String msgInfoClaimBuyerRented = "$bYou have rented the {1} for $a{2}";
@ConfigField(name="RealEstate.Info.Claim.Info.Header")
public String msgInfoClaimInfoHeader = "$9-----= $f[$6RealEstate Lease Info$f]$9 =-----";
@ConfigField(name="RealEstate.Info.Claim.Info.Lease.GeneralNoBuyer", comment = "0: claim type, 1: payments left, 2: formatted price, 3: frequency")
public String msgInfoClaimInfoGeneralLeaseNoBuyer = "$bThis {0} is for lease for $a{1} $bpayments of $a{2} each. Payments are due every $a{3}";
@ConfigField(name="RealEstate.Info.Claim.Info.Lease.GeneralBuyer", comment = "0: claim type, 1: buyer name, 2: formatted price, 3: payments left, 4: next payment due, 5: frequency")
public String msgInfoClaimInfoGeneralLeaseBuyer = "$bThis {0} is currently leased by $a{1}$b for $a{2}$b. There is $a{3} $bpayments left. Next payment is in $a{4}$b. Payments are due every $a{5}";
@ConfigField(name="RealEstate.Info.Claim.Info.Lease.Oneline", comment = "0: claim area, 1: location, 2: payments left, 3: period, 4: formatted price")
public String msgInfoClaimInfoLeaseOneline = "$2{0} $bblocks to $2Lease $bat $2{1} $bfor $a{2} periods of $a{3}$b, each period costs $a{4}";
@ConfigField(name="RealEstate.Info.Claim.Info.Owner", comment = "0: owner name")
public String msgInfoClaimInfoOwner = "$bThe current owner is $a{0}";
@ConfigField(name="RealEstate.Info.Claim.Info.MainOwner", comment = "0: owner name")
public String msgInfoClaimInfoMainOwner = "$bThe main claim's owner is $a{0}";
@ConfigField(name="RealEstate.Info.Claim.Info.Note")
public String msgInfoClaimInfoNote = "$dNote: You will only get access to this subclaim.";
@ConfigField(name="RealEstate.List.Header", comment = "0: RE Offers|Sell Offers|Rent Offers|Lease Offers; 1: Page number; 2: Page count")
public String msgListTransactionsHeader = "$1----= $f[ $6{0} page $2 {1} $6/ $2{2} $f] $1=----";
@ConfigField(name="RealEstate.List.NextPage", comment="0: all|sell|rent|lease; 1: next page number")
public String msgListNextPage = "$6To see the next page, type $a/re list {0} {1}";
public Messages()
{
@ -86,7 +306,7 @@ public class Messages extends AnnotationConfig
this.loadConfig(RealEstate.languagesDirectory + "/" + RealEstate.instance.config.languageFile);
}
synchronized public String getMessage(String msgTemplate, String... args) {
public static String getMessage(String msgTemplate, String... args) {
for (int i = 0; i < args.length; i++) {
String param = args[i];
msgTemplate = msgTemplate.replace("{" + i + "}", param);
@ -101,7 +321,7 @@ public class Messages extends AnnotationConfig
//sends a color-coded message to a player
public static void sendMessage(CommandSender player, String msgTemplate, long delayInTicks, String... args) {
String message = RealEstate.instance.messages.getMessage(msgTemplate, args);
String message = getMessage(msgTemplate, args);
sendMessage(player, message, delayInTicks);
}

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
@ -156,29 +155,36 @@ public class RECommand extends BaseCommand
Location loc = player.getLocation();
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null);
ClaimRent cr = (ClaimRent)RealEstate.transactionsStore.getTransaction(claim);
String claimType = claim.parent == null ? "claim" : "subclaim";
String claimType = claim.parent == null ?
RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim;
if(!RealEstate.instance.config.cfgEnableAutoRenew)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Automatic renew is disabled!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorAutoRenewDisabled);
return;
}
if(newStatus == null)
{
Messages.sendMessage(player, RealEstate.instance.messages.msgRenewRentCurrently, cr.autoRenew ? "enabled" : "disabled", claimType);
Messages.sendMessage(player, RealEstate.instance.messages.msgRenewRentCurrently, cr.autoRenew ?
RealEstate.instance.messages.keywordEnabled :
RealEstate.instance.messages.keywordDisabled,
claimType);
}
else if(!newStatus.equalsIgnoreCase("enable") && !newStatus.equalsIgnoreCase("disable"))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Usage : /re renewrent [enable|disable]!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorCommandUsage, "/re renewrent [enable|disable]");
}
else if(cr.buyer.equals(player.getUniqueId()))
{
cr.autoRenew = newStatus.equalsIgnoreCase("enable");
RealEstate.transactionsStore.saveData();
Messages.sendMessage(player, RealEstate.instance.messages.msgRenewRentNow, cr.autoRenew ? "enabled" : "disabled", claimType);
Messages.sendMessage(player, RealEstate.instance.messages.msgRenewRentNow, cr.autoRenew ?
RealEstate.instance.messages.keywordEnabled :
RealEstate.instance.messages.keywordDisabled,
claimType);
}
else
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Only the buyer may change this setting!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorBuyerOnly);
}
}
@ -194,24 +200,23 @@ public class RECommand extends BaseCommand
BoughtTransaction bt = (BoughtTransaction)RealEstate.transactionsStore.getTransaction(player);
if(bt.exitOffer == null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "There is currently no exit offer for this claim!");
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferNone);
}
else if(bt.exitOffer.offerBy.equals(player.getUniqueId()))
{
String msg = RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You offered to exit the contract for " +
ChatColor.GREEN + bt.exitOffer.price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA +
", but your offer hasn't been accepted or denied yet...\n";
msg += ChatColor.AQUA + "To cancel your offer, just type " + ChatColor.LIGHT_PURPLE + "/re exitoffer cancel";
player.sendMessage(msg);
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferMadeByStatus,
RealEstate.econ.format(bt.exitOffer.price));
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferCancel,
"/re exitoffer cancel");
}
else// it is the other person
else// it is the other player
{
String msg = RealEstate.instance.config.chatPrefix + ChatColor.GREEN + Bukkit.getOfflinePlayer(bt.exitOffer.offerBy).getName() +
ChatColor.AQUA + " offered to exit the contract for " +
ChatColor.GREEN + bt.exitOffer.price + " " + RealEstate.econ.currencyNamePlural() + "\n";
msg += ChatColor.AQUA + "To accept the offer, just type " + ChatColor.LIGHT_PURPLE + "/re exitoffer accept\n";
msg += ChatColor.AQUA + "To refuse the offer, just type " + ChatColor.LIGHT_PURPLE + "/re exitoffer refuse\n";
player.sendMessage(msg);
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferMadeToStatus,
Bukkit.getOfflinePlayer(bt.exitOffer.offerBy).getName(), RealEstate.econ.format(bt.exitOffer.price));
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferAccept,
"/re exitoffer accept");
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferReject,
"/re exitoffer refuse");
}
}
@ -223,40 +228,40 @@ public class RECommand extends BaseCommand
BoughtTransaction bt = (BoughtTransaction)RealEstate.transactionsStore.getTransaction(player);
if(bt.exitOffer != null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"There is already an exit proposition for this transaction!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferAlreadyExists);
return;
}
if(bt.buyer == null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"No one is engaged by this transaction yet!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferNoBuyer);
return;
}
bt.exitOffer = new ExitOffer(player.getUniqueId(), price);
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"The proposition has been successfully created!");
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferCreatedBySelf,
RealEstate.econ.format(price));
UUID other = player.getUniqueId().equals(bt.owner) ? bt.buyer : bt.owner;
if(other != null)// not an admin claim
{
OfflinePlayer otherP = Bukkit.getOfflinePlayer(other);
Location loc = player.getLocation();
String claimType = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null).parent == null ? "claim" : "subclaim";
String claimType = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null).parent == null ?
RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim;
String location = "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: "
+ loc.getBlockZ() + "]";
if(otherP.isOnline())
{
((Player)otherP).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() +
ChatColor.AQUA + " has created an offer to exit the rent/lease contract for the " + claimType + " at " +
ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: "
+ loc.getBlockZ() + "]" + ChatColor.AQUA + " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(otherP.getPlayer(), RealEstate.instance.messages.msgInfoExitOfferCreatedByOther,
player.getName(), claimType, RealEstate.econ.format(price), location);
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(other);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() +
ChatColor.AQUA + " has created an offer to exit the rent/lease contract for the " + claimType + " at " +
ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: "
+ loc.getBlockZ() + "]" + ChatColor.AQUA + " for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
u.addMail(RealEstate.instance.config.chatPrefix +
Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCreatedByOther,
player.getName(), claimType, RealEstate.econ.format(price), location));
}
}
}
@ -271,36 +276,35 @@ public class RECommand extends BaseCommand
String claimType = claim.parent == null ? "claim" : "subclaim";
if(bt.exitOffer == null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"There has been no exit propositions for this transaction!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferNone);
}
else if(bt.exitOffer.offerBy.equals(player.getUniqueId()))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"You can't accept or refuse an offer you made!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferCantAcceptSelf);
}
else if(Utils.makePayment(player.getUniqueId(), bt.exitOffer.offerBy, bt.exitOffer.price, true, false))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"This exit offer has been accepted, the " + claimType + " is no longer rented or leased!");
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferAcceptedBySelf,
claimType, RealEstate.econ.format(bt.exitOffer.price));
UUID other = player.getUniqueId().equals(bt.owner) ? bt.buyer : bt.owner;
String location = "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() +
", Z: " + loc.getBlockZ() + "]";
if(other != null)
{
OfflinePlayer otherP = Bukkit.getOfflinePlayer(other);
if(otherP.isOnline())
{
((Player)otherP).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() +
ChatColor.AQUA + " has accepted your offer to exit the rent/lease contract for the " + claimType + " at " +
ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() +
", Z: " + loc.getBlockZ() + "]. It is no longer rented or leased.");
Messages.sendMessage(otherP.getPlayer(), RealEstate.instance.messages.msgInfoExitOfferAcceptedByOther,
player.getName(), claimType, RealEstate.econ.format(bt.exitOffer.price), location);
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(other);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() +
ChatColor.AQUA + " has accepted your offer to exit the rent/lease contract for the " + claimType + " at " +
ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() +
", Z: " + loc.getBlockZ() + "]. It is no longer rented or leased.");
u.addMail(RealEstate.instance.config.chatPrefix +
Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferAcceptedByOther,
player.getName(), claimType, RealEstate.econ.format(bt.exitOffer.price), location));
}
}
bt.exitOffer = null;
@ -323,37 +327,33 @@ public class RECommand extends BaseCommand
String claimType = claim.parent == null ? "claim" : "subclaim";
if(bt.exitOffer == null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"There has been no exit propositions for this transaction!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferNone);
}
else if(bt.exitOffer.offerBy.equals(player.getUniqueId()))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"You can't accept or refuse an offer you made!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferCantRefuseSelf);
}
else
{
bt.exitOffer = null;
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"This exit offer has been refused");
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferRejectedBySelf);
UUID other = player.getUniqueId().equals(bt.owner) ? bt.buyer : bt.owner;
String location = "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() +
", Z: " + loc.getBlockZ() + "]";
if(other != null)
{
OfflinePlayer otherP = Bukkit.getOfflinePlayer(other);
if(otherP.isOnline())
{
((Player)otherP).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() +
ChatColor.AQUA + " has refused your offer to exit the rent/lease contract for the " + claimType + " at " +
ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() +
", Z: " + loc.getBlockZ() + "]");
Messages.sendMessage(otherP.getPlayer(), RealEstate.instance.messages.msgInfoExitOfferRejectedByOther,
player.getName(), claimType, location);
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(other);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() +
ChatColor.AQUA + " has refused your offer to exit the rent/lease contract for the " + claimType + " at " +
ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() +
", Z: " + loc.getBlockZ() + "]");
u.addMail(RealEstate.instance.config.chatPrefix +
Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferRejectedByOther,
player.getName(), claimType, location));
}
}
}
@ -370,33 +370,31 @@ public class RECommand extends BaseCommand
if(bt.exitOffer.offerBy.equals(player.getUniqueId()))
{
bt.exitOffer = null;
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"This exit offer has been cancelled");
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoExitOfferCancelledBySelf);
UUID other = player.getUniqueId().equals(bt.owner) ? bt.buyer : bt.owner;
String location = "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() +
", Z: " + loc.getBlockZ() + "]";
if(other != null)
{
OfflinePlayer otherP = Bukkit.getOfflinePlayer(other);
if(otherP.isOnline())
{
((Player)otherP).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() +
ChatColor.AQUA + " has cancelled his offer to exit the rent/lease contract for the " + claimType + " at " +
ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: "
+ loc.getBlockZ() + "]");
Messages.sendMessage(otherP.getPlayer(), RealEstate.instance.messages.msgInfoExitOfferCancelledByOther,
player.getName(), claimType, location);
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(other);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() +
ChatColor.AQUA + " has cancelled his offer to exit the rent/lease contract for the " + claimType + " at " +
ChatColor.BLUE + "[" + loc.getWorld().getName() + ", X: " + loc.getBlockX() + ", Y: " + loc.getBlockY() + ", Z: "
+ loc.getBlockZ() + "]");
u.addMail(RealEstate.instance.config.chatPrefix +
Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCancelledByOther,
player.getName(), claimType, location));
}
}
}
else
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"Only the player who created this exit proposition may cancel it");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorExitOfferCantCancelOther);
}
}
}

View File

@ -44,21 +44,21 @@ public class REListener implements Listener
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(loc, false, null);
if(claim == null)// must have something to sell
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The sign you placed is not inside a claim!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNotInClaim);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
if(RealEstate.transactionsStore.anyTransaction(claim))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This claim already has an ongoing transaction!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignOngoingTransaction);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
if(RealEstate.transactionsStore.anyTransaction(claim.parent))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The parent claim already has an ongoing transaction!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignParentOngoingTransaction);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -67,8 +67,7 @@ public class REListener implements Listener
{
if(RealEstate.transactionsStore.anyTransaction(c))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"A subclaim of this claim already has an ongoing transaction!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignSubclaimOngoingTransaction);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -80,16 +79,18 @@ public class REListener implements Listener
{
if(!RealEstate.instance.config.cfgEnableSell)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Selling is disabled!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignSellingDisabled);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
String type = claim.parent == null ? "claim" : "subclaim";
String typeDisplay = claim.parent == null ?
RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim;
if(!RealEstate.perms.has(player, "realestate." + type + ".sell"))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to sell " + type + "s!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoSellPermission, typeDisplay);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -103,21 +104,21 @@ public class REListener implements Listener
}
catch (NumberFormatException e)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price you entered is not a valid number!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(1));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
if(price <= 0)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price must be greater than 0!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNegativePrice, event.getLine(1));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
if((price%1)!=0 && !RealEstate.instance.config.cfgUseDecimalCurrency) //if the price has a decimal number AND Decimal currency is disabled
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price cannot have a decimal number!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNonIntegerPrice, event.getLine(1));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -127,7 +128,7 @@ public class REListener implements Listener
{
if(!RealEstate.perms.has(player, "realestate.admin"))// admin may sell admin claims
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to sell admin claims!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoAdminSellPermission, typeDisplay);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -135,7 +136,7 @@ public class REListener implements Listener
}
else if(type.equals("claim") && !player.getUniqueId().equals(claim.ownerID))// only the owner may sell his claim
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You can only sell claims you own!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNotOwner, typeDisplay);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -150,15 +151,17 @@ public class REListener implements Listener
{
if(!RealEstate.instance.config.cfgEnableRent)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Renting is disabled!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignRentingDisabled);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
String type = claim.parent == null ? "claim" : "subclaim";
String typeDisplay = claim.parent == null ?
RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim;
if(!RealEstate.perms.has(player, "realestate." + type + ".rent"))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to rent " + type + "s!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoRentPermission, typeDisplay);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -172,21 +175,21 @@ public class REListener implements Listener
}
catch (NumberFormatException e)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price you entered is not a valid number!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(1));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
if(price <= 0)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price must be greater than 0!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNegativePrice, event.getLine(1));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
if((price%1)!=0 && !RealEstate.instance.config.cfgUseDecimalCurrency) //if the price has a decimal number AND Decimal currency is disabled
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price cannot have a decimal number!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNonIntegerPrice, event.getLine(1));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -199,9 +202,10 @@ public class REListener implements Listener
int duration = parseDuration(event.getLine(2));
if(duration == 0)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Couldn't read the date!\n" +
"Date must be formatted as follow : " + ChatColor.GREEN + "10 weeks" + ChatColor.RED + " or " +
ChatColor.GREEN + "3 days" + ChatColor.RED + " or " + ChatColor.GREEN + "1 week 3 days");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidDuration, event.getLine(2),
ChatColor.GREEN + "10 weeks",
ChatColor.GREEN + "3 days",
ChatColor.GREEN + "1 week 3 days");
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -219,16 +223,14 @@ public class REListener implements Listener
}
catch (NumberFormatException e)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"The number of rent periods you entered is not a valid number!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(3));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
if(rentPeriods <= 0)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"The number of rent periods must be greater than 0!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNegativeNumber, event.getLine(3));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -239,7 +241,7 @@ public class REListener implements Listener
{
if(!RealEstate.perms.has(player, "realestate.admin"))// admin may sell admin claims
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to rent admin claims!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoAdminRentPermission, typeDisplay);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -247,7 +249,7 @@ public class REListener implements Listener
}
else if(type.equals("claim") && !player.getUniqueId().equals(claim.ownerID))// only the owner may sell his claim
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You can only rent claims you own!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNotOwner, typeDisplay);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -262,15 +264,18 @@ public class REListener implements Listener
{
if(!RealEstate.instance.config.cfgEnableLease)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Leasing is disabled!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignLeasingDisabled);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
String type = claim.parent == null ? "claim" : "subclaim";
String typeDisplay = claim.parent == null ?
RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim;
if(!RealEstate.perms.has(player, "realestate." + type + ".lease"))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to lease " + type + "s!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoLeasePermission, typeDisplay);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -284,21 +289,21 @@ public class REListener implements Listener
}
catch (NumberFormatException e)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price you entered is not a valid number!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(1));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
if(price <= 0)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price must be greater than 0!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNegativePrice, event.getLine(1));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
}
if((price%1)!=0 && !RealEstate.instance.config.cfgUseDecimalCurrency) //if the price has a decimal number AND Decimal currency is disabled
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "The price cannot have a decimal number!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorNonIntegerPrice, event.getLine(1));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -315,8 +320,7 @@ public class REListener implements Listener
}
catch(Exception e)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"The number of payments you enterred is not a valid number!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidNumber, event.getLine(2));
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -329,9 +333,10 @@ public class REListener implements Listener
int frequency = parseDuration(event.getLine(3));
if(frequency == 0)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Couldn't read the date!\n" +
"Date must be formatted as follow" + ChatColor.GREEN + "10 weeks" + ChatColor.RED + " or " +
ChatColor.GREEN + "3 days" + ChatColor.RED + " or " + ChatColor.GREEN + "1 week 3 days");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorInvalidDuration, event.getLine(3),
ChatColor.GREEN + "10 weeks",
ChatColor.GREEN + "3 days",
ChatColor.GREEN + "1 week 3 days");
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -341,7 +346,7 @@ public class REListener implements Listener
{
if(!RealEstate.perms.has(player, "realestate.admin"))// admin may sell admin claims
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to lease admin claims!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoAdminLeasePermission, typeDisplay);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -349,7 +354,7 @@ public class REListener implements Listener
}
else if(type.equals("claim") && !player.getUniqueId().equals(claim.ownerID))// only the owner may sell his claim
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You can only lease claims you own!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNotOwner, typeDisplay);
event.setCancelled(true);
event.getBlock().breakNaturally();
return;
@ -402,8 +407,7 @@ public class REListener implements Listener
if(!RealEstate.transactionsStore.anyTransaction(claim))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"This claim is no longer for rent, sell or lease, sorry...");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorSignNoTransaction);
event.getClickedBlock().breakNaturally();
event.setCancelled(true);
return;
@ -432,15 +436,13 @@ public class REListener implements Listener
if(event.getPlayer() != null && tr.getOwner() != null && !event.getPlayer().getUniqueId().equals(tr.getOwner()) &&
!RealEstate.perms.has(event.getPlayer(), "realestate.destroysigns"))
{
event.getPlayer().sendMessage(RealEstate.instance.config.chatPrefix +
ChatColor.RED + "Only the author of the sell/rent/lease sign is allowed to destroy it");
Messages.sendMessage(event.getPlayer(), RealEstate.instance.messages.msgErrorSignNotAuthor);
event.setCancelled(true);
return;
}
else if(event.getPlayer() != null && tr.getOwner() == null && !RealEstate.perms.has(event.getPlayer(), "realestate.admin"))
{
event.getPlayer().sendMessage(RealEstate.instance.config.chatPrefix +
ChatColor.RED + "Only an admin is allowed to destroy this sign");
Messages.sendMessage(event.getPlayer(), RealEstate.instance.messages.msgErrorSignNotAdmin);
event.setCancelled(true);
return;
}

View File

@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
import me.EtienneDx.RealEstate.Messages;
import me.EtienneDx.RealEstate.RealEstate;
import me.EtienneDx.RealEstate.Utils;
import me.ryanhamshire.GriefPrevention.Claim;
@ -65,7 +66,7 @@ public class ClaimLease extends BoughtTransaction
if(sign.getBlock().getState() instanceof Sign)
{
Sign s = (Sign)sign.getBlock().getState();
s.setLine(0, RealEstate.instance.messages.getMessage(RealEstate.instance.config.cfgSignsHeader));
s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader));
s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceLease);
//s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER");
//s.setLine(2, paymentsLeft + "x " + price + " " + RealEstate.econ.currencyNamePlural());
@ -312,40 +313,34 @@ public class ClaimLease extends BoughtTransaction
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);// getting by id creates errors for subclaims
if(claim == null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This claim does not exist!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimDoesNotExist);
RealEstate.transactionsStore.cancelTransaction(claim);
return;
}
String claimType = claim.parent == null ? "claim" : "subclaim";
String claimTypeDisplay = claim.parent == null ?
RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim;
if (owner != null && owner.equals(player.getUniqueId()))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You already own this " + claimType + "!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimAlreadyOwner, claimTypeDisplay);
return;
}
if(claim.parent == null && owner != null && !owner.equals(claim.ownerID))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + Bukkit.getPlayer(owner).getDisplayName() +
" does not have the right to put this " + claimType + " for lease!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNotLeasedByOwner, claimTypeDisplay);
RealEstate.transactionsStore.cancelTransaction(claim);
return;
}
if(!player.hasPermission("realestate." + claimType + ".lease"))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You do not have the permission to lease " +
claimType + "s!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoLeasePermission, claimTypeDisplay);
return;
}
if(player.getUniqueId().equals(buyer))
if(player.getUniqueId().equals(buyer) || buyer != null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You are already leasing this " +
claimType + "!");
return;
}
if(buyer != null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Someone already leases this " +
claimType + "!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimAlreadyLeased, claimTypeDisplay);
return;
}
@ -360,43 +355,47 @@ public class ClaimLease extends BoughtTransaction
getHolder().breakNaturally();// leases don't have signs indicating the remaining time
update();
RealEstate.transactionsStore.saveData();
String location = "[" + player.getLocation().getWorld() + ", " +
"X: " + player.getLocation().getBlockX() + ", " +
"Y: " + player.getLocation().getBlockY() + ", " +
"Z: " + player.getLocation().getBlockZ() + "]";
RealEstate.instance.addLogEntry(
"[" + RealEstate.transactionsStore.dateFormat.format(RealEstate.transactionsStore.date) + "] " + player.getName() +
" has started leasing a " + claimType + " at " +
"[" + player.getLocation().getWorld() + ", " +
"X: " + player.getLocation().getBlockX() + ", " +
"Y: " + player.getLocation().getBlockY() + ", " +
"Z: " + player.getLocation().getBlockZ() + "] " +
"Price: " + price + " " + RealEstate.econ.currencyNamePlural());
location +
" Price: " + price + " " + RealEstate.econ.currencyNamePlural());
if(owner != null)
{
OfflinePlayer seller = Bukkit.getOfflinePlayer(owner);
if(RealEstate.instance.config.cfgMessageOwner && seller.isOnline())
{
((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + ChatColor.AQUA +
" has just paid for your lease for the " + claimType + " at " +
ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + sign.getBlockY() + ", Z: "
+ sign.getBlockZ() + "]" + ChatColor.AQUA +
" for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + ", " +
ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left");
Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimOwnerLeaseStarted,
player.getName(),
claimTypeDisplay,
RealEstate.econ.format(price),
location,
paymentsLeft + "");
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.owner);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + player.getName() + ChatColor.AQUA +
" has just paid for your lease for the " + claimType + " at " +
ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " + sign.getBlockY() + ", Z: "
+ sign.getBlockZ() + "]" + ChatColor.AQUA +
" for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + ", " +
ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left");
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + Messages.getMessage(
RealEstate.instance.messages.msgInfoClaimOwnerLeaseStarted,
player.getName(),
claimTypeDisplay,
RealEstate.econ.format(price),
location,
paymentsLeft + ""));
}
}
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully paid lease for this " + claimType +
" for " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + ", " +
ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left");
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimBuyerLeaseStarted,
claimTypeDisplay,
RealEstate.econ.format(price),
paymentsLeft + "");
}
}
@ -404,27 +403,32 @@ public class ClaimLease extends BoughtTransaction
public void preview(Player player)
{
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
String msg = "";
if(player.hasPermission("realestate.info"))
{
String claimType = claim.parent == null ? "claim" : "subclaim";
msg = ChatColor.BLUE + "-----= " + ChatColor.WHITE + "[" + ChatColor.GOLD + "RealEstate Rent Info" + ChatColor.WHITE + "]" +
ChatColor.BLUE + " =-----\n";
String claimTypeDisplay = claim.parent == null ?
RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim;
String msg;
msg = Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoHeader) + "\n";
if(buyer == null)
{
msg += ChatColor.AQUA + "This " + claimType + " is for lease for " +
ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments of " +
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + " each.\nPayments are due every " +
ChatColor.GREEN + Utils.getTime(frequency, null, true) + "\n";
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoGeneralLeaseNoBuyer,
claimTypeDisplay,
paymentsLeft + "",
RealEstate.econ.format(price),
Utils.getTime(frequency, null, true)) + "\n";
if(claimType.equalsIgnoreCase("claim"))
{
msg += ChatColor.AQUA + "The current owner is: " + ChatColor.GREEN + claim.getOwnerName();
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner,
claim.getOwnerName()) + "\n";
}
else
{
msg += ChatColor.AQUA + "The main claim owner is: " + ChatColor.GREEN + claim.getOwnerName() + "\n";
msg += ChatColor.LIGHT_PURPLE + "Note: " + ChatColor.AQUA + "You will only get access to this subclaim!";
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner,
claim.parent.getOwnerName()) + "\n";
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoNote) + "\n";
}
}
else
@ -439,40 +443,46 @@ public class ClaimLease extends BoughtTransaction
int daysLeft = frequency - days - 1;// we need to remove the current day
Duration timeRemaining = Duration.ofHours(24).minus(hours);
msg += ChatColor.AQUA + "This " + claimType + " is currently leased by " +
ChatColor.GREEN + Bukkit.getOfflinePlayer(buyer).getName() + ChatColor.AQUA + " for " +
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + ". There is " +
ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left. Next payment is in " +
ChatColor.GREEN + Utils.getTime(daysLeft, timeRemaining, true) + ChatColor.AQUA + ".\n";
if(claimType.equalsIgnoreCase("claim"))
{
msg += ChatColor.AQUA + "The current owner is: " + ChatColor.GREEN + claim.getOwnerName();
}
else
{
msg += ChatColor.AQUA + "The main claim owner is: " + ChatColor.GREEN + claim.getOwnerName();
}
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoGeneralLeaseBuyer,
claimTypeDisplay,
Bukkit.getOfflinePlayer(buyer).getName(),
RealEstate.econ.format(price),
paymentsLeft + "",
Utils.getTime(daysLeft, timeRemaining, true),
Utils.getTime(frequency, null, true)) + "\n";
if(claimType.equalsIgnoreCase("claim"))
{
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner,
claim.getOwnerName()) + "\n";
}
else
{
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner,
claim.parent.getOwnerName()) + "\n";
}
}
Messages.sendMessage(player, msg);
}
else
{
msg = RealEstate.instance.config.chatPrefix + ChatColor.RED + "You don't have the permission to view real estate informations!";
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoInfoPermission);
}
player.sendMessage(msg);
}
@Override
public void msgInfo(CommandSender cs)
{
cs.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() +
ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Lease " + ChatColor.AQUA + "at " + ChatColor.DARK_GREEN +
"[" + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getWorld().getName() + ", " +
"X: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockX() + ", " +
"Y: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockY() + ", " +
"Z: " + GriefPrevention.instance.dataStore.getClaim(claimId).getLesserBoundaryCorner().getBlockZ() + "] " + ChatColor.AQUA + "for " +
ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " periods of " + ChatColor.GREEN + Utils.getTime(frequency, Duration.ZERO, false) +
ChatColor.AQUA + ", each period costs " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural()
);
Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId);
String location = "[" + claim.getLesserBoundaryCorner().getWorld().getName() + ", " +
"X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " +
"Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " +
"Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "]";
Messages.sendMessage(cs, RealEstate.instance.messages.msgInfoClaimInfoLeaseOneline,
claim.getArea(),
location,
RealEstate.econ.format(price),
paymentsLeft + "");
}
}

View File

@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
import me.EtienneDx.RealEstate.Messages;
import me.EtienneDx.RealEstate.RealEstate;
import me.EtienneDx.RealEstate.Utils;
import me.ryanhamshire.GriefPrevention.Claim;
@ -80,7 +81,7 @@ public class ClaimRent extends BoughtTransaction
if(sign.getBlock().getState() instanceof Sign)
{
Sign s = (Sign) sign.getBlock().getState();
s.setLine(0, RealEstate.instance.messages.getMessage(RealEstate.instance.config.cfgSignsHeader));
s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader));
s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceRent);
//s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER");
String price_line = "";