feat: added last messages & fixed event checks with GP

This commit is contained in:
Etienne Dx 2022-01-18 19:20:34 +01:00
parent 75ba2173bc
commit d870f5e04d
13 changed files with 466 additions and 274 deletions

View File

@ -156,7 +156,7 @@
<dependency>
<groupId>com.github.EtienneDx</groupId>
<artifactId>AnnotationConfig</artifactId>
<version>cff4221</version>
<version>e9eab24</version>
</dependency>
</dependencies>
</project>

View File

@ -6,6 +6,9 @@ import org.bukkit.plugin.PluginManager;
import me.EtienneDx.RealEstate.Transactions.BoughtTransaction;
import me.EtienneDx.RealEstate.Transactions.Transaction;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.ClaimPermission;
import me.ryanhamshire.GriefPrevention.events.ClaimDeletedEvent;
import me.ryanhamshire.GriefPrevention.events.ClaimPermissionCheckEvent;
public class ClaimPermissionListener implements Listener {
@ -18,32 +21,60 @@ public class ClaimPermissionListener implements Listener {
@EventHandler
public void onClaimPermission(ClaimPermissionCheckEvent event) {
Transaction b = RealEstate.transactionsStore.getTransaction(event.getClaim());
Transaction transaction = RealEstate.transactionsStore.getTransaction(event.getClaim());
// we only have to remove the owner's access, the rest is handled by GP
if(
b != null &&
event.getCheckedUUID().equals(b.getOwner()) &&
b instanceof BoughtTransaction &&
((BoughtTransaction)b).getBuyer() != null
// if there is a transaction and the player is the owner
transaction != null &&
(
event.getCheckedUUID().equals(transaction.getOwner()) ||
(event.getClaim().isAdminClaim() && event.getCheckedPlayer().hasPermission("griefprevention.adminclaims"))
) &&
transaction instanceof BoughtTransaction &&
((BoughtTransaction)transaction).getBuyer() != null
) {
switch(event.getRequiredPermission()) {
case Edit:
event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantEdit);
event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantEdit));
break;
case Access:
event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantAccess);
event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantAccess));
break;
case Build:
event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantBuild);
event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantBuild));
break;
case Inventory:
event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantInventory);
event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantInventory));
break;
case Manage:
event.setDenialReason(() -> RealEstate.instance.messages.msgErrorClaimInTransactionCantManage);
event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorClaimInTransactionCantManage));
break;
default:
break;
}
}
if(event.getRequiredPermission() == ClaimPermission.Edit || event.getRequiredPermission() == ClaimPermission.Manage) {
for (Claim child : event.getClaim().children) {
Transaction tr = RealEstate.transactionsStore.getTransaction(child);
if(tr != null &&
tr instanceof BoughtTransaction &&
((BoughtTransaction)tr).getBuyer() != null
) {
event.setDenialReason(() -> Messages.getMessage(RealEstate.instance.messages.msgErrorSubclaimInTransaction));
}
}
}
}
// more of a safety measure, normally it shouldn't be needed
@EventHandler
public void onClaimDeleted(ClaimDeletedEvent event) {
Transaction tr = RealEstate.transactionsStore.getTransaction(event.getClaim());
if(tr != null) tr.tryCancelTransaction(null, true);
for (Claim child : event.getClaim().children) {
tr = RealEstate.transactionsStore.getTransaction(child);
if(tr != null) tr.tryCancelTransaction(null, true);
}
}
}

View File

@ -18,7 +18,9 @@ public class Config extends AnnotationConfig
public final String configFilePath = RealEstate.pluginDirPath + "config.yml";
public final String logFilePath = RealEstate.pluginDirPath + "GriefProtection_RealEstate.log";
public final String chatPrefix = "[" + ChatColor.GOLD + "RealEstate" + ChatColor.WHITE + "] ";
@ConfigField(name="RealEstate.Keywords.ChatPrefix", comment="What is displayed before any chat message")
public String chatPrefix = "$f[$6RealEstate$f] ";
@ConfigField(name="RealEstate.Keywords.SignsHeader", comment = "What is displayed in top of the signs")
public String cfgSignsHeader = "$6[RealEstate]";

View File

