diff --git a/src/me/EtienneDx/RealEstate/Messages.java b/src/me/EtienneDx/RealEstate/Messages.java index 029de32..ee351ed 100644 --- a/src/me/EtienneDx/RealEstate/Messages.java +++ b/src/me/EtienneDx/RealEstate/Messages.java @@ -453,6 +453,9 @@ public class Messages extends AnnotationConfig @ConfigField(name="RealEstate.Info.Claim.Info.Auction.Ended", comment = "0: claim type") public String msgInfoClaimInfoAuctionEnded = "$bThe auction for the {0} has ended."; + @ConfigField(name="RealEstate.Info.Claim.Info.Auction.Cancelled", comment = "0: claim type") + public String msgInfoClaimInfoAuctionCancelled = "$bThe auction for the {0} has been cancelled. You have been reimbursed."; + @ConfigField(name="RealEstate.Info.Claim.Info.Owner", comment = "0: owner name") public String msgInfoClaimInfoOwner = "$bThe current owner is $a{0}"; diff --git a/src/me/EtienneDx/RealEstate/Transactions/ClaimAuction.java b/src/me/EtienneDx/RealEstate/Transactions/ClaimAuction.java index 84d0dca..1bd10fa 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/ClaimAuction.java +++ b/src/me/EtienneDx/RealEstate/Transactions/ClaimAuction.java @@ -88,6 +88,14 @@ else if(!Utils.makePayment(owner, null, price, false, false)) if(buyerPlayer.isOnline()) { Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgErrorAuctionCouldntPayOwner); + if(!Utils.makePayment(buyer, null, price, false, false)) + { + RealEstate.instance.log.warning("Couldn't reimburse " + price + " to " + buyerPlayer.getName() + " for the cancellation of an auction"); + } + if(buyerPlayer.isOnline()) + { + Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoAuctionCancelled); + } } if(owner != null && ownerPlayer.isOnline()) { @@ -153,8 +161,20 @@ else if(!Utils.makePayment(owner, null, price, false, false)) @Override public boolean tryCancelTransaction(Player p, boolean force) { - if(buyer == null || force || p.hasPermission("realestate.admin")) + if(buyer == null || RealEstate.instance.config.cfgCancelAuction || force || p.hasPermission("realestate.admin")) { + if(buyer != null) + { + OfflinePlayer buyerPlayer = Bukkit.getOfflinePlayer(buyer); + if(!Utils.makePayment(buyer, null, price, false, false)) + { + RealEstate.instance.log.warning("Couldn't reimburse " + price + " to " + buyerPlayer.getName() + " for the cancellation of an auction"); + } + if(buyerPlayer.isOnline()) + { + Messages.sendMessage(buyerPlayer.getPlayer(), RealEstate.instance.messages.msgInfoClaimInfoAuctionCancelled); + } + } RealEstate.transactionsStore.cancelTransaction(this); return true; } diff --git a/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java b/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java index 27062aa..3fea747 100644 --- a/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java +++ b/src/me/EtienneDx/RealEstate/Transactions/TransactionsStore.java @@ -206,7 +206,9 @@ public void cancelTransaction(Transaction tr) public boolean canCancelTransaction(Transaction tr) { - return tr instanceof ClaimSell || tr instanceof ClaimAuction || (tr instanceof ClaimRent && ((ClaimRent)tr).buyer == null) || + return tr instanceof ClaimSell || + (tr instanceof ClaimAuction && ((ClaimRent)tr).buyer == null || RealEstate.instance.config.cfgCancelAuction) || + (tr instanceof ClaimRent && ((ClaimRent)tr).buyer == null) || (tr instanceof ClaimLease && ((ClaimLease)tr).buyer == null); }