@ -6,13 +6,14 @@ import org.bukkit.plugin.PluginDescriptionFile;
import me.EtienneDx.AnnotationConfig.AnnotationConfig;
import me.EtienneDx.AnnotationConfig.ConfigField;
import me.EtienneDx.AnnotationConfig.ConfigFile;
import net.md_5.bungee.api.ChatColor;
@ConfigFile(header = "Use a YAML editor like NotepadPlusPlus to edit this file. \nAfter editing, back up your changes before reloading the server in case you made a syntax error. \nUse dollar signs ($) for formatting codes, which are documented here: http://minecraft.gamepedia.com/Formatting_codes.\n You can use {0}, {1} to include the different values indicated in the comments")
public class Messages extends AnnotationConfig
{
public PluginDescriptionFile pdf;
@ConfigField(name="RealEstate.Keywords.Enabled", comment = "Keywords used within other messages")
@ConfigField(name="RealEstate.Keywords.Enabled", comment = "Keywords used within other messages but with a longer text at the end just because i need to test some stuff")
public String keywordEnabled = "enabled";
@ConfigField(name="RealEstate.Keywords.Disabled")
@ -24,8 +25,20 @@ public class Messages extends AnnotationConfig
@ConfigField(name="RealEstate.Keywords.Subclaim")
public String keywordSubclaim = "subclaim";
@ConfigField(name="RealEstate.Keywords.AdminClaimPrefix")
public String keywordAdminClaimPrefix = "an admin";
@ConfigField(name="RealEstate.Keywords.ClaimPrefix")
public String keywordClaimPrefix = "a";
@ConfigField(name="RealEstate.Keywords.TheServer")
public String keywordTheServer = "The server";
@ConfigField(name="RealEstate.NoTransactionFound")
public String msgNoTransactionFound = "$cNo transaction found at your location!";
public String msgNoTransactionFound = "$cNo transaction found!";
@ConfigField(name="RealEstate.NoTransactionFoundHere")
public String msgNoTransactionFoundHere = "$cNo transaction found at your location!";
@ConfigField(name="RealEstate.PageMustBePositive")
public String msgPageMustBePositive = "$cPage must be a positive option";
@ -66,6 +79,9 @@ public class Messages extends AnnotationConfig
@ConfigField(name="RealEstate.Errors.InvalidOption")
public String msgErrorInvalidOption = "$cInvalid option provided!";
@ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantOwner")
public String msgErrorClaimInTransactionCantOwner = "$cThis claim is currently involved in a transaction, you can't modify it!";
@ConfigField(name="RealEstate.Errors.ClaimInTransaction.CantEdit")
public String msgErrorClaimInTransactionCantEdit = "$cThis claim is currently involved in a transaction, you can't edit it!";
@ -80,6 +96,9 @@ 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.ClaimInTransaction.Subclaim")
public String msgErrorSubclaimInTransaction = "$cA subclaim is currently involved in a transaction, you can't edit or manage the parent claim!";
@ConfigField(name="RealEstate.Errors.Command.Usage", comment = "0: command usage")
public String msgErrorCommandUsage = "$cUsage: {0}";
@ -87,6 +106,9 @@ public class Messages extends AnnotationConfig
@ConfigField(name="RealEstate.Errors.BuyerOnly")
public String msgErrorBuyerOnly = "$cOnly the buyer can perform this command!";
@ConfigField(name="RealEstate.Errors.Unexpected")
public String msgErrorUnexpected = "$cAn unexpected error has occured!";
@ConfigField(name="RealEstate.Errors.InvalidNumber", comment = "0: number")
public String msgErrorInvalidNumber = "$c{0} is not a valid number!";
@ -102,6 +124,30 @@ public class Messages extends AnnotationConfig
@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.NoMoneySelf")
public String msgErrorNoMoneySelf = "$cYou don't have enough money to make this transaction!";
@ConfigField(name="RealEstate.Errors.NoMoneyOther", comment = "0: Other player")
public String msgErrorNoMoneyOther = "$c{0} doesn't have enough money to make this transaction!";
@ConfigField(name="RealEstate.Errors.NoWithdrawSelf")
public String msgErrorNoWithdrawSelf = "$cCould not withdraw the money!";
@ConfigField(name="RealEstate.Errors.NoWithdrawOther", comment = "0: Other player")
public String msgErrorNoWithdrawOther = "$cCould not withdraw the money from {0}!";
@ConfigField(name="RealEstate.Errors.NoDepositSelf", comment = "0: Other player")
public String msgErrorNoDepositSelf = "$cCould not deposit the money to you, refunding {0}!";
@ConfigField(name="RealEstate.Errors.NoDepositOther", comment = "0: Other player")
public String msgErrorNoDepositOther = "$cCould not deposit the money to {0}, refunding you!";
@ConfigField(name="RealEstate.Errors.CantCancelAlreadyLeased", comment = "0: claim type")
public String msgErrorCantCancelAlreadyLeased = "$cThis {0} is currently being leased, you can't cancel the transaction!";
@ConfigField(name="RealEstate.Errors.CantCancelAlreadyRented", comment = "0: claim type")
public String msgErrorCantCancelAlreadyRented = "$cThis {0} is currently being rented, you can't cancel the transaction!";
@ConfigField(name="RealEstate.Errors.AutoRenew.Disabled")
public String msgErrorAutoRenewDisabled = "$cAutomatic renew is disabled!";
@ -207,11 +253,14 @@ public class Messages extends AnnotationConfig
@ConfigField(name="RealEstate.Errors.Claim.NoInfoPermission")
public String msgErrorClaimNoInfoPermission = "$cYou don't have permission to view this real estate informations!";
@ConfigField(name="RealEstate.Errors.Claim.NoClaimBlocks", comment = "0: area; 1: claim blocks remaining; 2: missing claim blocks")
public String msgErrorClaimNoClaimBlocks = "$cYou don't have enough claim blocks! You need $a{2}$c more claim blocks to claim this area. The claim requires $a{0}$c claim blocks, you only have $a{1}$c claim blocks left.";
@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...";
public String msgInfoExitOfferMadeByStatus = "$bYou offered to exit the contract for $a{0}$b, 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}";
@ -258,14 +307,14 @@ public class Messages extends AnnotationConfig
@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.BuyerBought", comment = "0: claim type, 1: formatted price")
public String msgInfoClaimBuyerSold = "$bYou have bought the {0} for $a{1}";
@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.BuyerLeaseStarted", comment = "0: claim type, 1: formatted price, 2: payments left")
public String msgInfoClaimBuyerLeaseStarted = "$bYou have leased the {0} for $a{1} with $a{2} $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.BuyerRented", comment = "0: claim type, 1: formatted price")
public String msgInfoClaimBuyerRented = "$bYou have rented the {0} for $a{1}";
@ConfigField(name="RealEstate.Info.Claim.Info.Lease.Header")
public String msgInfoClaimInfoLeaseHeader = "$9-----= $f[$6RealEstate Lease Info$f]$9 =-----";
@ -279,14 +328,32 @@ public class Messages extends AnnotationConfig
@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.Lease.PaymentBuyer", comment = "0: claim type, 1: location, 2: formatted price, 3: payments left")
public String msgInfoClaimInfoLeasePaymentBuyer = "$bPaid lease for the {0} at $a{1} $bfor $a{2}$b. There are $a{3} $bpayments left.";
@ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentOwner", comment = "0: player name, 1: claim type, 2: location, 3: formatted price, 4: payments left")
public String msgInfoClaimInfoLeasePaymentOwner = "$a{0} $bpaid lease for the {1} at $a{2} $bfor $a{3}$b. There are $a{4} $bpayments left.";
@ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentBuyerFinal", comment = "0: claim type, 1: location, 2: formatted price")
public String msgInfoClaimInfoLeasePaymentBuyerFinal = "$bPaid final lease for the {0} at $a{1} $bfor $a{2}$b. The {0} is now your property.";
@ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentOwnerFinal", comment = "0: player name, 1: claim type, 2: location, 3: formatted price")
public String msgInfoClaimInfoLeasePaymentOwnerFinal = "$a{0} $bpaid final lease for the {1} at $a{2} $bfor $a{3}$b. The {1} is now $a{0}$b's property.";
@ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentBuyerCancelled", comment = "0: claim type, 1: location, 2: formatted price")
public String msgInfoClaimInfoLeasePaymentBuyerCancelled = "$bCouldn't pay the lease for the {0} at $a{1} $bfor $a{2}$b. The lease has been cancelled.";
@ConfigField(name="RealEstate.Info.Claim.Info.Lease.PaymentOwnerCancelled", comment = "0: player name, 1: claim type, 2: location, 3: formatted price")
public String msgInfoClaimInfoLeasePaymentOwnerCancelled = "$a{0} $bcouldn't pay the lease for the {1} at $a{2} $bfor $a{3}$b. The lease has been cancelled.";
@ConfigField(name="RealEstate.Info.Claim.Info.Rent.Header")
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{3}.";
public String msgInfoClaimInfoGeneralRentNoBuyer = "$bThis {0} is for rent for $a{1}$b per $a{2}.";
@ConfigField(name="RealEstate.Info.Claim.Info.Rent.GeneralBuyer", comment = "0: claim type, 1: buyer name, 2: formatted price, 3: time left in current period, 5: 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{5}";
@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}";
@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.";
@ -300,6 +367,30 @@ public class Messages extends AnnotationConfig
@ConfigField(name="RealEstate.Info.Claim.Info.Rent.Oneline", comment = "0: claim area, 1: location, 2: formatted price, 3: duration")
public String msgInfoClaimInfoRentOneline = "$2{0} $bblocks to $2Rent $bat $2{1} $bfor $a{2}$b per $a{3}";
@ConfigField(name="RealEstate.Info.Claim.Info.Rent.PaymentBuyer", comment = "0: claim type, 1: location, 2: formatted price")
public String msgInfoClaimInfoRentPaymentBuyer = "$bPaid rent for the {0} at $a{1} $bfor $a{2}$b.";
@ConfigField(name="RealEstate.Info.Claim.Info.Rent.PaymentOwner", comment = "0: player name, 1: claim type, 2: location, 3: formatted price")
public String msgInfoClaimInfoRentPaymentOwner = "$a{0} $bpaid rent for the {1} at $a{2} $bfor $a{3}$b.";
@ConfigField(name="RealEstate.Info.Claim.Info.Rent.PaymentBuyerCancelled", comment = "0: claim type, 1: location, 2: formatted price")
public String msgInfoClaimInfoRentPaymentBuyerCancelled = "$bCouldn't pay the rent for the {0} at $a{1} $bfor $a{2}$b. The rent has been cancelled.";
@ConfigField(name="RealEstate.Info.Claim.Info.Rent.PaymentOwnerCancelled", comment = "0: player name, 1: claim type, 2: location, 3: formatted price")
public String msgInfoClaimInfoRentPaymentOwnerCancelled = "$a{0} $bcouldn't pay the rent for the {1} at $a{2} $bfor $a{3}$b. The rent has been cancelled.";
@ConfigField(name="RealEstate.Info.Claim.Info.Rent.RentCancelled", comment = "0: claim type, 1: location")
public String msgInfoClaimInfoRentCancelled = "$bThe rent for the {0} at $a{1} $bis now over, your access has been revoked.";
@ConfigField(name="RealEstate.Info.Claim.Info.Sell.Header")
public String msgInfoClaimInfoSellHeader = "$9-----= $f[$6RealEstate Sale Info$f]$9 =-----";
@ConfigField(name="RealEstate.Info.Claim.Info.Sell.General", comment = "0: claim type, 1: formatted price")
public String msgInfoClaimInfoSellGeneral = "$bThis {0} is for sale for $a{1}";
@ConfigField(name="RealEstate.Info.Claim.Info.Sell.Oneline", comment = "0: claim area, 1: location, 2: formatted price")
public String msgInfoClaimInfoSellOneline = "$2{0} $bblocks to $2Sell $bat $2{1} $bfor $a{2}";
@ConfigField(name="RealEstate.Info.Claim.Info.Owner", comment = "0: owner name")
public String msgInfoClaimInfoOwner = "$bThe current owner is $a{0}";
@ -309,6 +400,24 @@ public class Messages extends AnnotationConfig
@ConfigField(name="RealEstate.Info.Claim.Info.Note")
public String msgInfoClaimInfoNote = "$dNote: You will only get access to this subclaim.";
@ConfigField(name="RealEstate.Info.Claim.Created.Sell", comment = "0: claim prefix, 1: claim type, 2: formatted price")
public String msgInfoClaimCreatedSell = "$bYou have successfully created {0} {1} sale for $a{2}";
@ConfigField(name="RealEstate.Info.Claim.Created.Lease", comment = "0: claim prefix, 1: claim type, 2: formatted price, 3: payments count, 4: frequency")
public String msgInfoClaimCreatedLease = "$bYou have successfully created {0} {1} lease for $a{3}$b payments of $a{2}$b each. Payments are due every $a{4}";
@ConfigField(name="RealEstate.Info.Claim.Created.Rent", comment = "0: claim prefix, 1: claim type, 2: formatted price, 3: duration")
public String msgInfoClaimCreatedRent = "$bYou have successfully created {0} {1} rent for $a{2}$b per $a{3}";
@ConfigField(name="RealEstate.Info.Claim.Created.SellBroadcast", comment = "0: player name, 1: claim prefix, 2: claim type, 3: formatted price")
public String msgInfoClaimCreatedSellBroadcast = "$a{0} $bhas created {1} {2} sale for $a{3}";
@ConfigField(name="RealEstate.Info.Claim.Created.LeaseBroadcast", comment = "0: player name, 1: claim prefix, 2: claim type, 3: formatted price, 4: payments count, 5: frequency")
public String msgInfoClaimCreatedLeaseBroadcast = "$a{0} $bhas created {1} {2} lease for $a{4}$b payments of $a{3}$b each. Payments are due every $a{5}";
@ConfigField(name="RealEstate.Info.Claim.Created.RentBroadcast", comment = "0: player name, 1: claim prefix, 2: claim type, 3: formatted price, 4: duration")
public String msgInfoClaimCreatedRentBroadcast = "$a{0} $bhas created {1} {2} rent for $a{3}$b per $a{4}";
@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=----";
@ -328,12 +437,19 @@ public class Messages extends AnnotationConfig
}
public static String getMessage(String msgTemplate, String... args) {
return getMessage(msgTemplate, true, args);
}
public static String getMessage(String msgTemplate, boolean withPrefix, String... args) {
if (withPrefix) {
msgTemplate = RealEstate.instance.config.chatPrefix + msgTemplate;
}
for (int i = 0; i < args.length; i++) {
String param = args[i];
msgTemplate = msgTemplate.replace("{" + i + "}", param);
msgTemplate = msgTemplate.replaceAll("\\{" + i + "\\}", param);
}
return msgTemplate.replace('$', (char) 0x00A7);
return msgTemplate.replace('$', ChatColor.COLOR_CHAR);
}
//sends a color-coded message to a player
public static void sendMessage(CommandSender player, String msgTemplate, String... args) {
@ -348,13 +464,7 @@ public class Messages extends AnnotationConfig
//sends a color-coded message to a player
public static void sendMessage(CommandSender player, String message) {
if (message == null || message.length() == 0) return;
if (player == null) {
RealEstate.instance.log.info(message);
} else {
player.sendMessage(RealEstate.instance.config.chatPrefix + message.replace('$', (char) 0x00A7));
}
sendMessage(player, getMessage(message), 0);
}
public static void sendMessage(CommandSender player, String message, long delayInTicks) {

View File

@ -47,7 +47,7 @@ public class RECommand extends BaseCommand
}
else
{
Messages.sendMessage(player, RealEstate.instance.messages.msgNoTransactionFound);
Messages.sendMessage(player, RealEstate.instance.messages.msgNoTransactionFoundHere);
}
}
@ -259,8 +259,7 @@ public class RECommand extends BaseCommand
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(other);
u.addMail(RealEstate.instance.config.chatPrefix +
Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCreatedByOther,
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCreatedByOther,
player.getName(), claimType, RealEstate.econ.format(price), location));
}
}
@ -302,8 +301,7 @@ public class RECommand extends BaseCommand
{
User u = RealEstate.ess.getUser(other);
u.addMail(RealEstate.instance.config.chatPrefix +
Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferAcceptedByOther,
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferAcceptedByOther,
player.getName(), claimType, RealEstate.econ.format(bt.exitOffer.price), location));
}
}
@ -351,8 +349,7 @@ public class RECommand extends BaseCommand
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(other);
u.addMail(RealEstate.instance.config.chatPrefix +
Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferRejectedByOther,
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferRejectedByOther,
player.getName(), claimType, location));
}
}
@ -386,8 +383,7 @@ public class RECommand extends BaseCommand
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(other);
u.addMail(RealEstate.instance.config.chatPrefix +
Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCancelledByOther,
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoExitOfferCancelledByOther,
player.getName(), claimType, location));
}
}

View File

@ -399,8 +399,10 @@ public class REListener implements Listener
event.getClickedBlock().getState() instanceof Sign)
{
Sign sign = (Sign)event.getClickedBlock().getState();
RealEstate.instance.log.info(sign.getLine(0));
// it is a real estate sign
if(ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(RealEstate.instance.config.cfgSignsHeader)))
if(ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(ChatColor.stripColor(
Messages.getMessage(RealEstate.instance.config.cfgSignsHeader, false))))
{
Player player = event.getPlayer();
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(event.getClickedBlock().getLocation(), false, null);

View File

@ -112,78 +112,78 @@ public class RealEstate extends JavaPlugin
{
return;
}
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim));
});
manager.getCommandConditions().addCondition("claimHasTransaction", (context) -> {
if(!context.getIssuer().isPlayer())
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly));
}
Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null);
if(c == null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim));
}
Transaction tr = transactionsStore.getTransaction(c);
if(tr == null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNoOngoingTransaction);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNoOngoingTransaction));
}
});
manager.getCommandConditions().addCondition("inPendingTransactionClaim", (context) -> {
if(!context.getIssuer().isPlayer())
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly));
}
Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null);
if(c == null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim));
}
Transaction tr = transactionsStore.getTransaction(c);
if(tr == null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotRentNorLease);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotRentNorLease));
}
else if(tr instanceof BoughtTransaction && ((BoughtTransaction)tr).getBuyer() != null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorAlreadyBought);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorAlreadyBought));
}
});
manager.getCommandConditions().addCondition("inBoughtClaim", (context) -> {
if(!context.getIssuer().isPlayer())
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly));
}
Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null);
if(c == null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim));
}
Transaction tr = transactionsStore.getTransaction(c);
if(tr == null || !(tr instanceof BoughtTransaction))
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotRentNorLease);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotRentNorLease));
}
});
manager.getCommandConditions().addCondition("partOfBoughtTransaction", context -> {
if(!context.getIssuer().isPlayer())
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly));
}
Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null);
if(c == null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim));
}
Transaction tr = transactionsStore.getTransaction(c);
if(tr == null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNoOngoingTransaction);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNoOngoingTransaction));
}
if(!(tr instanceof BoughtTransaction))
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotRentNorLease);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotRentNorLease));
}
if((((BoughtTransaction)tr).buyer != null && ((BoughtTransaction)tr).buyer.equals(context.getIssuer().getPlayer().getUniqueId())) ||
(tr.getOwner() != null && (tr.getOwner().equals(context.getIssuer().getPlayer().getUniqueId()))) ||
@ -191,26 +191,26 @@ public class RealEstate extends JavaPlugin
{
return;
}
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotPartOfTransaction);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotPartOfTransaction));
});
manager.getCommandConditions().addCondition("partOfRent", context -> {
if(!context.getIssuer().isPlayer())
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorPlayerOnly);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorPlayerOnly));
}
Claim c = GriefPrevention.instance.dataStore.getClaimAt(context.getIssuer().getPlayer().getLocation(), false, null);
if(c == null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorOutOfClaim);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorOutOfClaim));
}
Transaction tr = transactionsStore.getTransaction(c);
if(tr == null)
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNoOngoingTransaction);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNoOngoingTransaction));
}
if(!(tr instanceof ClaimRent))
{
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorRentOnly);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorRentOnly));
}
if((((ClaimRent)tr).buyer != null && ((ClaimRent)tr).buyer.equals(context.getIssuer().getPlayer().getUniqueId())) ||
(tr.getOwner() != null && (tr.getOwner().equals(context.getIssuer().getPlayer().getUniqueId()))) ||
@ -218,11 +218,11 @@ public class RealEstate extends JavaPlugin
{
return;
}
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorNotPartOfTransaction);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorNotPartOfTransaction));
});
manager.getCommandConditions().addCondition(Double.class, "positiveDouble", (c, exec, value) -> {
if(value > 0) return;
throw new ConditionFailedException(config.chatPrefix + messages.msgErrorValueGreaterThanZero);
throw new ConditionFailedException(Messages.getMessage(messages.msgErrorValueGreaterThanZero));
});
}

View File

@ -17,11 +17,12 @@ class SendPlayerMessageTask implements Runnable
@Override
public void run()
{
if(player == null)
{
RealEstate.instance.log.info(message);
return;
}
Messages.sendMessage(this.player, this.message);
if (message == null || message.length() == 0) return;
if (player == null) {
RealEstate.instance.log.info(message);
} else {
player.sendMessage(message);
}
}
}

View File

@ -66,7 +66,7 @@ public class ClaimLease extends BoughtTransaction
if(sign.getBlock().getState() instanceof Sign)
{
Sign s = (Sign)sign.getBlock().getState();
s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader));
s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader, false));
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());
@ -125,7 +125,10 @@ public class ClaimLease extends BoughtTransaction
OfflinePlayer buyerPlayer = Bukkit.getOfflinePlayer(buyer);
OfflinePlayer seller = owner == null ? null : Bukkit.getOfflinePlayer(owner);
String claimType = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null).parent == null ? "claim" : "subclaim";
String claimType = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null).parent == null ?
RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim;
String location = "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() +
", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]";
if(Utils.makePayment(owner, buyer, price, false, false))
{
@ -135,42 +138,42 @@ public class ClaimLease extends BoughtTransaction
{
if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer)
{
((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"Paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() +
", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + " for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() +
ChatColor.AQUA + ", " + ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left");
Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyer,
claimType,
location,
RealEstate.econ.format(price),
paymentsLeft + "");
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.buyer);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"Paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() +
", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + " for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() +
ChatColor.AQUA + ", " + ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left");
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyer,
claimType,
location,
RealEstate.econ.format(price),
paymentsLeft + ""));
}
if(owner != null)
{
if(seller.isOnline() && RealEstate.instance.config.cfgMessageOwner)
{
((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() +
ChatColor.AQUA + " has paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" +
sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + " at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() +
ChatColor.AQUA + ", " + ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left");
Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwner,
buyerPlayer.getName(),
claimType,
location,
RealEstate.econ.format(price),
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 + buyerPlayer.getName() +
ChatColor.AQUA + " has paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" +
sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + " at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() +
ChatColor.AQUA + ", " + ChatColor.GREEN + paymentsLeft + ChatColor.AQUA + " payments left");
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwner,
buyerPlayer.getName(),
claimType,
location,
RealEstate.econ.format(price),
paymentsLeft + ""));
}
}
}
@ -178,40 +181,36 @@ public class ClaimLease extends BoughtTransaction
{
if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer)
{
((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"Paid final lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() +
", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + " for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() +
ChatColor.AQUA + ", the " + claimType + " is now yours");
Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyerFinal,
claimType,
location,
RealEstate.econ.format(price));
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.buyer);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"Paid final lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() +
", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + " for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() +
ChatColor.AQUA + ", the " + claimType + " is now yours");
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyerFinal,
claimType,
location,
RealEstate.econ.format(price)));
}
if(seller.isOnline() && RealEstate.instance.config.cfgMessageOwner)
{
((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() +
ChatColor.AQUA + " has paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" +
sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + "at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() +
ChatColor.AQUA + ", the " + claimType + " is now his property");
Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwnerFinal,
buyerPlayer.getName(),
claimType,
location,
RealEstate.econ.format(price));
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.owner);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() +
ChatColor.AQUA + " has paid lease for the " + claimType + " at " + ChatColor.BLUE + "[" +
sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + "at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() +
ChatColor.AQUA + ", the " + claimType + " is now his property");
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwnerFinal,
buyerPlayer.getName(),
claimType,
location,
RealEstate.econ.format(price)));
}
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
@ -236,39 +235,44 @@ public class ClaimLease extends BoughtTransaction
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
String claimType = claim.parent == null ? "claim" : "subclaim";
String claimType = claim.parent == null ?
RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim;
String location = "[" + sign.getWorld().getName() + ", X: " +
sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]";
if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer)
{
((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"Couldn't pay the lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " +
sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.RED + ", the transaction has been cancelled.");
Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyerCancelled,
claimType,
location,
RealEstate.econ.format(price));
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.buyer);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"Couldn't pay the lease for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " +
sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.RED + ", the transaction has been cancelled.");
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentBuyerCancelled,
claimType,
location,
RealEstate.econ.format(price)));
}
if(seller.isOnline() && RealEstate.instance.config.cfgMessageOwner)
{
((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() +
ChatColor.AQUA + " couldn't pay lease for the " + claimType + " at " + ChatColor.BLUE + "[" +
sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + ", the transaction has been cancelled");
Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwnerCancelled,
buyerPlayer.getName(),
claimType,
location,
RealEstate.econ.format(price));
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.owner);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + buyerPlayer.getName() +
ChatColor.AQUA + " couldn't pay lease for the " + claimType + " at " + ChatColor.BLUE + "[" +
sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + ", the transaction has been cancelled");
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoLeasePaymentOwnerCancelled,
buyerPlayer.getName(),
claimType,
location,
RealEstate.econ.format(price)));
}
claim.managers.remove(buyer.toString());
@ -294,9 +298,13 @@ public class ClaimLease extends BoughtTransaction
else
{
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
if(p != null)
p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This " + (claim.parent == null ? "claim" : "subclaim") +
" is currently leased, you can't cancel the transaction!");
if(p != null) {
Messages.sendMessage(p, RealEstate.instance.messages.msgErrorCantCancelAlreadyLeased,
claim.parent == null ?
RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim
);
}
return false;
}
}
@ -382,8 +390,7 @@ public class ClaimLease extends BoughtTransaction
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.owner);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.GREEN + Messages.getMessage(
RealEstate.instance.messages.msgInfoClaimOwnerLeaseStarted,
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimOwnerLeaseStarted,
player.getName(),
claimTypeDisplay,
RealEstate.econ.format(price),
@ -479,7 +486,7 @@ public class ClaimLease extends BoughtTransaction
"Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "]";
Messages.sendMessage(cs, RealEstate.instance.messages.msgInfoClaimInfoLeaseOneline,
claim.getArea(),
claim.getArea() + "",
location,
RealEstate.econ.format(price),
paymentsLeft + "");

View File

@ -81,7 +81,7 @@ public class ClaimRent extends BoughtTransaction
if(sign.getBlock().getState() instanceof Sign)
{
Sign s = (Sign) sign.getBlock().getState();
s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader));
s.setLine(0, Messages.getMessage(RealEstate.instance.config.cfgSignsHeader, false));
s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceRent);
//s.setLine(2, owner != null ? Bukkit.getOfflinePlayer(owner).getName() : "SERVER");
String price_line = "";
@ -164,10 +164,15 @@ public class ClaimRent extends BoughtTransaction
GriefPrevention.instance.dataStore.saveClaim(claim);
if(msgBuyer && Bukkit.getOfflinePlayer(buyer).isOnline() && RealEstate.instance.config.cfgMessageBuyer)
{
Bukkit.getPlayer(buyer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"The rent for the " + (claim.parent == null ? "claim" : "subclaim") + " at " + ChatColor.BLUE + "[" +
sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.AQUA + " is now over, your access has been revoked.");
String location = "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]";
String claimType = claim.parent == null ?
RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim;
Messages.sendMessage(Bukkit.getPlayer(buyer), RealEstate.instance.messages.msgInfoClaimInfoRentCancelled,
claimType,
location);
}
buyer = null;
RealEstate.transactionsStore.saveData();
@ -181,7 +186,11 @@ public class ClaimRent extends BoughtTransaction
OfflinePlayer buyerPlayer = Bukkit.getOfflinePlayer(this.buyer);
OfflinePlayer seller = owner == null ? null : Bukkit.getOfflinePlayer(owner);
String claimType = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null).parent == null ? "claim" : "subclaim";
String claimType = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null).parent == null ?
RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim;
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))
{
@ -189,38 +198,38 @@ public class ClaimRent extends BoughtTransaction
startDate = LocalDateTime.now();
if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer)
{
((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"Paid rent for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() +
", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + "for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoRentPaymentBuyer,
claimType,
location,
RealEstate.econ.format(price));
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.buyer);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA +
"Paid rent for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " + sign.getBlockX() +
", Y: " + sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + "for the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentPaymentBuyer,
claimType,
location,
RealEstate.econ.format(price)));
}
if(seller != null)
{
if(seller.isOnline() && RealEstate.instance.config.cfgMessageOwner)
{
((Player)seller).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + buyerPlayer.getName() +
" has paid rent for the " + claimType + " at " + ChatColor.BLUE + "[" +
sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + "at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(seller.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoRentPaymentOwner,
buyerPlayer.getName(),
claimType,
location,
RealEstate.econ.format(price));
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.owner);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + buyerPlayer.getName() +
" has paid rent for the " + claimType + " at " + ChatColor.BLUE + "[" +
sign.getWorld().getName() + ", X: " + sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" +
ChatColor.AQUA + "at the price of " + ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentPaymentOwner,
buyerPlayer.getName(),
claimType,
location,
RealEstate.econ.format(price)));
}
}
@ -229,18 +238,18 @@ public class ClaimRent extends BoughtTransaction
{
if(buyerPlayer.isOnline() && RealEstate.instance.config.cfgMessageBuyer)
{
((Player)buyerPlayer).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"Couldn't pay the rent for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " +
sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.RED + ", your access has been revoked.");
Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoRentPaymentBuyerCancelled,
claimType,
location,
RealEstate.econ.format(price));
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(this.buyer);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"Couldn't pay the rent for the " + claimType + " at " + ChatColor.BLUE + "[" + sign.getWorld().getName() + ", X: " +
sign.getBlockX() + ", Y: " +
sign.getBlockY() + ", Z: " + sign.getBlockZ() + "]" + ChatColor.RED + ", your access has been revoked.");
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoRentPaymentBuyerCancelled,
claimType,
location,
RealEstate.econ.format(price)));
}
unRent(false);
return;
@ -268,9 +277,13 @@ public class ClaimRent extends BoughtTransaction
else
{
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
if(p != null)
p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "This " + (claim.parent == null ? "claim" : "subclaim") +
" is currently rented, you can't cancel the transaction!");
if(p != null) {
Messages.sendMessage(p, RealEstate.instance.messages.msgErrorCantCancelAlreadyRented,
claim.parent == null ?
RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim
);
}
return false;
}
}
@ -477,18 +490,10 @@ public class ClaimRent extends BoughtTransaction
"Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "]";
Messages.sendMessage(cs, RealEstate.instance.messages.msgInfoClaimInfoRentOneline,
claim.getArea(),
claim.getArea() + "",
location,
RealEstate.econ.format(price),
Utils.getTime(duration, Duration.ZERO, false));
cs.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() +
ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Rent " + 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 + price + " " + RealEstate.econ.currencyNamePlural() + ChatColor.AQUA + " per period of " + ChatColor.GREEN +
Utils.getTime(duration, Duration.ZERO, false));
}
}

View File

@ -4,6 +4,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;
@ -37,7 +38,7 @@ public class ClaimSell extends ClaimTransaction
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, false));
s.setLine(1, ChatColor.DARK_GREEN + RealEstate.instance.config.cfgReplaceSell);
s.setLine(2, owner != null ? Utils.getSignString(Bukkit.getOfflinePlayer(owner).getName()) : "SERVER");
if(RealEstate.instance.config.cfgUseCurrencySymbol)
@ -85,38 +86,40 @@ public class ClaimSell extends ClaimTransaction
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 (player.getUniqueId().equals(owner))
{
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 sell this " + claimType + "!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNotSoldByOwner, claimTypeDisplay);
RealEstate.transactionsStore.cancelTransaction(claim);
return;
}
if(!player.hasPermission("realestate." + claimType + ".buy"))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "You do not have the permission to purchase " +
claimType + "s!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoBuyPermission, claimTypeDisplay);
return;
}
// for real claims, you may need to have enough claim blocks in reserve to purchase it (if transferClaimBlocks is false)
if(claimType.equalsIgnoreCase("claim") && !RealEstate.instance.config.cfgTransferClaimBlocks &&
GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).getRemainingClaimBlocks() < claim.getArea())
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"You don't have enough claim blocks to purchase this claim, you need to get " + ChatColor.DARK_GREEN +
(claim.getArea() - GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).getRemainingClaimBlocks()) +
ChatColor.RED + " more blocks!");
int remaining = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).getRemainingClaimBlocks();
int area = claim.getArea();
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorClaimNoClaimBlocks,
area + "",
remaining + "",
(area - remaining) + "");
return;
}
// the player has the right to buy, let's make the payment
@ -127,8 +130,15 @@ public class ClaimSell extends ClaimTransaction
// normally, this is always the case, so it's not necessary, but until I proven my point, here
if(claim.parent != null || claim.ownerID.equals(player.getUniqueId()))
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully purchased this " + claimType +
" for " + ChatColor.GREEN + price + RealEstate.econ.currencyNamePlural());
String location = "[" + player.getLocation().getWorld() + ", " +
"X: " + player.getLocation().getBlockX() + ", " +
"Y: " + player.getLocation().getBlockY() + ", " +
"Z: " + player.getLocation().getBlockZ() + "]";
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimBuyerSold,
claimTypeDisplay,
RealEstate.econ.format(price));
RealEstate.instance.addLogEntry(
"[" + RealEstate.transactionsStore.dateFormat.format(RealEstate.transactionsStore.date) + "] " + player.getName() +
" has purchased a " + claimType + " at " +
@ -143,30 +153,26 @@ public class ClaimSell extends ClaimTransaction
OfflinePlayer oldOwner = Bukkit.getOfflinePlayer(owner);
if(oldOwner.isOnline())
{
((Player) oldOwner).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + player.getDisplayName() +
" has purchased your " + claimType + " at " + ChatColor.BLUE +
"[" + player.getLocation().getWorld().getName() + ", " +
"X: " + player.getLocation().getBlockX() + ", " +
"Y: " + player.getLocation().getBlockY() + ", " +
"Z: " + player.getLocation().getBlockZ() + "] " + ChatColor.AQUA + "for " + ChatColor.GREEN +
price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(oldOwner.getPlayer(), RealEstate.instance.messages.msgInfoClaimOwnerSold,
player.getName(),
claimTypeDisplay,
RealEstate.econ.format(price),
location);
}
else if(RealEstate.instance.config.cfgMailOffline && RealEstate.ess != null)
{
User u = RealEstate.ess.getUser(owner);
u.addMail(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + player.getDisplayName() +
" has purchased your " + claimType + " at " + ChatColor.BLUE +
"[" + player.getLocation().getWorld().getName() + ", " +
"X: " + player.getLocation().getBlockX() + ", " +
"Y: " + player.getLocation().getBlockY() + ", " +
"Z: " + player.getLocation().getBlockZ() + "] " + ChatColor.AQUA + "for " + ChatColor.GREEN +
price + " " + RealEstate.econ.currencyNamePlural());;
u.addMail(Messages.getMessage(RealEstate.instance.messages.msgInfoClaimOwnerSold,
player.getName(),
claimTypeDisplay,
RealEstate.econ.format(price),
location));
}
}
}
else
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED + "Cannot purchase claim!");
Messages.sendMessage(player, RealEstate.instance.messages.msgErrorUnexpected);
return;
}
RealEstate.transactionsStore.cancelTransaction(claim);
@ -177,29 +183,35 @@ public class ClaimSell extends ClaimTransaction
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 Sale Info" + ChatColor.WHITE + "]" +
ChatColor.BLUE + " =-----\n";
msg += ChatColor.AQUA + "This " + claimType + " is for sale for " +
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural() + "\n";
String claimTypeDisplay = claim.parent == null ?
RealEstate.instance.messages.keywordClaim : RealEstate.instance.messages.keywordSubclaim;
String msg = Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoSellHeader) + "\n";
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoSellGeneral,
claimTypeDisplay,
RealEstate.econ.format(price)) + "\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() + "\n";
msg += ChatColor.LIGHT_PURPLE + "Note: " + ChatColor.AQUA + "You will only buy access to this subclaim!";
}
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoOwner,
claim.getOwnerName()) + "\n";
}
else
{
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoMainOwner,
claim.parent.getOwnerName()) + "\n";
msg += Messages.getMessage(RealEstate.instance.messages.msgInfoClaimInfoNote) + "\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
@ -211,12 +223,19 @@ public class ClaimSell extends ClaimTransaction
@Override
public void msgInfo(CommandSender cs)
{
cs.sendMessage(ChatColor.DARK_GREEN + "" + GriefPrevention.instance.dataStore.getClaim(claimId).getArea() +
ChatColor.AQUA + " blocks to " + ChatColor.DARK_GREEN + "Sell " + 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 + price + " " + RealEstate.econ.currencyNamePlural());
Claim claim = GriefPrevention.instance.dataStore.getClaim(claimId);
if(claim == null) {
tryCancelTransaction(null, true);
return;
}
String location = "[" + claim.getLesserBoundaryCorner().getWorld().getName() + ", " +
"X: " + claim.getLesserBoundaryCorner().getBlockX() + ", " +
"Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " +
"Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "]";
Messages.sendMessage(cs, RealEstate.instance.messages.msgInfoClaimInfoSellOneline,
claim.getArea() + "",
location,
RealEstate.econ.format(price));
}
}

View File

@ -17,10 +17,12 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import me.EtienneDx.RealEstate.Messages;
import me.EtienneDx.RealEstate.RealEstate;
import me.EtienneDx.RealEstate.Utils;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import net.md_5.bungee.api.ChatColor;
public class TransactionsStore
{
@ -194,12 +196,18 @@ public class TransactionsStore
"Y: " + claim.getGreaterBoundaryCorner().getBlockY() + ", " +
"Z: " + claim.getGreaterBoundaryCorner().getBlockZ() + "] " +
"Price: " + price + " " + RealEstate.econ.currencyNamePlural());
String claimPrefix = claim.isAdminClaim() ? RealEstate.instance.messages.keywordAdminClaimPrefix :
RealEstate.instance.messages.keywordClaimPrefix;
String claimTypeDisplay = claim.parent == null ? RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim;
if(player != null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully created " +
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " sale for " +
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimCreatedSell,
claimPrefix,
claimTypeDisplay,
RealEstate.econ.format(price));
}
if(RealEstate.instance.config.cfgBroadcastSell)
{
@ -207,10 +215,11 @@ public class TransactionsStore
{
if(p != player)
{
p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.DARK_GREEN + (player == null ? "The Server" : player.getDisplayName()) +
ChatColor.AQUA + " has put " +
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for sale for " +
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(p, RealEstate.instance.messages.msgInfoClaimCreatedSellBroadcast,
player == null ? RealEstate.instance.messages.keywordTheServer : player.getDisplayName(),
claimPrefix,
claimTypeDisplay,
RealEstate.econ.format(price));
}
}
}
@ -230,12 +239,19 @@ public class TransactionsStore
"Y: " + claim.getLesserBoundaryCorner().getBlockY() + ", " +
"Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "] " +
"Price: " + price + " " + RealEstate.econ.currencyNamePlural());
String claimPrefix = claim.isAdminClaim() ? RealEstate.instance.messages.keywordAdminClaimPrefix :
RealEstate.instance.messages.keywordClaimPrefix;
String claimTypeDisplay = claim.parent == null ? RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim;
if(player != null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully put " +
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for" + (buildTrust ? "" : " container") + " rent for " +
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimCreatedRent,
claimPrefix,
claimTypeDisplay,
RealEstate.econ.format(price),
Utils.getTime(duration, null, false));
}
if(RealEstate.instance.config.cfgBroadcastSell)
{
@ -243,10 +259,12 @@ public class TransactionsStore
{
if(p != player)
{
p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.DARK_GREEN + (player == null ? "The Server" : player.getDisplayName()) +
ChatColor.AQUA + " has put " +
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for" + (buildTrust ? "" : " container") + " rent for " +
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(p, RealEstate.instance.messages.msgInfoClaimCreatedRentBroadcast,
player == null ? RealEstate.instance.messages.keywordTheServer : player.getDisplayName(),
claimPrefix,
claimTypeDisplay,
RealEstate.econ.format(price),
Utils.getTime(duration, null, false));
}
}
}
@ -267,13 +285,20 @@ public class TransactionsStore
"Z: " + claim.getLesserBoundaryCorner().getBlockZ() + "] " +
"Payments Count : " + paymentsCount + " " +
"Price: " + price + " " + RealEstate.econ.currencyNamePlural());
String claimPrefix = claim.isAdminClaim() ? RealEstate.instance.messages.keywordAdminClaimPrefix :
RealEstate.instance.messages.keywordClaimPrefix;
String claimTypeDisplay = claim.parent == null ? RealEstate.instance.messages.keywordClaim :
RealEstate.instance.messages.keywordSubclaim;
if(player != null)
{
player.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.AQUA + "You have successfully put " +
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for lease for " +
ChatColor.GREEN + paymentsCount + ChatColor.AQUA + " payments of " +
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(player, RealEstate.instance.messages.msgInfoClaimCreatedLease,
claimPrefix,
claimTypeDisplay,
RealEstate.econ.format(price),
paymentsCount + "",
Utils.getTime(frequency, null, false));
}
if(RealEstate.instance.config.cfgBroadcastSell)
{
@ -281,11 +306,13 @@ public class TransactionsStore
{
if(p != player)
{
p.sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.DARK_GREEN + (player == null ? "The Server" : player.getDisplayName()) +
ChatColor.AQUA + " has put " +
(claim.isAdminClaim() ? "an admin" : "a") + " " + (claim.parent == null ? "claim" : "subclaim") + " for lease for " +
ChatColor.GREEN + paymentsCount + ChatColor.AQUA + " payments of " +
ChatColor.GREEN + price + " " + RealEstate.econ.currencyNamePlural());
Messages.sendMessage(p, RealEstate.instance.messages.msgInfoClaimCreatedLeaseBroadcast,
player == null ? RealEstate.instance.messages.keywordTheServer : player.getDisplayName(),
claimPrefix,
claimTypeDisplay,
RealEstate.econ.format(price),
paymentsCount + "",
Utils.getTime(frequency, null, false));
}
}
}

View File

@ -5,13 +5,11 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.ClaimPermission;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import me.ryanhamshire.GriefPrevention.PlayerData;
import net.md_5.bungee.api.ChatColor;
import net.milkbowl.vault.economy.EconomyResponse;
public class Utils
@ -24,13 +22,11 @@ public class Utils
{
if(b.isOnline() && msgBuyer)
{
((Player)b).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"You don't have enough money to make this transaction!");
Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoMoneySelf);
}
if(s != null && s.isOnline() && msgSeller)
{
((Player)s).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
b.getName() + " doesn't have enough money to make this transaction!");
Messages.sendMessage(s.getPlayer(), RealEstate.instance.messages.msgErrorNoMoneyOther, b.getName());
}
return false;
}
@ -39,13 +35,11 @@ public class Utils
{
if(b.isOnline() && msgBuyer)
{
((Player)b).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"Could not withdraw the money!");
Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoWithdrawSelf);
}
if(s != null && s.isOnline() && msgSeller)
{
((Player)s).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"Could not withdraw the money!");
Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoWithdrawOther);
}
return false;
}
@ -56,13 +50,11 @@ public class Utils
{
if(b.isOnline() && msgBuyer)
{
((Player)b).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"Could not deposit to " + s.getName() + ", refunding Player!");
Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoDepositOther, s.getName());
}
if(s != null && s.isOnline() && msgSeller)
{
((Player)s).sendMessage(RealEstate.instance.config.chatPrefix + ChatColor.RED +
"Could not deposit to you, refunding" + b.getName() + "!");
Messages.sendMessage(b.getPlayer(), RealEstate.instance.messages.msgErrorNoDepositSelf, b.getName());
}
RealEstate.econ.depositPlayer(b, amount);
return false;